On Mon 2011.03.14 at 11:05 +0800, Kevin Lo wrote:
> This diff fixes uninitialized variable warnings emitted by gcc 4.2.1
> on i386/amd64.
How's this instead (lifted from mksh)?
Index: eval.c
===================================================================
RCS file: /home/okan/hack/open/cvs/src/bin/ksh/eval.c,v
retrieving revision 1.35
diff -u -p -r1.35 eval.c
--- eval.c 24 Mar 2010 08:27:26 -0000 1.35
+++ eval.c 14 Mar 2011 07:09:37 -0000
@@ -152,7 +152,10 @@ expand(char *cp, /* input word */
char *dp, *sp; /* dest., source */
int fdo, word; /* second pass flags; have word */
int doblank; /* field splitting of parameter/command subst */
- Expand x; /* expansion variables */
+ Expand x = {
+ /* expansion variables */
+ NULL, { NULL }, NULL, 0
+ };
SubType st_head, *st;
int newlines = 0; /* For trailing newlines in COMSUB */
int saw_eq, tilde_ok;
@@ -265,7 +268,7 @@ expand(char *cp, /* input word */
{
char *varname = ++sp; /* skip the { or x (}) */
int stype;
- int slen;
+ int slen = 0;
sp = strchr(sp, '\0') + 1; /* skip variable */
type = varsub(&x, varname, sp, &stype, &slen);