commit: b6cba2230bc94a954de6e61f11141fe2c56c5836
parent b61883a7672368b1e7b6c6a4b5b54a38193f803f
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 30 Aug 2024 10:16:33 +0200
cmd/base64: rely on fwrite return value rather than errno
Diffstat:
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/cmd/base64.c b/cmd/base64.c
@@ -104,15 +104,14 @@ encode(FILE *fin, const char *name)
obuf[4 - pad] = '=';
}
- assert(errno == 0);
- fwrite((char *)obuf, 4, 1, stdout);
- if(errno != 0)
+ if(fwrite((char *)obuf, 4, 1, stdout) <= 0)
{
fprintf(stderr, "base64: Error writing: %s\n", strerror(errno));
errno = 0;
return 1;
}
c_out += 4;
+ assert(errno == 0);
if(wrap_nl != 0 && (c_out + 4) > wrap_nl)
{