]> granicus.if.org Git - curl/commitdiff
netrc: Tightened up the type checks.
authorJulien Chaffraix <julien.chaffraix@gmail.com>
Fri, 28 Jan 2011 16:20:37 +0000 (08:20 -0800)
committerJulien Chaffraix <julien.chaffraix@gmail.com>
Tue, 8 Feb 2011 04:15:35 +0000 (20:15 -0800)
The state should not be anonymous so that we can check if the values
are fine. Added 2 unreachables states to the switch as a result of this
change.

lib/netrc.c

index e9443253e9c2087a3aeadb67f6993ac2d35af131..1934d6a6980d3a4b62f1429837e385c15654d4ca 100644 (file)
@@ -58,7 +58,7 @@
 
 /* Get user and password from .netrc when given a machine name */
 
-enum {
+enum host_lookup_state {
   NOTHING,
   HOSTFOUND,    /* the 'machine' keyword was found */
   HOSTCOMPLETE, /* the machine name following the keyword was found too */
@@ -83,7 +83,7 @@ int Curl_parsenetrc(const char *host,
   char *home = NULL;
   bool home_alloc = FALSE;
   bool netrc_alloc = FALSE;
-  int state=NOTHING;
+  enum host_lookup_state state=NOTHING;
 
   char state_login=0;      /* Found a login keyword */
   char state_password=0;   /* Found a password keyword */
@@ -210,6 +210,10 @@ int Curl_parsenetrc(const char *host,
             state_our_login = FALSE;
           }
           break;
+        case HOSTCOMPLETE:
+        case HOSTEND:
+            /* Should not be reached. */
+            DEBUGASSERT(0);
         } /* switch (state) */
 
         tok = strtok_r(NULL, " \t\n", &tok_buf);