summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordana <dana@dana.is>2025-05-10 23:21:48 -0500
committerdana <dana@dana.is>2025-11-16 12:56:59 -0600
commita324ce344b5c57c4dc87c911e32ede7a586bd98d (patch)
tree9d97586491adca05705e07110e72ab81d64da47c
parent53577: _git: improve max-verbose, other descriptions (diff)
downloadzsh-a324ce344b5c57c4dc87c911e32ede7a586bd98d.tar
zsh-a324ce344b5c57c4dc87c911e32ede7a586bd98d.tar.gz
zsh-a324ce344b5c57c4dc87c911e32ede7a586bd98d.tar.bz2
zsh-a324ce344b5c57c4dc87c911e32ede7a586bd98d.tar.lz
zsh-a324ce344b5c57c4dc87c911e32ede7a586bd98d.tar.xz
zsh-a324ce344b5c57c4dc87c911e32ede7a586bd98d.tar.zst
zsh-a324ce344b5c57c4dc87c911e32ede7a586bd98d.zip
53578 (tweaked): silence gcc warnings
addresses -Wmaybe-uninitialized and (spurious) -Wformat-overflow warnings omitted the change for zle_refresh.c since it was caught in w/54036
-rw-r--r--ChangeLog3
-rw-r--r--Src/Zle/computil.c2
-rw-r--r--Src/builtin.c3
-rw-r--r--Src/exec.c22
4 files changed, 18 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index a5caf0b30..9fcd6432e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2025-11-16 dana <dana@dana.is>
+ * 53578 (tweaked): Src/Zle/computil.c, Src/builtin.c,
+ Src/exec.c: silence gcc warnings
+
* 53577: Completion/Unix/Command/_git: improve max-verbose,
other descriptions
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index 6ac458c91..280e1dbd8 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -1841,7 +1841,7 @@ ca_inactive(Cadef d, char **xor, int cur, int opts)
for (; (x = (opts ? "-" : *xor)); xor++) {
int excludeall = 0;
char *grp = NULL;
- size_t grplen;
+ size_t grplen = 0;
char *next, *sep = x;
while (*sep != '+' && *sep != '-' && *sep != ':' && *sep != '*' && !idigit(*sep)) {
diff --git a/Src/builtin.c b/Src/builtin.c
index 9ddaad93e..1c0eb331e 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -3331,9 +3331,8 @@ add_autoload_function(Shfunc shf, char *funcname)
&& (shf2->node.flags & PM_LOADDIR) && (shf2->node.flags & PM_ABSPATH_USED)
&& shf2->filename)
{
- if (strlen(shf2->filename) + strlen(funcname) + 1 < PATH_MAX)
+ if (snprintf(buf, PATH_MAX, "%s/%s", shf2->filename, funcname) < PATH_MAX)
{
- sprintf(buf, "%s/%s", shf2->filename, funcname);
/* Set containing directory if the function file
* exists (do normal FPATH processing otherwise) */
if (!access(buf, R_OK)) {
diff --git a/Src/exec.c b/Src/exec.c
index efc96d861..27bca110c 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2922,7 +2922,7 @@ execcmd_exec(Estate state, Execcmd_params eparams,
struct multio *mfds[10];
char *text;
int save[10];
- int fil, dfil, is_cursh, do_exec = 0, redir_err = 0, i;
+ int fil, dfil, is_cursh = 0, do_exec = 0, redir_err = 0, i;
int nullexec = 0, magic_assign = 0, forked = 0, old_lastval;
int is_shfunc = 0, is_builtin = 0, is_exec = 0, use_defpath = 0;
/* Various flags to the command. */
@@ -6255,12 +6255,14 @@ getfpfunc(char *s, int *ksh, char **fdir, char **alt_path, int test_only)
pp = alt_path ? alt_path : fpath;
for (; *pp; pp++) {
- if (strlen(*pp) + strlen(s) + 1 >= PATH_MAX)
+ if (**pp) {
+ if (snprintf(buf, PATH_MAX, "%s/%s", *pp, s) >= PATH_MAX)
+ continue;
+ } else if (strlen(s) >= PATH_MAX) {
continue;
- if (**pp)
- sprintf(buf, "%s/%s", *pp, s);
- else
+ } else {
strcpy(buf, s);
+ }
if ((r = try_dump_file(*pp, s, buf, ksh, test_only))) {
if (fdir)
*fdir = *pp;
@@ -6408,12 +6410,14 @@ cancd(char *s)
return NULL;
if (!nocdpath)
for (cp = cdpath; *cp; cp++) {
- if (strlen(*cp) + strlen(s) + 1 >= PATH_MAX)
+ if (**cp) {
+ if (snprintf(sbuf, PATH_MAX, "%s/%s", *cp, s) >= PATH_MAX)
+ continue;
+ } else if (strlen(s) >= PATH_MAX) {
continue;
- if (**cp)
- sprintf(sbuf, "%s/%s", *cp, s);
- else
+ } else {
strcpy(sbuf, s);
+ }
if (cancd2(sbuf)) {
doprintdir = -1;
return dupstring(sbuf);