Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] fix 'conditionally uninitialized' variables



I tried 'clang -Wconditional-uninitialized' and it gave about 25 warnings.
I've looked into only some of them, and I believe most of them can be
(or should be) ignored. The following two, however, may be worth fixing.

In builtin.c, the variable 's' may (or may not) be assigned at line 1480, but
using the value at line 1613 is meaningless. I guess this is just a typo.

utils.c is currently working fine because when NICEFLAG_QUOTE is set the
return value of mb_niceformat() is not used.


diff --git a/Src/builtin.c b/Src/builtin.c
index fb14b2e..da45300 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -1610,7 +1610,7 @@ bin_fc(char *nam, char **argv, Options ops, int func)
 		unqueue_signals();
 		if (fcedit(editor, fil)) {
 		    if (stuff(fil))
-			zwarnnam("fc", "%e: %s", errno, s);
+			zwarnnam("fc", "%e: %s", errno, fil);
 		    else {
 			loop(0,1);
 			retval = lastval;
diff --git a/Src/utils.c b/Src/utils.c
index 0a5954f..bdb614d 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -5080,8 +5080,10 @@ mb_niceformat(const char *s, FILE *stream, char **outstrp, int flags)
 	    cnt = 1;
 	    /* FALL THROUGH */
 	default:
-	    if (c == L'\'' && (flags & NICEFLAG_QUOTE))
+	    if (c == L'\'' && (flags & NICEFLAG_QUOTE)) {
 		fmt = "\\'";
+		newl = 2;
+	    }
 	    else
 		fmt = wcs_nicechar_sel(c, &newl, NULL, flags & NICEFLAG_QUOTE);
 	    break;



Messages sorted by: Reverse Date, Date, Thread, Author