]> arthur.barton.de Git - netatalk.git/blobdiff - libatalk/util/getiface.c
Merge master
[netatalk.git] / libatalk / util / getiface.c
index 867e6d6298eebf678b35ab669e2e69c04f2de581..bf79fff7f49e62f63983583aeb0b2b7cb4934d0c 100644 (file)
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
-#ifdef HAVE_STDINT_H
 #include <stdint.h>
-#endif
-
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/ioctl.h>
@@ -38,7 +34,7 @@
 #define IFACE_NUM 5
 
 /* we leave all of the ioctl's to the application */
-static int addname(char **list, int *i, int *length, const char *name) 
+static int addname(char **list, int *i, const char *name) 
 
 {
     /* if we've run out of room, allocate some more. just return
@@ -53,7 +49,7 @@ static int addname(char **list, int *i, int *length, const char *name)
 }
 
 
-static int getifaces(const int sockfd, char ***list, int *length)
+static int getifaces(const int sockfd, char ***list)
 {
 #ifdef HAVE_IFNAMEINDEX
       struct if_nameindex *ifstart, *ifs;
@@ -65,7 +61,7 @@ static int getifaces(const int sockfd, char ***list, int *length)
          new = (char **) malloc((sizeof(ifs)/sizeof(struct if_nameindex) + 1) * sizeof(char *));
       while (ifs && ifs->if_name) {
        /* just bail if there's a problem */
-       if (addname(new, &i, length, ifs->if_name) < 0)
+       if (addname(new, &i, ifs->if_name) < 0)
          break;
        ifs++;
       }
@@ -92,7 +88,7 @@ static int getifaces(const int sockfd, char ***list, int *length)
     }
 
        new = (char **) malloc((ifc.ifc_len/sizeof(struct ifreq) + 1) * sizeof(char *));
-    for ( ifr = ifc.ifc_req; ifc.ifc_len >= sizeof( struct ifreq );
+    for ( ifr = ifc.ifc_req; ifc.ifc_len >= (int) sizeof( struct ifreq );
            ifc.ifc_len -= ifrsize, ifr = nextifr ) {
 #ifdef BSD4_4
        ifrsize = sizeof(ifr->ifr_name) +
@@ -104,7 +100,7 @@ static int getifaces(const int sockfd, char ***list, int *length)
        nextifr = (struct ifreq *)((caddr_t)ifr + ifrsize );
 
        /* just bail if there's a problem */
-       if (addname(new, &i, length, ifr->ifr_name) < 0)
+       if (addname(new, &i, ifr->ifr_name) < 0)
          break;
     }
        *list = new;
@@ -117,15 +113,15 @@ static int getifaces(const int sockfd, char ***list, int *length)
  * Get interfaces from the kernel. we keep an extra null entry to signify
  * the end of the interface list. 
  */
-char **getifacelist()
+char **getifacelist(void)
 {
-  char **list;
-  int  length, i, fd;
+  char **list = NULL; /* FIXME */
+  int  i, fd;
 
   if ((fd = socket(PF_INET, SOCK_STREAM, 0)) < 0)
     return NULL;
 
-  if ((i = getifaces(fd, &list, &length)) == 0) {
+  if ((i = getifaces(fd, &list)) == 0) {
     free(list);
     close(fd);
     return NULL;