X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fmadwifi.c;h=d3a58030681493f23fa23ef196fa26ca977f6992;hb=1b4d95b869063e619bd7aae54cf37c5a1b91fbee;hp=8b3266dc80c706cd9552beb2d9ef4009effa9ed6;hpb=8be9c73cc216609a54a1b997aad8a3d646a0a43f;p=collectd.git diff --git a/src/madwifi.c b/src/madwifi.c index 8b3266dc..d3a58030 100644 --- a/src/madwifi.c +++ b/src/madwifi.c @@ -368,14 +368,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 +420,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; @@ -561,20 +561,20 @@ static void submit (const char *dev, const char *type, const char *ti1, plugin_dispatch_values (&vl); } -static void submit_counter (const char *dev, const char *type, const char *ti1, - const char *ti2, counter_t val) +static void submit_derive (const char *dev, const char *type, const char *ti1, + const char *ti2, derive_t val) { value_t item; - item.counter = val; + item.derive = val; submit (dev, type, ti1, ti2, &item, 1); } -static void submit_counter2 (const char *dev, const char *type, const char *ti1, - const char *ti2, counter_t val1, counter_t val2) +static void submit_derive2 (const char *dev, const char *type, const char *ti1, + const char *ti2, derive_t val1, derive_t val2) { value_t items[2]; - items[0].counter = val1; - items[1].counter = val2; + items[0].derive = val1; + items[1].derive = val2; submit (dev, type, ti1, ti2, items, 2); } @@ -598,8 +598,8 @@ static void submit_antx (const char *dev, const char *name, continue; ssnprintf (ti2, sizeof (ti2), "%i", i); - submit_counter (dev, "ath_stat", name, ti2, - (counter_t) vals[i]); + submit_derive (dev, "ath_stat", name, ti2, + (derive_t) vals[i]); } } @@ -618,21 +618,21 @@ 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++) { uint32_t val = *(uint32_t *)(((char *) ptr) + specs[i].offset) ; if (item_watched (i) && (val != 0)) - submit_counter (dev, type_name, specs[i].name, mac, val); + submit_derive (dev, type_name, specs[i].name, mac, val); if (item_summed (i)) misc += val; } if (misc != 0) - submit_counter (dev, type_name, misc_name, mac, misc); + submit_derive (dev, type_name, misc_name, mac, misc); } @@ -734,13 +734,13 @@ process_station (int sk, const char *dev, struct ieee80211req_sta_info *si) /* These two stats are handled as a special case as they are a pair of 64bit values */ if (item_watched (STAT_NODE_OCTETS)) - submit_counter2 (dev, "node_octets", mac, NULL, + submit_derive2 (dev, "node_octets", mac, NULL, ns->ns_rx_bytes, ns->ns_tx_bytes); /* This stat is handled as a special case, because it is stored as uin64_t, but we will ignore upper half */ if (item_watched (STAT_NS_RX_BEACONS)) - submit_counter (dev, "node_stat", "ns_rx_beacons", mac, + submit_derive (dev, "node_stat", "ns_rx_beacons", mac, (ns->ns_rx_beacons & 0xFFFFFFFF)); /* All other node statistics */ @@ -754,7 +754,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));