vmstat(1): various nits
Continue my parade on introspection tools by fixing: - failed to check for null after reallocf - avoid the comma operator - mark usage as dead - correct size of len
This commit is contained in:
parent
372639f944
commit
baab2cf821
@ -7,8 +7,6 @@ PROG= vmstat
|
||||
MAN= vmstat.8
|
||||
LIBADD= devstat kvm memstat xo util
|
||||
|
||||
WARNS?= 6
|
||||
|
||||
HAS_TESTS=
|
||||
SUBDIR.${MK_TESTS}+= tests
|
||||
|
||||
|
@ -218,7 +218,8 @@ main(int argc, char *argv[])
|
||||
{
|
||||
char *bp, *buf, *memf, *nlistf;
|
||||
float f;
|
||||
int bufsize, c, len, reps, todo;
|
||||
int bufsize, c, reps, todo;
|
||||
size_t len;
|
||||
unsigned int interval;
|
||||
char errbuf[_POSIX2_LINE_MAX];
|
||||
|
||||
@ -318,7 +319,8 @@ main(int argc, char *argv[])
|
||||
retry_nlist:
|
||||
if (kd != NULL && (c = kvm_nlist(kd, namelist)) != 0) {
|
||||
if (c > 0) {
|
||||
bufsize = 0, len = 0;
|
||||
bufsize = 0;
|
||||
len = 0;
|
||||
|
||||
/*
|
||||
* 'cnt' was renamed to 'vm_cnt'. If 'vm_cnt' is not
|
||||
@ -436,8 +438,11 @@ getdrivedata(char **argv)
|
||||
if (isdigit(**argv))
|
||||
break;
|
||||
num_devices_specified++;
|
||||
specified_devices = realloc(specified_devices,
|
||||
specified_devices = reallocf(specified_devices,
|
||||
sizeof(char *) * num_devices_specified);
|
||||
if (specified_devices == NULL) {
|
||||
xo_errx(1, "%s", "reallocf (specified_devices)");
|
||||
}
|
||||
specified_devices[num_devices_specified - 1] = *argv;
|
||||
}
|
||||
dev_select = NULL;
|
||||
@ -1206,7 +1211,7 @@ cpustats(void)
|
||||
total = 0;
|
||||
for (state = 0; state < CPUSTATES; ++state)
|
||||
total += cur.cp_time[state];
|
||||
if (total)
|
||||
if (total > 0)
|
||||
lpct = 100.0 / total;
|
||||
else
|
||||
lpct = 0.0;
|
||||
@ -1682,7 +1687,7 @@ kread(int nlx, void *addr, size_t size)
|
||||
kreado(nlx, addr, size, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
static void __dead2
|
||||
usage(void)
|
||||
{
|
||||
xo_error("%s%s",
|
||||
|
Loading…
Reference in New Issue
Block a user