logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: b0af37a039de92e89f5739e56a6ff47e3dbe1468
parent 1eecb504bfccb6ac1340206829d78338935280b0
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 15 Feb 2022 02:44:59 +0100

bin/xcd: log write error on first issue, fix fclose check

Diffstat:

Mbin/xcd.c7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/bin/xcd.c b/bin/xcd.c @@ -10,7 +10,7 @@ #include <stdio.h> /* printf(), fread(), fopen(), fclose() */ #include <string.h> /* memset(), strerror() */ -static struct rgb +struct rgb { double red, green, blue; }; @@ -115,7 +115,7 @@ concat(FILE *stream) if(print_xcd_reset() != 0) { - return 1; + goto werr; } pos_rgb = rgb_char((unsigned char)bytes); @@ -235,8 +235,9 @@ main(int argc, char *argv[]) else { err += concat(file); + err += fclose(file); - if((err += fclose(file)) != 0) + if(err != 0) { fprintf(stderr, "\nError closing ā€˜%sā€™: %s\n", argv[argi], strerror(errno)); err = 1;