X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmadwifi.c;h=d0b2f83ea1afa0e429f3fe2646ddbfa2739b7d5d;hb=866d6234d69c86f538536b4a375a9ef3efcd2969;hp=13301fffe15aea8afbce76c3ce06105ededfa195;hpb=7947c0d3d8e4cae18dc55108465eb6fa3b88b5f0;p=collectd.git diff --git a/src/madwifi.c b/src/madwifi.c index 13301fff..d0b2f83e 100644 --- a/src/madwifi.c +++ b/src/madwifi.c @@ -96,7 +96,6 @@ #include #include -#include #if !KERNEL_LINUX # error "No applicable input method." @@ -368,14 +367,14 @@ static int init_state = 0; static inline int item_watched(int i) { assert (i >= 0); - assert (i < ((STATIC_ARRAY_SIZE (watch_items) + 1) * 32)); + assert (((size_t) i) < ((STATIC_ARRAY_SIZE (watch_items) + 1) * 32)); return watch_items[i / 32] & FLAG (i); } static inline int item_summed(int i) { assert (i >= 0); - assert (i < ((STATIC_ARRAY_SIZE (misc_items) + 1) * 32)); + assert (((size_t) i) < ((STATIC_ARRAY_SIZE (misc_items) + 1) * 32)); return misc_items[i / 32] & FLAG (i); } @@ -420,8 +419,8 @@ static int watchitem_find (const char *name) static int madwifi_real_init (void) { - int max = STATIC_ARRAY_SIZE (specs); - int i; + size_t max = STATIC_ARRAY_SIZE (specs); + size_t i; for (i = 0; i < STATIC_ARRAY_SIZE (bounds); i++) bounds[i] = 0; @@ -618,7 +617,7 @@ process_stat_struct (int which, const void *ptr, const char *dev, const char *ma int i; assert (which >= 1); - assert (which < STATIC_ARRAY_SIZE (bounds)); + assert (((size_t) which) < STATIC_ARRAY_SIZE (bounds)); for (i = bounds[which - 1]; i < bounds[which]; i++) { @@ -754,7 +753,8 @@ process_stations (int sk, const char *dev) uint8_t buf[24*1024]; struct iwreq iwr; uint8_t *cp; - int len, nodes; + int nodes; + size_t len; int status; memset (&iwr, 0, sizeof (iwr)); @@ -821,15 +821,16 @@ check_devname (const char *dev) if (dev[0] == '.') return 0; - + ssnprintf (buf, sizeof (buf), "/sys/class/net/%s/device/driver", dev); - buf[sizeof (buf) - 1] = 0; + buf[sizeof (buf) - 1] = '\0'; - memset (buf2, 0, sizeof (buf2)); i = readlink (buf, buf2, sizeof (buf2) - 1); if (i < 0) return 0; + buf2[i] = '\0'; + if (strstr (buf2, "/drivers/ath_") == NULL) return 0; return 1;