misc: tweaks (mostly cosmetic) to several source files
. a more appropriate error return code was substituted . a safer form of comparison is utilized in two places . a STAT_VAL macro replaced by more proper MEMINFO_VAL . several of the silly 'xerrx' formats had been missed . a few whitespace changes have also been incorporated Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
parent
612f36189e
commit
5c857b865e
@ -303,6 +303,7 @@ static struct dev_node *node_add (
|
|||||||
return this;
|
return this;
|
||||||
} // end: node_add
|
} // end: node_add
|
||||||
|
|
||||||
|
|
||||||
static void node_classify (
|
static void node_classify (
|
||||||
struct dev_node *this)
|
struct dev_node *this)
|
||||||
{
|
{
|
||||||
@ -319,7 +320,7 @@ static void node_classify (
|
|||||||
this->type = DISKSTATS_TYPE_DISK;
|
this->type = DISKSTATS_TYPE_DISK;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while((dent = readdir(dirp))) {
|
while ((dent = readdir(dirp))) {
|
||||||
if (strcmp(this->name, dent->d_name) == 0) {
|
if (strcmp(this->name, dent->d_name) == 0) {
|
||||||
this->type = DISKSTATS_TYPE_DISK;
|
this->type = DISKSTATS_TYPE_DISK;
|
||||||
break;
|
break;
|
||||||
@ -578,7 +579,7 @@ static int read_diskstats_failed (
|
|||||||
if (rc != 14) {
|
if (rc != 14) {
|
||||||
if (errno != 0)
|
if (errno != 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
return -EINVAL;
|
return -EIO;
|
||||||
}
|
}
|
||||||
node.stamped = info->new_stamp;
|
node.stamped = info->new_stamp;
|
||||||
if ((rc = node_update(info, &node)))
|
if ((rc = node_update(info, &node)))
|
||||||
@ -608,15 +609,15 @@ static struct stacks_extent *stacks_alloc (
|
|||||||
vect_size = sizeof(void *) * maxstacks; // size of the addr vectors |
|
vect_size = sizeof(void *) * maxstacks; // size of the addr vectors |
|
||||||
vect_size += sizeof(void *); // plus NULL addr delimiter |
|
vect_size += sizeof(void *); // plus NULL addr delimiter |
|
||||||
head_size = sizeof(struct diskstats_stack); // size of that head struct |
|
head_size = sizeof(struct diskstats_stack); // size of that head struct |
|
||||||
list_size = sizeof(struct diskstats_result) * this->numitems;// any single results stack |
|
list_size = sizeof(struct diskstats_result) * this->numitems; // any single results stack |
|
||||||
blob_size = sizeof(struct stacks_extent); // the extent anchor itself |
|
blob_size = sizeof(struct stacks_extent); // the extent anchor itself |
|
||||||
blob_size += vect_size; // plus room for addr vects |
|
blob_size += vect_size; // plus room for addr vects |
|
||||||
blob_size += head_size * maxstacks; // plus room for head thing |
|
blob_size += head_size * maxstacks; // plus room for head thing |
|
||||||
blob_size += list_size * maxstacks; // plus room for our stacks |
|
blob_size += list_size * maxstacks; // plus room for our stacks |
|
||||||
|
|
||||||
/* note: all of our memory is allocated in a single blob, facilitating some later free(). |
|
/* note: all of our memory is allocated in one single blob, facilitating some later free(). |
|
||||||
as a minimum, it is important that all those result structs themselves always be |
|
as a minimum, it's important that all of those result structs themselves always be |
|
||||||
contiguous within every stack since they will be accessed via relative position. | */
|
contiguous within every stack since they will be accessed via a relative position. | */
|
||||||
if (NULL == (p_blob = calloc(1, blob_size)))
|
if (NULL == (p_blob = calloc(1, blob_size)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -963,7 +964,7 @@ PROCPS_EXPORT struct diskstats_stack **procps_diskstats_sort (
|
|||||||
if (p->item == sortitem)
|
if (p->item == sortitem)
|
||||||
break;
|
break;
|
||||||
++offset;
|
++offset;
|
||||||
if (p->item == DISKSTATS_logical_end)
|
if (p->item >= DISKSTATS_logical_end)
|
||||||
return NULL;
|
return NULL;
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
@ -994,7 +994,7 @@ PROCPS_EXPORT struct slabinfo_stack **procps_slabinfo_sort (
|
|||||||
if (p->item == sortitem)
|
if (p->item == sortitem)
|
||||||
break;
|
break;
|
||||||
++offset;
|
++offset;
|
||||||
if (p->item == SLABINFO_logical_end)
|
if (p->item >= SLABINFO_logical_end)
|
||||||
return NULL;
|
return NULL;
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
|
19
vmstat.c
19
vmstat.c
@ -326,7 +326,7 @@ static void new_format(void)
|
|||||||
#define TICv(E) STAT_VAL(E, ull_int, stat_stack)
|
#define TICv(E) STAT_VAL(E, ull_int, stat_stack)
|
||||||
#define DTICv(E) STAT_VAL(E, sl_int, stat_stack)
|
#define DTICv(E) STAT_VAL(E, sl_int, stat_stack)
|
||||||
#define SYSv(E) STAT_VAL(E, ul_int, stat_stack)
|
#define SYSv(E) STAT_VAL(E, ul_int, stat_stack)
|
||||||
#define MEMv(E) STAT_VAL(E, ul_int, mem_stack)
|
#define MEMv(E) MEMINFO_VAL(E, ul_int, mem_stack)
|
||||||
#define DSYSv(E) STAT_VAL(E, s_int, stat_stack)
|
#define DSYSv(E) STAT_VAL(E, s_int, stat_stack)
|
||||||
const char format[] =
|
const char format[] =
|
||||||
"%2lu %2lu %6lu %6lu %6lu %6lu %4u %4u %5u %5u %4u %4u %2u %2u %2u %2u %2u";
|
"%2lu %2lu %6lu %6lu %6lu %6lu %4u %4u %5u %5u %4u %4u %2u %2u %2u %2u %2u";
|
||||||
@ -536,8 +536,7 @@ static void diskpartition_format(const char *partition_name)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (procps_diskstats_new(&disk_stat) < 0)
|
if (procps_diskstats_new(&disk_stat) < 0)
|
||||||
xerr(EXIT_FAILURE,
|
xerrx(EXIT_FAILURE, _("Unable to create diskstat structure"));
|
||||||
_("Unable to create diskstat structure"));
|
|
||||||
|
|
||||||
if (!(got = procps_diskstats_get(disk_stat, partition_name, DISKSTATS_TYPE)))
|
if (!(got = procps_diskstats_get(disk_stat, partition_name, DISKSTATS_TYPE)))
|
||||||
xerrx(EXIT_FAILURE, _("Disk/Partition %s not found"), partition_name);
|
xerrx(EXIT_FAILURE, _("Disk/Partition %s not found"), partition_name);
|
||||||
@ -637,16 +636,14 @@ static void diskformat(void)
|
|||||||
const char wide_format[] = "%-5s %9lu %9lu %11lu %11lu %9lu %9lu %11lu %11lu %7lu %7lu";
|
const char wide_format[] = "%-5s %9lu %9lu %11lu %11lu %9lu %9lu %11lu %11lu %7lu %7lu";
|
||||||
|
|
||||||
if (procps_diskstats_new(&disk_stat) < 0)
|
if (procps_diskstats_new(&disk_stat) < 0)
|
||||||
xerr(EXIT_FAILURE,
|
xerrx(EXIT_FAILURE, _("Unable to create diskstat structure"));
|
||||||
_("Unable to create diskstat structure"));
|
|
||||||
|
|
||||||
if (!moreheaders)
|
if (!moreheaders)
|
||||||
diskheader();
|
diskheader();
|
||||||
|
|
||||||
for (i=0; infinite_updates || i < num_updates ; i++) {
|
for (i=0; infinite_updates || i < num_updates ; i++) {
|
||||||
if (!(reap = procps_diskstats_reap(disk_stat, Disk_items, MAX_disk)))
|
if (!(reap = procps_diskstats_reap(disk_stat, Disk_items, MAX_disk)))
|
||||||
xerr(EXIT_FAILURE,
|
xerrx(EXIT_FAILURE, _("Unable to retrieve disk statistics"));
|
||||||
_("Unable to retrieve disk statistics"));
|
|
||||||
if (t_option) {
|
if (t_option) {
|
||||||
(void) time( &the_time );
|
(void) time( &the_time );
|
||||||
tm_ptr = localtime( &the_time );
|
tm_ptr = localtime( &the_time );
|
||||||
@ -714,7 +711,7 @@ static void slabformat (void)
|
|||||||
slab_AOBJS, slab_OBJS, slab_OSIZE, slab_OPS, slab_NAME };
|
slab_AOBJS, slab_OBJS, slab_OSIZE, slab_OPS, slab_NAME };
|
||||||
|
|
||||||
if (procps_slabinfo_new(&slab_info) < 0)
|
if (procps_slabinfo_new(&slab_info) < 0)
|
||||||
xerr(EXIT_FAILURE, _("Unable to create slabinfo structure"));
|
xerrx(EXIT_FAILURE, _("Unable to create slabinfo structure"));
|
||||||
|
|
||||||
if (!moreheaders)
|
if (!moreheaders)
|
||||||
slabheader();
|
slabheader();
|
||||||
@ -759,11 +756,9 @@ static void disksum_format(void)
|
|||||||
disk_count = part_count = 0;
|
disk_count = part_count = 0;
|
||||||
|
|
||||||
if (procps_diskstats_new(&disk_stat) < 0)
|
if (procps_diskstats_new(&disk_stat) < 0)
|
||||||
xerr(EXIT_FAILURE,
|
xerrx(EXIT_FAILURE, _("Unable to create diskstat structure"));
|
||||||
_("Unable to create diskstat structure"));
|
|
||||||
if (!(reap = procps_diskstats_reap(disk_stat, Disk_items, MAX_disk)))
|
if (!(reap = procps_diskstats_reap(disk_stat, Disk_items, MAX_disk)))
|
||||||
xerr(EXIT_FAILURE,
|
xerrx(EXIT_FAILURE, _("Unable to retrieve disk statistics"));
|
||||||
_("Unable to retrieve disk statistics"));
|
|
||||||
|
|
||||||
for (j = 0; j < reap->total; j++) {
|
for (j = 0; j < reap->total; j++) {
|
||||||
if (diskVAL(disk_TYPE, s_int) != DISKSTATS_TYPE_DISK) {
|
if (diskVAL(disk_TYPE, s_int) != DISKSTATS_TYPE_DISK) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user