Two trivial patches for /bin/sh

Douglas S. Keester dkeester at comcast.net
Sun Jun 4 21:09:20 PDT 2006


I wanted to submit these before I attempt any serious surgery on /bin/sh.

These two patches *mostly* bring /bin/sh up to WARNS?=3. They don't correct 
the "comparison is always true due to limited range of data type" errors that 
also appear on WARNS?=0.

The eval.c patch fixes possible logjmp clobbering. The histedit.c patch fixes 
a warning of possibly returning an uninitialized value from str_to_event. (I 
initialize 'i' as well for good measure.)

Index: eval.c
===================================================================
RCS file: /home/dcvs/src/bin/sh/eval.c,v
retrieving revision 1.5
diff -u -p -r1.5 eval.c
--- eval.c      12 May 2006 01:56:11 -0000      1.5
+++ eval.c      4 Jun 2006 08:15:20 -0000
@@ -977,6 +977,12 @@    struct jmploc loc, *old;
        struct strlist *sp;
        const char *path;
        int ch;
+#ifdef __GNUC__
+       /* Avoid longjmp clobbering */
+       (void) &path;
+       (void) &argc;
+       (void) &argv;
+#endif

        for (sp = cmdenviron; sp ; sp = sp->next)
                setvareq(sp->text, VEXPORT|VSTACK);
Index: histedit.c
===================================================================
RCS file: /home/dcvs/src/bin/sh/histedit.c,v
retrieving revision 1.7
diff -u -p -r1.7 histedit.c
--- histedit.c  17 Jan 2006 15:06:26 -0000      1.7
+++ histedit.c  25 May 2006 19:05:33 -0000
@@ -441,6 +441,7 @@     const char *s = str;
        int relative = 0;
        int i, retval;

+       i = retval = 0;
        history(hist, &he, H_FIRST);
        switch (*s) {
        case '-':

-- 
Douglas S. Keester
mailto:dkeester at xxxxxxxxxxx

"We, the unwilling, led by the unknowing,
are doing the impossible for the ungrateful.
We have done so much, for so long, with so little,
we are now qualified to do anything with nothing."
        -Mother Teresa
two trivial patches for /bin/sh

Index: eval.c
===================================================================
RCS file: /home/dcvs/src/bin/sh/eval.c,v
retrieving revision 1.5
diff -u -p -r1.5 eval.c
--- eval.c      12 May 2006 01:56:11 -0000      1.5
+++ eval.c      4 Jun 2006 08:15:20 -0000
@@ -977,6 +977,12 @@    struct jmploc loc, *old;
        struct strlist *sp;
        const char *path;
        int ch;
+#ifdef __GNUC__
+       /* Avoid longjmp clobbering */
+       (void) &path;
+       (void) &argc;
+       (void) &argv;
+#endif
 
        for (sp = cmdenviron; sp ; sp = sp->next)
                setvareq(sp->text, VEXPORT|VSTACK);
Index: histedit.c
===================================================================
RCS file: /home/dcvs/src/bin/sh/histedit.c,v
retrieving revision 1.7
diff -u -p -r1.7 histedit.c
--- histedit.c  17 Jan 2006 15:06:26 -0000      1.7
+++ histedit.c  25 May 2006 19:05:33 -0000
@@ -441,6 +441,7 @@     const char *s = str;
        int relative = 0;
        int i, retval;
 
+       i = retval = 0;
        history(hist, &he, H_FIRST);
        switch (*s) {
        case '-':




More information about the Submit mailing list