udhcp,ipcalc: simple code shrink (Nico Erfurth <masta AT perlgolf.de>)
authorDenis Vlasenko <vda.linux@googlemail.com>
Thu, 10 Apr 2008 02:09:40 +0000 (02:09 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Thu, 10 Apr 2008 02:09:40 +0000 (02:09 -0000)
function                                             old     new   delta
ipcalc_main                                          609     610      +1
read_staticlease                                     102      85     -17
ether_aton                                            17       -     -17

networking/ipcalc.c
networking/udhcp/files.c

index 9e92b643e81e9c616b9be41f66ca007bd8cfe73f..8578893af6d14728f4c68ab7412f3c7abf9ecb28 100644 (file)
@@ -175,16 +175,13 @@ int ipcalc_main(int argc, char **argv)
 
                if (opt & HOSTNAME) {
                        struct hostent *hostinfo;
-                       int x;
 
                        hostinfo = gethostbyaddr((char *) &ipaddr, sizeof(ipaddr), AF_INET);
                        if (!hostinfo) {
                                bb_herror_msg_and_die("cannot find hostname for %s", argv[0]);
                        }
-                       for (x = 0; hostinfo->h_name[x]; x++) {
-                               hostinfo->h_name[x] = tolower(hostinfo->h_name[x]);
-                       }
-
+                       str_tolower(hostinfo->h_name);
+                       
                        printf("HOSTNAME=%s\n", hostinfo->h_name);
                }
        }
index 043a95bb07c47dfbf279b440f54905a65bf1717b..e0e8b12c397466ac9d12976a1b2d66bfc0c093fe 100644 (file)
@@ -26,13 +26,11 @@ static int read_ip(const char *line, void *arg)
 
 static int read_mac(const char *line, void *arg)
 {
-       uint8_t *mac_bytes = arg;
        struct ether_addr *temp_ether_addr;
 
-       temp_ether_addr = ether_aton(line);
+       temp_ether_addr = ether_aton_r(line, (struct ether_addr *)arg);
        if (temp_ether_addr == NULL)
                return 0;
-       memcpy(mac_bytes, temp_ether_addr, 6);
        return 1;
 }