[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fopen: Silence a gcc warning
From: |
Bruno Haible |
Subject: |
fopen: Silence a gcc warning |
Date: |
Tue, 02 May 2023 20:55:32 +0200 |
The continuous integration of 'gzip' failed today:
CC fopen.o
fopen.c: In function 'rpl_fopen':
fopen.c:50:7: error: variable 'open_direction' set but not used
[-Werror=unused-but-set-variable]
50 | int open_direction;
| ^~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[6]: *** [Makefile:2311: fopen.o] Error 1
Contributing factors are:
- There is a depencency from module 'fclose' to module 'fopen' since last
week.
- The variable 'open_direction' is set but possibly not used (depending
on #if conditions).
- gzip's configuration apparently enables many warnings and -Werror.
- The fopen module uses AC_LIBOBJ, in order to avoid link error w.r.t.
to modules fopen vs. fopen-gnu.
- In AC_LIBOBJ compilation units, Gnulib's override of the CFLAGS with
-Wno-error has no effect.
The easiest fix is the following:
2023-05-02 Bruno Haible <bruno@clisp.org>
fopen: Silence a gcc warning.
* lib/fopen.c (rpl_fopen): Mark open_direction as used.
diff --git a/lib/fopen.c b/lib/fopen.c
index f8469a0bbc..e1e4cdbd23 100644
--- a/lib/fopen.c
+++ b/lib/fopen.c
@@ -225,5 +225,9 @@ rpl_fopen (const char *filename, const char *mode)
}
#endif
+ /* open_direction is sometimes used, sometimes unused.
+ Silence gcc's warning about this situation. */
+ (void) open_direction;
+
return orig_fopen (filename, mode);
}
- fopen: Silence a gcc warning,
Bruno Haible <=