PATCH: A few very minor things coverity complained about

Mikael Magnusson <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <[email protected]>
Coverity CID 1692322 in Src/glob.c:
  i'm pretty sure this is a false positive so add a debug message just in case

Coverity CID 1500752 in Src/Zle/compresult.c:
  remove unused assignment that also reads uninitialized pointer p

And two that were just near other things it complained about

Src/utils.c:
  Warn if maildir disappeared from under us

Src/Modules/system.c:
  stray \n in zwarn message

Src/subst.c:
  Use DIGBUFSIZE for buf holding digits

  This one would be a little hard to overflow in practice, you'd need a
  parameter at least 100000000000000 characters long, which is 100TB.
---
 Src/Modules/system.c | 2 +-
 Src/Zle/compresult.c | 2 --
 Src/glob.c           | 3 +++
 Src/subst.c          | 2 +-
 Src/utils.c          | 4 +++-
 5 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/Src/Modules/system.c b/Src/Modules/system.c
index f1c0d7042f..1f3665dba5 100644
--- a/Src/Modules/system.c
+++ b/Src/Modules/system.c
@@ -357,7 +357,7 @@ bin_sysopen(char *nam, char **args, Options ops, UNUSED(int func))
 	    for (o = sizeof(openopts)/sizeof(*openopts) - 1; o >= 0 &&
 		strcasecmp(openopts[o].name, opt); o--) {}
 	    if (o < 0) {
-		zwarnnam(nam, "unsupported option: %s\n", opt);
+		zwarnnam(nam, "unsupported option: %s", opt);
 		return 1;
 	    }
 #if defined(FD_CLOEXEC) && !defined(O_CLOEXEC)
diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c
index 5b08895235..45f01fef5c 100644
--- a/Src/Zle/compresult.c
+++ b/Src/Zle/compresult.c
@@ -1774,8 +1774,6 @@ calclist(int showall)
                                  width < zterm_columns && nth < g->dcount;
                                  nth++, tline++) {
 
-                                m = *p;
-
                                 if (tline == tlines) {
                                     tcol++;
                                     tline = 0;
diff --git a/Src/glob.c b/Src/glob.c
index e134819552..7511c1c154 100644
--- a/Src/glob.c
+++ b/Src/glob.c
@@ -3021,6 +3021,9 @@ igetmatch(char **sp, Patprog p, int fl, int n, char *replstr,
 		imd.repllist = (fl & SUB_LIST) ? znewlinklist() : newlinklist();
 		if (repllistp)
 		     *repllistp = imd.repllist;
+		else {
+		    DPUTS((fl & SUB_LIST), "leaking a linklist");
+		}
 	    }
 	    ioff = 0;		/* offset into string */
 	    umlen = umltot;
diff --git a/Src/subst.c b/Src/subst.c
index 56c1ad6ddb..5f8436e280 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -3844,7 +3844,7 @@ colonsubscript:
      */
     if (getlen) {
 	long len = 0;
-	char buf[14];
+	char buf[DIGBUFSIZE];
 
 	if (isarr) {
 	    char **ctr;
diff --git a/Src/utils.c b/Src/utils.c
index 2a1d49e5ad..94844e4229 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -1645,7 +1645,9 @@ checkmailpath(char **s)
 	    char buf[PATH_MAX * 2 + 1], **arr, **ap;
 	    int buflen, ct = 1;
 
-	    if (lock) {
+	    if (!lock)
+		zerr("%e: %s", errno, *s);
+	    else {
 		char *fn;
 
 		pushheap();
-- 
2.38.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.