aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-11-17 20:29:00 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-11-17 20:29:00 +0000
commitd165e94f4904b921be285ac06ecd035d8fe7eb77 (patch)
tree436e3ab7b6f055553199153e99f6b7589fb488ec /shell
parent5e930fe52997747f9c5127a4c34fff0ca1057222 (diff)
downloadbusybox-w32-d165e94f4904b921be285ac06ecd035d8fe7eb77.tar.gz
busybox-w32-d165e94f4904b921be285ac06ecd035d8fe7eb77.tar.bz2
busybox-w32-d165e94f4904b921be285ac06ecd035d8fe7eb77.zip
add -Wundef, fix uncovered bugs
git-svn-id: svn://busybox.net/trunk/busybox@16571 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/shell/ash.c b/shell/ash.c
index a34c871f1..3c7639707 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -42,6 +42,7 @@
42 * When debugging is on, debugging info will be written to ./trace and 42 * When debugging is on, debugging info will be written to ./trace and
43 * a quit signal will generate a core dump. 43 * a quit signal will generate a core dump.
44 */ 44 */
45#define DEBUG 0
45 46
46 47
47#define IFS_BROKEN 48#define IFS_BROKEN
@@ -50,7 +51,7 @@
50 51
51#include "busybox.h" 52#include "busybox.h"
52 53
53#ifdef DEBUG 54#if DEBUG
54#define _GNU_SOURCE 55#define _GNU_SOURCE
55#endif 56#endif
56 57
@@ -104,7 +105,7 @@ static int *dash_errno;
104#error "Do not even bother, ash will not run on uClinux" 105#error "Do not even bother, ash will not run on uClinux"
105#endif 106#endif
106 107
107#ifdef DEBUG 108#if DEBUG
108#define _DIAGASSERT(assert_expr) assert(assert_expr) 109#define _DIAGASSERT(assert_expr) assert(assert_expr)
109#else 110#else
110#define _DIAGASSERT(assert_expr) 111#define _DIAGASSERT(assert_expr)
@@ -582,7 +583,7 @@ static const char dolatstr[] = { CTLVAR, VSNORMAL|VSQUOTE, '@', '=', '\0' };
582static const char illnum[] = "Illegal number: %s"; 583static const char illnum[] = "Illegal number: %s";
583static const char homestr[] = "HOME"; 584static const char homestr[] = "HOME";
584 585
585#ifdef DEBUG 586#if DEBUG
586#define TRACE(param) trace param 587#define TRACE(param) trace param
587#define TRACEV(param) tracev param 588#define TRACEV(param) tracev param
588#else 589#else
@@ -1937,7 +1938,7 @@ struct shparam {
1937#define uflag optlist[12] 1938#define uflag optlist[12]
1938#define viflag optlist[13] 1939#define viflag optlist[13]
1939 1940
1940#ifdef DEBUG 1941#if DEBUG
1941#define nolog optlist[14] 1942#define nolog optlist[14]
1942#define debug optlist[15] 1943#define debug optlist[15]
1943#endif 1944#endif
@@ -1964,7 +1965,7 @@ static const char *const optletters_optnames[] = {
1964 "b" "notify", 1965 "b" "notify",
1965 "u" "nounset", 1966 "u" "nounset",
1966 "\0" "vi", 1967 "\0" "vi",
1967#ifdef DEBUG 1968#if DEBUG
1968 "\0" "nolog", 1969 "\0" "nolog",
1969 "\0" "debug", 1970 "\0" "debug",
1970#endif 1971#endif
@@ -2011,7 +2012,7 @@ static int redirectsafe(union node *, int);
2011/* show.h */ 2012/* show.h */
2012 2013
2013 2014
2014#ifdef DEBUG 2015#if DEBUG
2015static void showtree(union node *); 2016static void showtree(union node *);
2016static void trace(const char *, ...); 2017static void trace(const char *, ...);
2017static void tracev(const char *, va_list); 2018static void tracev(const char *, va_list);
@@ -2536,7 +2537,7 @@ static void exverror(int, const char *, va_list)
2536static void 2537static void
2537exraise(int e) 2538exraise(int e)
2538{ 2539{
2539#ifdef DEBUG 2540#if DEBUG
2540 if (handler == NULL) 2541 if (handler == NULL)
2541 abort(); 2542 abort();
2542#endif 2543#endif
@@ -2596,7 +2597,7 @@ exvwarning(const char *msg, va_list ap)
2596static void 2597static void
2597exverror(int cond, const char *msg, va_list ap) 2598exverror(int cond, const char *msg, va_list ap)
2598{ 2599{
2599#ifdef DEBUG 2600#if DEBUG
2600 if (msg) { 2601 if (msg) {
2601 TRACE(("exverror(%d, \"", cond)); 2602 TRACE(("exverror(%d, \"", cond));
2602 TRACEV((msg, ap)); 2603 TRACEV((msg, ap));
@@ -2785,7 +2786,7 @@ evaltree(union node *n, int flags)
2785 getpid(), n, n->type, flags)); 2786 getpid(), n, n->type, flags));
2786 switch (n->type) { 2787 switch (n->type) {
2787 default: 2788 default:
2788#ifdef DEBUG 2789#if DEBUG
2789 out1fmt("Node type = %d\n", n->type); 2790 out1fmt("Node type = %d\n", n->type);
2790 fflush(stdout); 2791 fflush(stdout);
2791 break; 2792 break;
@@ -4481,7 +4482,7 @@ commandcmd(int argc, char **argv)
4481 verify |= VERIFY_VERBOSE; 4482 verify |= VERIFY_VERBOSE;
4482 else if (c == 'v') 4483 else if (c == 'v')
4483 verify |= VERIFY_BRIEF; 4484 verify |= VERIFY_BRIEF;
4484#ifdef DEBUG 4485#if DEBUG
4485 else if (c != 'p') 4486 else if (c != 'p')
4486 abort(); 4487 abort();
4487#endif 4488#endif
@@ -4907,7 +4908,7 @@ expari(int quotes)
4907 4908
4908 while (*p != CTLARI) { 4909 while (*p != CTLARI) {
4909 p--; 4910 p--;
4910#ifdef DEBUG 4911#if DEBUG
4911 if (p < start) { 4912 if (p < start) {
4912 sh_error("missing CTLARI (shouldn't happen)"); 4913 sh_error("missing CTLARI (shouldn't happen)");
4913 } 4914 }
@@ -5100,7 +5101,7 @@ subevalvar(char *p, char *str, int strloc, int subtype, int startloc, int varfla
5100 } 5101 }
5101 5102
5102 subtype -= VSTRIMRIGHT; 5103 subtype -= VSTRIMRIGHT;
5103#ifdef DEBUG 5104#if DEBUG
5104 if (subtype < 0 || subtype > 3) 5105 if (subtype < 0 || subtype > 3)
5105 abort(); 5106 abort();
5106#endif 5107#endif
@@ -5223,7 +5224,7 @@ record:
5223 goto end; 5224 goto end;
5224 } 5225 }
5225 5226
5226#ifdef DEBUG 5227#if DEBUG
5227 switch (subtype) { 5228 switch (subtype) {
5228 case VSTRIMLEFT: 5229 case VSTRIMLEFT:
5229 case VSTRIMLEFTMAX: 5230 case VSTRIMLEFTMAX:
@@ -6460,7 +6461,7 @@ set_curjob(struct job *jp, unsigned mode)
6460 jpp = curp; 6461 jpp = curp;
6461 switch (mode) { 6462 switch (mode) {
6462 default: 6463 default:
6463#ifdef DEBUG 6464#if DEBUG
6464 abort(); 6465 abort();
6465#endif 6466#endif
6466 case CUR_DELETE: 6467 case CUR_DELETE:
@@ -6581,7 +6582,7 @@ usage:
6581 while ((c = nextopt("ls:")) != '\0') 6582 while ((c = nextopt("ls:")) != '\0')
6582 switch (c) { 6583 switch (c) {
6583 default: 6584 default:
6584#ifdef DEBUG 6585#if DEBUG
6585 abort(); 6586 abort();
6586#endif 6587#endif
6587 case 'l': 6588 case 'l':
@@ -6647,7 +6648,7 @@ usage:
6647} 6648}
6648#endif /* JOBS */ 6649#endif /* JOBS */
6649 6650
6650#if defined(JOBS) || defined(DEBUG) 6651#if defined(JOBS) || DEBUG
6651static int 6652static int
6652jobno(const struct job *jp) 6653jobno(const struct job *jp)
6653{ 6654{
@@ -7827,7 +7828,7 @@ chkmail(void)
7827 if (*p == '\0') 7828 if (*p == '\0')
7828 continue; 7829 continue;
7829 for (q = p ; *q ; q++); 7830 for (q = p ; *q ; q++);
7830#ifdef DEBUG 7831#if DEBUG
7831 if (q[-1] != '/') 7832 if (q[-1] != '/')
7832 abort(); 7833 abort();
7833#endif 7834#endif
@@ -7921,7 +7922,7 @@ ash_main(int argc, char **argv)
7921 goto state4; 7922 goto state4;
7922 } 7923 }
7923 handler = &jmploc; 7924 handler = &jmploc;
7924#ifdef DEBUG 7925#if DEBUG
7925 opentrace(); 7926 opentrace();
7926 trputs("Shell args: "); trargs(argv); 7927 trputs("Shell args: "); trargs(argv);
7927#endif 7928#endif
@@ -7988,7 +7989,7 @@ state4: /* XXX ??? - why isn't this before the "if" statement */
7988#if PROFILE 7989#if PROFILE
7989 monitor(0); 7990 monitor(0);
7990#endif 7991#endif
7991#if GPROF 7992#ifdef GPROF
7992 { 7993 {
7993 extern void _mcleanup(void); 7994 extern void _mcleanup(void);
7994 _mcleanup(); 7995 _mcleanup();
@@ -8266,7 +8267,7 @@ stalloc(size_t nbytes)
8266void 8267void
8267stunalloc(pointer p) 8268stunalloc(pointer p)
8268{ 8269{
8269#ifdef DEBUG 8270#if DEBUG
8270 if (!p || (stacknxt < (char *)p) || ((char *)p < stackp->space)) { 8271 if (!p || (stacknxt < (char *)p) || ((char *)p < stackp->space)) {
8271 write(2, "stunalloc\n", 10); 8272 write(2, "stunalloc\n", 10);
8272 abort(); 8273 abort();
@@ -8844,7 +8845,7 @@ setarg0:
8844void 8845void
8845optschanged(void) 8846optschanged(void)
8846{ 8847{
8847#ifdef DEBUG 8848#if DEBUG
8848 opentrace(); 8849 opentrace();
8849#endif 8850#endif
8850 setinteractive(iflag); 8851 setinteractive(iflag);
@@ -9913,7 +9914,7 @@ static int
9913readtoken(void) 9914readtoken(void)
9914{ 9915{
9915 int t; 9916 int t;
9916#ifdef DEBUG 9917#if DEBUG
9917 int alreadyseen = tokpushback; 9918 int alreadyseen = tokpushback;
9918#endif 9919#endif
9919 9920
@@ -9963,7 +9964,7 @@ top:
9963 } 9964 }
9964out: 9965out:
9965 checkkwd = 0; 9966 checkkwd = 0;
9966#ifdef DEBUG 9967#if DEBUG
9967 if (!alreadyseen) 9968 if (!alreadyseen)
9968 TRACE(("token %s %s\n", tokname(t), t == TWORD ? wordtext : "")); 9969 TRACE(("token %s %s\n", tokname(t), t == TWORD ? wordtext : ""));
9969 else 9970 else
@@ -11053,7 +11054,7 @@ openredirect(union node *redir)
11053 goto ecreate; 11054 goto ecreate;
11054 break; 11055 break;
11055 default: 11056 default:
11056#ifdef DEBUG 11057#if DEBUG
11057 abort(); 11058 abort();
11058#endif 11059#endif
11059 /* Fall through to eliminate warning. */ 11060 /* Fall through to eliminate warning. */
@@ -11255,7 +11256,7 @@ redirectsafe(union node *redir, int flags)
11255 11256
11256/* show.c */ 11257/* show.c */
11257 11258
11258#ifdef DEBUG 11259#if DEBUG
11259static void shtree(union node *, int, char *, FILE*); 11260static void shtree(union node *, int, char *, FILE*);
11260static void shcmd(union node *, FILE *); 11261static void shcmd(union node *, FILE *);
11261static void sharg(union node *, FILE *); 11262static void sharg(union node *, FILE *);
@@ -11714,7 +11715,7 @@ setsignal(int signo)
11714 action = S_CATCH; 11715 action = S_CATCH;
11715 break; 11716 break;
11716 case SIGQUIT: 11717 case SIGQUIT:
11717#ifdef DEBUG 11718#if DEBUG
11718 if (debug) 11719 if (debug)
11719 break; 11720 break;
11720#endif 11721#endif
@@ -13659,7 +13660,7 @@ static arith_t arith (const char *expr, int *perrcode)
13659#endif /* CONFIG_ASH_MATH_SUPPORT */ 13660#endif /* CONFIG_ASH_MATH_SUPPORT */
13660 13661
13661 13662
13662#ifdef DEBUG 13663#if DEBUG
13663const char *applet_name = "debug stuff usage"; 13664const char *applet_name = "debug stuff usage";
13664int main(int argc, char **argv) 13665int main(int argc, char **argv)
13665{ 13666{