Fix compiler warnings in iostat
Raise WARNS from 1 to 6 (the default) Fix warnings: * Use C99 designated initializers for structs, and initialize all fields * Mark global variables as static * Mark unused function arguments * Be careful about signed/unsigned comparisons Reviewed by: eadler MFC after: 4 weeks Sponsored by: Spectra Logic Corp Differential Revision: https://reviews.freebsd.org/D5328
This commit is contained in:
parent
c2a9e596ed
commit
a59c2129f3
@ -6,6 +6,4 @@ MAN= iostat.8
|
||||
|
||||
LIBADD= devstat kvm m
|
||||
|
||||
WARNS?= 1
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -117,30 +117,34 @@
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct nlist namelist[] = {
|
||||
static struct nlist namelist[] = {
|
||||
#define X_TTY_NIN 0
|
||||
{ "_tty_nin" },
|
||||
{ .n_name = "_tty_nin",
|
||||
.n_type = 0, .n_other = 0, .n_desc = 0, .n_value = 0 },
|
||||
#define X_TTY_NOUT 1
|
||||
{ "_tty_nout" },
|
||||
{ .n_name = "_tty_nout",
|
||||
.n_type = 0, .n_other = 0, .n_desc = 0, .n_value = 0 },
|
||||
#define X_BOOTTIME 2
|
||||
{ "_boottime" },
|
||||
{ .n_name = "_boottime",
|
||||
.n_type = 0, .n_other = 0, .n_desc = 0, .n_value = 0 },
|
||||
#define X_END 2
|
||||
{ NULL },
|
||||
{ .n_name = NULL,
|
||||
.n_type = 0, .n_other = 0, .n_desc = 0, .n_value = 0 },
|
||||
};
|
||||
|
||||
#define IOSTAT_DEFAULT_ROWS 20 /* Traditional default `wrows' */
|
||||
|
||||
struct statinfo cur, last;
|
||||
int num_devices;
|
||||
struct device_selection *dev_select;
|
||||
int maxshowdevs;
|
||||
volatile sig_atomic_t headercount;
|
||||
volatile sig_atomic_t wresized; /* Tty resized, when non-zero. */
|
||||
volatile sig_atomic_t alarm_rang;
|
||||
volatile sig_atomic_t return_requested;
|
||||
unsigned short wrows; /* Current number of tty rows. */
|
||||
int dflag = 0, Iflag = 0, Cflag = 0, Tflag = 0, oflag = 0, Kflag = 0;
|
||||
int xflag = 0, zflag = 0;
|
||||
static struct statinfo cur, last;
|
||||
static int num_devices;
|
||||
static struct device_selection *dev_select;
|
||||
static int maxshowdevs;
|
||||
static volatile sig_atomic_t headercount;
|
||||
static volatile sig_atomic_t wresized; /* Tty resized, when non-zero. */
|
||||
static volatile sig_atomic_t alarm_rang;
|
||||
static volatile sig_atomic_t return_requested;
|
||||
static unsigned short wrows; /* Current number of tty rows. */
|
||||
static int dflag = 0, Iflag = 0, Cflag = 0, Tflag = 0, oflag = 0, Kflag = 0;
|
||||
static int xflag = 0, zflag = 0;
|
||||
|
||||
/* local function declarations */
|
||||
static void usage(void);
|
||||
@ -650,7 +654,7 @@ main(int argc, char **argv)
|
||||
* Force a header to be prepended to the next output.
|
||||
*/
|
||||
void
|
||||
needhdr(int signo)
|
||||
needhdr(int signo __unused)
|
||||
{
|
||||
|
||||
headercount = 1;
|
||||
@ -662,7 +666,7 @@ needhdr(int signo)
|
||||
* prepended to the next output.
|
||||
*/
|
||||
void
|
||||
needresize(int signo)
|
||||
needresize(int signo __unused)
|
||||
{
|
||||
|
||||
wresized = 1;
|
||||
@ -673,7 +677,7 @@ needresize(int signo)
|
||||
* Record the alarm so the main loop can break its sleep
|
||||
*/
|
||||
void
|
||||
alarm_clock(int signo)
|
||||
alarm_clock(int signo __unused)
|
||||
{
|
||||
alarm_rang = 1;
|
||||
}
|
||||
@ -682,7 +686,7 @@ alarm_clock(int signo)
|
||||
* Request that the main loop exit soon
|
||||
*/
|
||||
void
|
||||
needreturn(int signo)
|
||||
needreturn(int signo __unused)
|
||||
{
|
||||
return_requested = 1;
|
||||
}
|
||||
@ -998,8 +1002,7 @@ readvar(kvm_t *kd, const char *name, int nlid, void *ptr, size_t len)
|
||||
warnx("kvm_read(%s): %s", namelist[nlid].n_name,
|
||||
kvm_geterr(kd));
|
||||
return (1);
|
||||
}
|
||||
if (nbytes != len) {
|
||||
} else if ((size_t)nbytes != len) {
|
||||
warnx("kvm_read(%s): expected %zu bytes, got %zd bytes",
|
||||
namelist[nlid].n_name, len, nbytes);
|
||||
return (1);
|
||||
|
Loading…
Reference in New Issue
Block a user