udhcpc: reuse string constant; remove unneeded memset(0)
[oweals/busybox.git] / networking / libiproute / ll_types.c
index 50c9f208f1737aaeb953c0a1e170b49e52419445..bb42e269e51b06153c66d8cb72c98f395eee3b73 100644 (file)
@@ -1,26 +1,28 @@
 /* vi: set sw=4 ts=4: */
 /*
- * ll_types.c
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
  *
- *             This program is free software; you can redistribute it and/or
- *             modify it under the terms of the GNU General Public License
- *             as published by the Free Software Foundation; either version
- *             2 of the License, or (at your option) any later version.
- *
- * Authors:    Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
+ * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
  */
+#include <sys/socket.h> /* linux/if_arp.h needs it on some systems */
 #include <arpa/inet.h>
 #include <linux/if_arp.h>
 
 #include "libbb.h"
 #include "rt_names.h"
 
-const char *ll_type_n2a(int type, char *buf, int len)
+const char* FAST_FUNC ll_type_n2a(int type, char *buf)
 {
        static const char arphrd_name[] =
        /* 0,                  */ "generic" "\0"
        /* ARPHRD_LOOPBACK,    */ "loopback" "\0"
        /* ARPHRD_ETHER,       */ "ether" "\0"
+#ifdef ARPHRD_INFINIBAND
+       /* ARPHRD_INFINIBAND,  */ "infiniband" "\0"
+#endif
 #ifdef ARPHRD_IEEE802_TR
        /* ARPHRD_IEEE802,     */ "ieee802" "\0"
        /* ARPHRD_IEEE802_TR,  */ "tr" "\0"
@@ -107,6 +109,9 @@ const char *ll_type_n2a(int type, char *buf, int len)
        0,                  /* "generic" "\0" */
        ARPHRD_LOOPBACK,    /* "loopback" "\0" */
        ARPHRD_ETHER,       /* "ether" "\0" */
+#ifdef ARPHRD_INFINIBAND
+       ARPHRD_INFINIBAND,  /* "infiniband" "\0" */
+#endif
 #ifdef ARPHRD_IEEE802_TR
        ARPHRD_IEEE802,     /* "ieee802" "\0" */
        ARPHRD_IEEE802_TR,  /* "tr" "\0" */
@@ -194,6 +199,6 @@ const char *ll_type_n2a(int type, char *buf, int len)
                        return aname;
                aname += strlen(aname) + 1;
        }
-       snprintf(buf, len, "[%d]", type);
+       sprintf(buf, "[%d]", type);
        return buf;
 }