ntpd: remove some code which is at best unneeded and at worst wrong
[oweals/busybox.git] / networking / interface.c
index ef187be1a24c37523fc83d3c0a26e5545a3b04d4..b64d24a58b73d68e64d6011ab6e55e9699d5ce96 100644 (file)
@@ -410,20 +410,20 @@ static struct interface *add_interface(char *name)
 static char *get_name(char *name, char *p)
 {
        /* Extract <name> from nul-terminated p where p matches
-          <name>: after leading whitespace.
-          If match is not made, set name empty and return unchanged p */
-       int namestart = 0, nameend = 0;
+        * <name>: after leading whitespace.
+        * If match is not made, set name empty and return unchanged p
+        */
+       char *nameend;
+       char *namestart = skip_whitespace(p);
 
-       while (isspace(p[namestart]))
-               namestart++;
        nameend = namestart;
-       while (p[nameend] && p[nameend] != ':' && !isspace(p[nameend]))
+       while (*nameend && *nameend != ':' && !isspace(*nameend))
                nameend++;
-       if (p[nameend] == ':') {
+       if (*nameend == ':') {
                if ((nameend - namestart) < IFNAMSIZ) {
-                       memcpy(name, &p[namestart], nameend - namestart);
+                       memcpy(name, namestart, nameend - namestart);
                        name[nameend - namestart] = '\0';
-                       p = &p[nameend];
+                       p = nameend;
                } else {
                        /* Interface name too large */
                        name[0] = '\0';
@@ -1242,10 +1242,8 @@ int FAST_FUNC in_ib(const char *bufp, struct sockaddr *sap)
                c = *bufp++;
                if (isdigit(c))
                        val = c - '0';
-               else if (c >= 'a' && c <= 'f')
-                       val = c - 'a' + 10;
-               else if (c >= 'A' && c <= 'F')
-                       val = c - 'A' + 10;
+               else if ((c|0x20) >= 'a' && (c|0x20) <= 'f')
+                       val = (c|0x20) - ('a' - 10);
                else {
                        errno = EINVAL;
                        return -1;
@@ -1254,17 +1252,15 @@ int FAST_FUNC in_ib(const char *bufp, struct sockaddr *sap)
                c = *bufp;
                if (isdigit(c))
                        val |= c - '0';
-               else if (c >= 'a' && c <= 'f')
-                       val |= c - 'a' + 10;
-               else if (c >= 'A' && c <= 'F')
-                       val |= c - 'A' + 10;
-               else if (c == ':' || c == 0)
+               else if ((c|0x20) >= 'a' && (c|0x20) <= 'f')
+                       val |= (c|0x20) - ('a' - 10);
+               else if (c == ':' || c == '\0')
                        val >>= 4;
                else {
                        errno = EINVAL;
                        return -1;
                }
-               if (c != 0)
+               if (c != '\0')
                        bufp++;
                *ptr++ = (unsigned char) (val & 0377);
                i++;