Whamcloud - gitweb
LU-5577 obdclass: change loop indexes to unsigned
[fs/lustre-release.git] / libcfs / libcfs / nidstrings.c
index 8235f0e..10e8f8d 100644 (file)
 #define DEBUG_SUBSYSTEM S_LNET
 
 #include <libcfs/libcfs.h>
-#include <lnet/lnet.h>
+#include <lnet/nidstr.h>
 #ifndef __KERNEL__
 #ifdef HAVE_GETHOSTBYNAME
 # include <netdb.h>
 #endif
 #endif
 
+/* max value for numeric network address */
+#define MAX_NUMERIC_VALUE 0xffffffff
+
 #define IPSTRING_LENGTH 16
 
 /* CAVEAT VENDITOR! Keep the canonical string representation of nets/nids
@@ -313,11 +316,11 @@ libcfs_ip_addr2str(__u32 addr, char *str)
 int
 libcfs_ip_str2addr(const char *str, int nob, __u32 *addr)
 {
-        int   a;
-        int   b;
-        int   c;
-        int   d;
-        int   n = nob;                          /* XscanfX */
+       unsigned int    a;
+       unsigned int    b;
+       unsigned int    c;
+       unsigned int    d;
+       int             n = nob; /* XscanfX */
 
         /* numeric IP? */
         if (sscanf(str, "%u.%u.%u.%u%n", &a, &b, &c, &d, &n) >= 4 &&
@@ -524,9 +527,9 @@ static struct netstrfns *
 libcfs_str2net_internal(const char *str, __u32 *net)
 {
        struct netstrfns *nf = NULL;
-        int               nob;
-        int               netnum;
-        int               i;
+       int               nob;
+       unsigned int      netnum;
+       int               i;
 
         for (i = 0; i < libcfs_nnetstrfns; i++) {
                 nf = &libcfs_netstrfns[i];
@@ -894,7 +897,6 @@ cfs_parse_nidlist(char *str, int len, struct list_head *nidlist)
        struct cfs_lstr src;
        struct cfs_lstr res;
        int rc;
-       ENTRY;
 
        src.ls_str = str;
        src.ls_len = len;
@@ -903,15 +905,15 @@ cfs_parse_nidlist(char *str, int len, struct list_head *nidlist)
                rc = cfs_gettok(&src, ' ', &res);
                if (rc == 0) {
                        cfs_free_nidlist(nidlist);
-                       RETURN(0);
+                       return 0;
                }
                rc = parse_nidrange(&res, nidlist);
                if (rc == 0) {
                        cfs_free_nidlist(nidlist);
-                       RETURN(0);
+                       return 0;
                }
        }
-       RETURN(1);
+       return 1;
 }
 
 /*
@@ -943,7 +945,6 @@ int cfs_match_nid(lnet_nid_t nid, struct list_head *nidlist)
 {
        struct nidrange *nr;
        struct addrrange *ar;
-       ENTRY;
 
        list_for_each_entry(nr, nidlist, nr_link) {
                if (nr->nr_netstrfns->nf_type != LNET_NETTYP(LNET_NIDNET(nid)))
@@ -951,13 +952,13 @@ int cfs_match_nid(lnet_nid_t nid, struct list_head *nidlist)
                if (nr->nr_netnum != LNET_NETNUM(LNET_NIDNET(nid)))
                        continue;
                if (nr->nr_all)
-                       RETURN(1);
+                       return 1;
                list_for_each_entry(ar, &nr->nr_addrranges, ar_link)
                        if (nr->nr_netstrfns->nf_match_addr(LNET_NIDADDR(nid),
                                                        &ar->ar_numaddr_ranges))
-                               RETURN(1);
+                               return 1;
        }
-       RETURN(0);
+       return 0;
 }
 
 static int
@@ -1043,10 +1044,9 @@ int cfs_print_nidlist(char *buffer, int count, struct list_head *nidlist)
 {
        int i = 0;
        struct nidrange *nr;
-       ENTRY;
 
        if (count <= 0)
-               RETURN(0);
+               return 0;
 
        list_for_each_entry(nr, nidlist, nr_link) {
                if (i != 0)
@@ -1061,7 +1061,7 @@ int cfs_print_nidlist(char *buffer, int count, struct list_head *nidlist)
                                                  &nr->nr_addrranges, nr);
                }
        }
-       RETURN(i);
+       return i;
 }
 
 /**