Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: fix warnings from 54710
- X-seq: zsh-workers 54776
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Cc: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: PATCH: fix warnings from 54710
- Date: Mon, 15 Jun 2026 02:11:56 +0200
- Archived-at: <https://zsh.org/workers/54776>
- In-reply-to: <CAHYJk3SBzsidh+cPxg-Sjoc1fC4YdxNxAp=MOnjwu8zmRAs2aA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAHYJk3SBzsidh+cPxg-Sjoc1fC4YdxNxAp=MOnjwu8zmRAs2aA@mail.gmail.com>
Some compilers warn if a label immediately precedes a variable declaration. This used
to be helpful back in C89 when variable declarations had to come first, but when that
requirement was relaxed, they forgot about case labels, and eventually rememebered in
C23.
---
From what I could see, we use the
label: {
int decl;
... code here
}
pattern in some places, but it doesn't work well with the default: label because we'd
end up with two closing braces on the same indent level which looks wrong, so I went
with this style here.
Src/Modules/system.c | 4 ++--
Src/Modules/zftp.c | 12 +++++++-----
Src/Zle/complete.c | 12 +++++++-----
Src/exec.c | 20 +++++++++++---------
Src/glob.c | 12 +++++++-----
5 files changed, 34 insertions(+), 26 deletions(-)
diff --git a/Src/Modules/system.c b/Src/Modules/system.c
index 4d2f8c42a3..57daf0d871 100644
--- a/Src/Modules/system.c
+++ b/Src/Modules/system.c
@@ -556,7 +556,7 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
#endif
while (*args && **args == '-') {
- int opt;
+ convchar_t opt;
char *optptr = *args + 1, *optarg;
args++;
if (!*optptr || !strcmp(optptr, "-"))
@@ -653,7 +653,7 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func))
break;
default:
- convchar_t opt = unmeta_one(optptr, NULL);
+ opt = unmeta_one(optptr, NULL);
zwarnnam(nam, "flock: bad option: %c", opt);
return 1;
}
diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c
index f863676c12..738b22b43e 100644
--- a/Src/Modules/zftp.c
+++ b/Src/Modules/zftp.c
@@ -3093,11 +3093,13 @@ bin_zftp(char *name, char **args, UNUSED(Options ops), UNUSED(int func))
break;
default:
- int sz;
- convchar_t p = unmeta_one(ptr, &sz);
- ptr += sz - 1;
- zwarnnam(name, "preference %c not recognized", p);
- break;
+ {
+ int sz;
+ convchar_t p = unmeta_one(ptr, &sz);
+ ptr += sz - 1;
+ zwarnnam(name, "preference %c not recognized", p);
+ break;
+ }
}
}
}
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index b8e203b80f..28d62efea2 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -797,11 +797,13 @@ bin_compadd(char *name, char **argv, UNUSED(Options ops), UNUSED(int func))
argv++;
goto ca_args;
default:
- convchar_t c = unmeta_one(p, NULL);
- zwarnnam(name, "bad option: -%c", c);
- zsfree(mstr);
- zfree(dat.dpar, dparsize);
- return 1;
+ {
+ convchar_t c = unmeta_one(p, NULL);
+ zwarnnam(name, "bad option: -%c", c);
+ zsfree(mstr);
+ zfree(dat.dpar, dparsize);
+ return 1;
+ }
}
if (sp) {
if (p[1]) {
diff --git a/Src/exec.c b/Src/exec.c
index f7249f551a..17899262d6 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -3300,15 +3300,17 @@ execcmd_exec(Estate state, Execcmd_params eparams,
cflags |= BINF_DASH;
break;
default:
- convchar_t opt = unmeta_one(cmdopt, NULL);
- zerr("unknown exec flag -%c", opt);
- lastval = 1;
- errflag |= ERRFLAG_ERROR;
- if (forked)
- _realexit();
- if (how & Z_TIMED)
- shelltime(&shti, &chti, &then, 1);
- return;
+ {
+ convchar_t opt = unmeta_one(cmdopt, NULL);
+ zerr("unknown exec flag -%c", opt);
+ lastval = 1;
+ errflag |= ERRFLAG_ERROR;
+ if (forked)
+ _realexit();
+ if (how & Z_TIMED)
+ shelltime(&shti, &chti, &then, 1);
+ return;
+ }
}
}
if (!argnode)
diff --git a/Src/glob.c b/Src/glob.c
index b9f7223781..0b516d226e 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -1755,11 +1755,13 @@ zglob(LinkList list, LinkNode np, int nountok)
break;
}
default:
- untokenize(--s);
- convchar_t attr = unmeta_one(s, NULL);
- zerr("unknown file attribute: %c", attr);
- restore_globstate(saved);
- return;
+ {
+ untokenize(--s);
+ convchar_t attr = unmeta_one(s, NULL);
+ zerr("unknown file attribute: %c", attr);
+ restore_globstate(saved);
+ return;
+ }
}
}
if (func) {
--
2.38.1
Messages sorted by:
Reverse Date,
Date,
Thread,
Author