X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fdisk.c;h=d7eb0a5c407011c9789ee2fe43e4d46f938e2414;hb=51181b899668ad2c232a152d6e5e787c4eb049cc;hp=255d4db6076d905210e7fd1628217c05bcaf6db1;hpb=d67b510b1ec7c17b6e1f65e40b8d8fdb2f33c857;p=collectd.git diff --git a/src/disk.c b/src/disk.c index 255d4db6..d7eb0a5c 100644 --- a/src/disk.c +++ b/src/disk.c @@ -22,6 +22,7 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" #include "utils_ignorelist.h" @@ -893,7 +894,13 @@ static int disk_read (void) #endif if (ignorelist_match (ignorelist, output_name) != 0) + { +#if HAVE_LIBUDEV + /* release udev-based alternate name, if allocated */ + sfree (alt_name); +#endif continue; + } if ((ds->read_bytes != 0) || (ds->write_bytes != 0)) disk_submit (output_name, "disk_octets", @@ -947,12 +954,11 @@ static int disk_read (void) # error "kstat_io_t does not have the required members" # endif static kstat_io_t kio; - int i; if (kc == NULL) return (-1); - for (i = 0; i < numdisk; i++) + for (int i = 0; i < numdisk; i++) { if (kstat_read (kc, ksp[i], &kio) == -1) continue; @@ -990,13 +996,12 @@ static int disk_read (void) # else int disks; #endif - int counter; char name[DATA_MAX_NAME_LEN]; if ((ds = sg_get_disk_io_stats(&disks)) == NULL) return (0); - for (counter=0; counter < disks; counter++) { + for (int counter = 0; counter < disks; counter++) { strncpy(name, ds->disk_name, sizeof(name)); name[sizeof(name)-1] = '\0'; /* strncpy doesn't terminate longer strings */ @@ -1019,7 +1024,6 @@ static int disk_read (void) derive_t write_ops; perfstat_id_t firstpath; int rnumdisk; - int i; if ((numdisk = perfstat_disk(NULL, NULL, sizeof(perfstat_disk_t), 0)) < 0) { @@ -1045,7 +1049,7 @@ static int disk_read (void) return (-1); } - for (i = 0; i < rnumdisk; i++) + for (int i = 0; i < rnumdisk; i++) { if (ignorelist_match (ignorelist, stat_disk[i].name) != 0) continue;