From 0de35447382fec8ac50c6592bbedb6d999672752 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 5 Jan 2024 21:59:40 +0100 Subject: [PATCH] Fix compiler warnings for unused local variables Instead of assigning the return value to an otherwise unused variable (which also raises a compiler warning), use a cast to void to explicitly indicate that the return value is intentionally ignored. Signed-off-by: Stefan Weil --- src/colormap.c | 6 +++--- src/kernel.c | 8 ++++---- src/pnmio.c | 2 -- src/sarray1.c | 4 ++-- src/sel1.c | 10 +++++----- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/colormap.c b/src/colormap.c index 7d5b567ab..dd1f3bd1b 100644 --- a/src/colormap.c +++ b/src/colormap.c @@ -1787,7 +1787,7 @@ PIXCMAP *cmap; PIXCMAP * pixcmapReadStream(FILE *fp) { -l_int32 rval, gval, bval, aval, ignore; +l_int32 rval, gval, bval, aval; l_int32 i, index, ret, depth, ncolors; PIXCMAP *cmap; @@ -1800,8 +1800,8 @@ PIXCMAP *cmap; (depth != 1 && depth != 2 && depth != 4 && depth != 8) || (ncolors < 2 || ncolors > 256)) return (PIXCMAP *)ERROR_PTR("invalid cmap size", __func__, NULL); - ignore = fscanf(fp, "Color R-val G-val B-val Alpha\n"); - ignore = fscanf(fp, "----------------------------------------\n"); + (void)fscanf(fp, "Color R-val G-val B-val Alpha\n"); + (void)fscanf(fp, "----------------------------------------\n"); if ((cmap = pixcmapCreate(depth)) == NULL) return (PIXCMAP *)ERROR_PTR("cmap not made", __func__, NULL); diff --git a/src/kernel.c b/src/kernel.c index edb56fb31..9ad4042c7 100644 --- a/src/kernel.c +++ b/src/kernel.c @@ -537,7 +537,7 @@ L_KERNEL *kel; L_KERNEL * kernelReadStream(FILE *fp) { -l_int32 sy, sx, cy, cx, i, j, ret, version, ignore; +l_int32 sy, sx, cy, cx, i, j, ret, version; L_KERNEL *kel; if (!fp) @@ -562,10 +562,10 @@ L_KERNEL *kel; for (i = 0; i < sy; i++) { for (j = 0; j < sx; j++) - ignore = fscanf(fp, "%15f", &kel->data[i][j]); - ignore = fscanf(fp, "\n"); + (void)fscanf(fp, "%15f", &kel->data[i][j]); + (void)fscanf(fp, "\n"); } - ignore = fscanf(fp, "\n"); + (void)fscanf(fp, "\n"); return kel; } diff --git a/src/pnmio.c b/src/pnmio.c index c3e2831c9..2f69909eb 100644 --- a/src/pnmio.c +++ b/src/pnmio.c @@ -1327,8 +1327,6 @@ static l_int32 pnmReadNextAsciiValue(FILE *fp, l_int32 *pval) { -l_int32 ignore; - if (!pval) return ERROR_INT("&val not defined", __func__, 1); *pval = 0; diff --git a/src/sarray1.c b/src/sarray1.c index ba5719a99..2e6c39dd1 100644 --- a/src/sarray1.c +++ b/src/sarray1.c @@ -1387,7 +1387,7 @@ SARRAY * sarrayReadStream(FILE *fp) { char *stringbuf; -l_int32 i, n, size, index, bufsize, version, ignore, success; +l_int32 i, n, size, index, bufsize, version, success; SARRAY *sa; if (!fp) @@ -1435,7 +1435,7 @@ SARRAY *sa; /* Copy it in, skipping the 2 leading spaces */ sarrayAddString(sa, stringbuf + 2, L_COPY); } - ignore = fscanf(fp, "\n"); + (void)fscanf(fp, "\n"); cleanup: LEPT_FREE(stringbuf); diff --git a/src/sel1.c b/src/sel1.c index c7e24e93b..321266b89 100644 --- a/src/sel1.c +++ b/src/sel1.c @@ -1351,7 +1351,7 @@ selReadStream(FILE *fp) { char selname[256]; char linebuf[256]; -l_int32 sy, sx, cy, cx, i, j, version, ignore; +l_int32 sy, sx, cy, cx, i, j, version; SEL *sel; if (!fp) @@ -1375,12 +1375,12 @@ SEL *sel; selSetOrigin(sel, cy, cx); for (i = 0; i < sy; i++) { - ignore = fscanf(fp, " "); + (void)fscanf(fp, " "); for (j = 0; j < sx; j++) - ignore = fscanf(fp, "%1d", &sel->data[i][j]); - ignore = fscanf(fp, "\n"); + (void)fscanf(fp, "%1d", &sel->data[i][j]); + (void)fscanf(fp, "\n"); } - ignore = fscanf(fp, "\n"); + (void)fscanf(fp, "\n"); return sel; }