qr: fix exit status

Call exits(0) instead of returning from main.  Also call sysfatal if
writing of image data fails.  Previously, qr(1) would exit with
default non-nil status "main" unconditionally as a result of returning
from main.
This commit is contained in:
Alex Musolino 2021-01-05 22:36:03 +10:30
parent 76ed42e31f
commit 95b9b8863d

View file

@ -732,8 +732,11 @@ main(int argc, char **argv)
b = qrcode(ver, lev, mode, buf, rc, &s);
if(b == nil)
sysfatal("%r");
print("%11s %11d %11d %11d %11d ", "k8", 0, 0, s, s);
write(1, b, s * s);
if(print("%11s %11d %11d %11d %11d ", "k8", 0, 0, s, s) != 5*12)
sysfatal("print: %r");
if(write(1, b, s*s) != s*s)
sysfatal("write: %r");
exits(0);
}
uchar qrrawpolys[] = {