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

Re: zle_thingy.c: variable "modsave" used before its value set

On Mon, Apr 12, 2004 at 10:38:00AM +0900, Jens Petersen wrote:
> I received a bug report that the local variable `modsave' is
> used uninitialised in bin_zle_call() (zle_thingy.c).

The variable can't actually be used uninitialized -- the compiler just
thinks it can.

If we want to get rid of the warning, I'd recommend making the struct
static rather than initializing it to an unneeded value on every call.
Here's a patch that does this, plus it gets rid of some unneeded cleanup
code that can't get triggered.

--- Src/Zle/zle_thingy.c	12 Dec 2003 22:53:28 -0000	1.12
+++ Src/Zle/zle_thingy.c	12 Apr 2004 08:40:04 -0000
@@ -622,13 +622,11 @@ static int
 bin_zle_call(char *name, char **args, Options ops, char func)
     Thingy t;
-    struct modifier modsave;
+    static struct modifier modsave;
     int ret, saveflag = 0;
     char *wname = *args++;
     if (!wname) {
-	if (saveflag)
-	    zmod = modsave;
 	return (!zleactive || incompctlfunc || incompfunc ||
 		sfcontext != SFC_WIDGET);

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