I've attached a few patches to fix some GCC warnings I noticed.
The first removes a bad definition of SIGPIPE. Commit
ede0a8888a4d3d0750e1651e01f198e2faab5d59 moved '#include "tailor.h"'
above '#include <signal.h>'. This caused SIGPIPE to be defined to zero
and then redefined:
In file included from /usr/include/signal.h:30,
from ./lib/signal.h:58,
from gzip.c:80:
/usr/include/bits/signum-generic.h:60:9: warning: 'SIGPIPE' redefined
60 | #define SIGPIPE 13 /* Broken pipe. */
| ^~~~~~~
In file included from gzip.c:59:
tailor.h:152:10: note: this is the location of the previous definition
152 | # define SIGPIPE 0
| ^~~~~~~
If my memory serves me correctly, it is undefined behavior to define
things like that. But GCC emits the correct value for SIGPIPE anyways.
We only use it in gzip.c, so we can just remove it entirely.
The other two just fix some shadowing.
Collin
>From b3f319eaa5b1e63cc6c49dff35eae26817eecf88 Mon Sep 17 00:00:00 2001
Message-ID: <b3f319eaa5b1e63cc6c49dff35eae26817eecf88.1779941378.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Wed, 27 May 2026 20:52:02 -0700
Subject: [PATCH 1/3] maint: don't redefine SIGPIPE
This fixes the following warning:
CC gzip.o
In file included from /usr/include/signal.h:30,
from ./lib/signal.h:58,
from gzip.c:80:
/usr/include/bits/signum-generic.h:60:9: warning: 'SIGPIPE' redefined
60 | #define SIGPIPE 13 /* Broken pipe. */
| ^~~~~~~
In file included from gzip.c:59:
tailor.h:152:10: note: this is the location of the previous definition
152 | # define SIGPIPE 0
| ^~~~~~~
* tailor.h (SIGPIPE): Remove definition.
* gzip.c (handled_sig): Use #ifdef instead of #if.
---
gzip.c | 2 +-
tailor.h | 5 -----
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/gzip.c b/gzip.c
index 302efe9..ba77284 100644
--- a/gzip.c
+++ b/gzip.c
@@ -228,7 +228,7 @@ static int handled_sig[] =
#ifdef SIGHUP
, SIGHUP
#endif
-#if SIGPIPE
+#ifdef SIGPIPE
, SIGPIPE
#endif
#ifdef SIGTERM
diff --git a/tailor.h b/tailor.h
index 17f82b9..a7aec97 100644
--- a/tailor.h
+++ b/tailor.h
@@ -148,11 +148,6 @@
# define OS_CODE 0x0a
#endif
-#ifndef SIGPIPE
-# define SIGPIPE 0
-#endif
-
-
/* Common defaults */
#ifndef OS_CODE
--
2.54.0
>From 2bb5dbba557acf1ca3d113eb7afad63822697fe7 Mon Sep 17 00:00:00 2001
Message-ID: <2bb5dbba557acf1ca3d113eb7afad63822697fe7.1779941378.git.collin.fu...@gmail.com>
In-Reply-To: <b3f319eaa5b1e63cc6c49dff35eae26817eecf88.1779941378.git.collin.fu...@gmail.com>
References: <b3f319eaa5b1e63cc6c49dff35eae26817eecf88.1779941378.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Wed, 27 May 2026 21:00:50 -0700
Subject: [PATCH 2/3] maint: fix -Wshadow=compatible-local warning
This fixes the following warning:
unlzw.c: In function 'unlzw':
unlzw.c:249:21: warning: declaration of 'i' shadows a previous local [-Wshadow=compatible-local]
249 | int i;
| ^
unlzw.c:157:13: note: shadowed declaration is here
157 | int i;
| ^
We can safely remove the second declaration since the value is never
used beyond this point in the parent scope and it is always initialized
in the first if statement before use.
* unlzw.c (unlzw): Remove unnecessary declaration.
---
unlzw.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/unlzw.c b/unlzw.c
index 358add3..40d48c1 100644
--- a/unlzw.c
+++ b/unlzw.c
@@ -246,8 +246,6 @@ unlzw (int in, int out)
/* And put them out in forward order */
{
- int i;
-
if (outpos+(i = (de_stack-stackp)) >= OUTBUFSIZ) {
do {
if (i > OUTBUFSIZ-outpos) i = OUTBUFSIZ-outpos;
--
2.54.0
>From 7c1ecdde390b83f2bb0ac415a0c9559e74d3cf9c Mon Sep 17 00:00:00 2001
Message-ID: <7c1ecdde390b83f2bb0ac415a0c9559e74d3cf9c.1779941378.git.collin.fu...@gmail.com>
In-Reply-To: <b3f319eaa5b1e63cc6c49dff35eae26817eecf88.1779941378.git.collin.fu...@gmail.com>
References: <b3f319eaa5b1e63cc6c49dff35eae26817eecf88.1779941378.git.collin.fu...@gmail.com>
From: Collin Funk <[email protected]>
Date: Wed, 27 May 2026 21:07:08 -0700
Subject: [PATCH 3/3] maint: fix -Wshadow=local warning
This fixes the following warning:
unzip.c: In function 'unzip':
unzip.c:189:22: warning: declaration of 'n' shadows a previous local [-Wshadow=local]
189 | register ulg n = orig_len;
| ^
unzip.c:163:9: note: shadowed declaration is here
163 | int n; /* Number of bytes in buf. */
| ^
The value in the parent scope is not used until after the second
declaration where it will be initialized to 0. Therefore, it is safe to
move.
* unzip.c (unzip): Move closer to where it is used.
---
unzip.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/unzip.c b/unzip.c
index e3d40b6..75789ae 100644
--- a/unzip.c
+++ b/unzip.c
@@ -160,7 +160,6 @@ int
unzip (int in, int out)
{
off_t orig_bytes_out = bytes_out;
- int n; /* Number of bytes in buf. */
uch buf[EXTHDR]; /* extended local header */
int err = OK;
@@ -200,6 +199,9 @@ unzip (int in, int out)
ulg crc = getcrc ();
off_t len = bytes_out - orig_bytes_out;
+ /* Number of bytes in buf. */
+ int n;
+
if (ext_header)
{
/* Validate the zip data descriptor, as follows:
--
2.54.0