Fix the command-line parser, compile with -Wall
authorhpa <hpa>
Thu, 13 Dec 2001 05:27:15 +0000 (05:27 +0000)
committerhpa <hpa>
Thu, 13 Dec 2001 05:27:15 +0000 (05:27 +0000)
memdisk/Makefile
memdisk/e820func.c
memdisk/setup.c

index b3abf5a..70d6f69 100644 (file)
@@ -12,7 +12,7 @@
 ## -----------------------------------------------------------------------
 
 CC      = gcc
-CFLAGS  = -O2 -fomit-frame-pointer -march=i386 \
+CFLAGS  = -Wall -O2 -fomit-frame-pointer -march=i386 \
          -malign-functions=0 -malign-jumps=0 -malign-loops=0
 LDFLAGS = 
 AS      = as
@@ -31,7 +31,7 @@ tidy:
        rm -f *.o *.s *.o16 *.s16 *.bin *.lst *.elf e820test
 
 # clean also removes the product binary
-clean:
+clean: tidy
        rm -f memdisk
 
 %.o16: %.s16
index 4d0ec15..3087d33 100644 (file)
@@ -52,7 +52,7 @@ static void insertrange_at(int where, uint64_t start, uint32_t type)
 
 void insertrange(uint64_t start, uint64_t len, uint32_t type)
 {
-  uint64_t newstart, last;
+  uint64_t last;
   uint32_t oldtype;
   int i, j;
 
index 0fa9dbf..8543298 100644 (file)
@@ -188,35 +188,33 @@ rdz_32(uint32_t addr)
  * Routine to seek for a command-line item and return a pointer
  * to the data portion, if present
  */
-static inline int
-isspace(int ch)
-{
-  return (ch == ' ') || ((ch >= '\b') && (ch <= '\r'));
-}
 
 /* Magic return values */
 #define CMD_NOTFOUND   ((char *)-1) /* Not found */
 #define CMD_BOOL       ((char *)-2) /* Found boolean option */
 #define CMD_HASDATA(X) ((int)(X) >= 0)
+
 const char *getcmditem(const char *what)
 {
-  const char *p, *wp;
+  const char *p;
+  const char *wp = what;
   int match = 0;
 
   for ( p = shdr->cmdline ; *p ; p++ ) {
     switch ( match ) {
     case 0:                    /* Ground state */
-      if ( isspace(*p) )
+      if ( *p == ' ' )
        break;
 
       wp = what;
+      match = 1;
       /* Fall through */
 
     case 1:                    /* Matching */
       if ( *wp == '\0' ) {
        if ( *p == '=' )
          return p+1;
-       else if ( isspace(*p) )
+       else if ( *p == ' ' )
          return CMD_BOOL;
        else {
          match = 2;
@@ -224,12 +222,13 @@ const char *getcmditem(const char *what)
        }
       }
       if ( *p != *wp++ )
-       match = 2;              /* Skipping bogus */
+       match = 2;
       break;
 
-    case 2:
-      if ( isspace(*p) )
+    case 2:                    /* Mismatch, skip rest of option */
+      if ( *p == ' ' )
        match = 0;              /* Next option */
+      break;
     }
   }