Fix the easy warnings:
1) Avoid shadowing index. 2) Constness. 3) Missing prototype for ifcmd. 4) Missing include of string.h. 5) Avoid shadowing error function. 6) ANSI definition for main.
This commit is contained in:
parent
a77c5ad8b7
commit
33dc549136
@ -55,24 +55,24 @@ get_tbl_ptr(const u_long size, const u_int scale)
|
||||
{
|
||||
struct convtbl *tbl_ptr = NULL;
|
||||
u_long tmp = 0;
|
||||
u_int index = scale;
|
||||
u_int idx = scale;
|
||||
|
||||
/* If our index is out of range, default to auto-scaling. */
|
||||
if (index > SC_AUTO)
|
||||
index = SC_AUTO;
|
||||
if (idx > SC_AUTO)
|
||||
idx = SC_AUTO;
|
||||
|
||||
if (index == SC_AUTO)
|
||||
if (idx == SC_AUTO)
|
||||
/*
|
||||
* Simple but elegant algorithm. Count how many times
|
||||
* we can shift our size value right by a factor of ten,
|
||||
* incrementing an index each time. We then use the
|
||||
* index as the array index into the conversion table.
|
||||
*/
|
||||
for (tmp = size, index = SC_KILOBYTE;
|
||||
tmp >= MEGA && index <= SC_GIGABYTE;
|
||||
tmp >>= 10, index++);
|
||||
for (tmp = size, idx = SC_KILOBYTE;
|
||||
tmp >= MEGA && idx <= SC_GIGABYTE;
|
||||
tmp >>= 10, idx++);
|
||||
|
||||
tbl_ptr = &convtbl[index];
|
||||
tbl_ptr = &convtbl[idx];
|
||||
return tbl_ptr;
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ convert(const u_long size, const u_int scale)
|
||||
|
||||
}
|
||||
|
||||
char *
|
||||
const char *
|
||||
get_string(const u_long size, const u_int scale)
|
||||
{
|
||||
struct convtbl *tp = NULL;
|
||||
|
@ -55,13 +55,13 @@
|
||||
struct convtbl {
|
||||
u_int mul;
|
||||
u_int scale;
|
||||
char *str;
|
||||
const char *str;
|
||||
};
|
||||
|
||||
extern struct convtbl convtbl[];
|
||||
|
||||
extern double convert(const u_long, const u_int);
|
||||
extern char *get_string(const u_long, const u_int);
|
||||
extern const char *get_string(const u_long, const u_int);
|
||||
|
||||
#endif /* ! _CONVTBL_H_ */
|
||||
/*
|
||||
|
@ -108,6 +108,7 @@ void fetchpigs(void);
|
||||
void fetchswap(void);
|
||||
void fetchtcp(void);
|
||||
void getsysctl(const char *, void *, size_t);
|
||||
int ifcmd(const char *cmd, const char *args);
|
||||
int initicmp(void);
|
||||
int initicmp6(void);
|
||||
int initifstat(void);
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <float.h>
|
||||
#include <err.h>
|
||||
@ -55,7 +56,7 @@ static int selectscale(const char *);
|
||||
int
|
||||
ifcmd(const char *cmd, const char *args)
|
||||
{
|
||||
if (prefix((char *)cmd, (char *)"scale")) {
|
||||
if (prefix(cmd, "scale")) {
|
||||
if (*args != '\0' && selectscale(args) != -1)
|
||||
;
|
||||
else {
|
||||
|
@ -39,6 +39,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <float.h>
|
||||
#include <err.h>
|
||||
@ -56,12 +57,12 @@
|
||||
#define C4 60 /* 60-80 */
|
||||
#define C5 80 /* Used for label positioning. */
|
||||
|
||||
static int col0 = 0;
|
||||
static int col1 = C1;
|
||||
static int col2 = C2;
|
||||
static int col3 = C3;
|
||||
static int col4 = C4;
|
||||
static int col5 = C5;
|
||||
static const int col0 = 0;
|
||||
static const int col1 = C1;
|
||||
static const int col2 = C2;
|
||||
static const int col3 = C3;
|
||||
static const int col4 = C4;
|
||||
static const int col5 = C5;
|
||||
|
||||
|
||||
SLIST_HEAD(, if_stat) curlist;
|
||||
@ -245,7 +246,6 @@ fetchifstat(void)
|
||||
struct timeval tv, new_tv, old_tv;
|
||||
double elapsed = 0.0;
|
||||
u_int new_inb, new_outb, old_inb, old_outb = 0;
|
||||
u_int error = 0;
|
||||
u_int we_need_to_sort_interface_list = 0;
|
||||
|
||||
SLIST_FOREACH(ifp, &curlist, link) {
|
||||
@ -257,8 +257,7 @@ fetchifstat(void)
|
||||
old_outb = ifp->if_mib.ifmd_data.ifi_obytes;
|
||||
ifp->tv_lastchanged = ifp->if_mib.ifmd_data.ifi_lastchange;
|
||||
|
||||
error = gettimeofday(&new_tv, (struct timezone *)0);
|
||||
if (error)
|
||||
if (gettimeofday(&new_tv, (struct timezone *)0) != 0)
|
||||
IFSTAT_ERR(2, "error getting time of day");
|
||||
(void)getifmibdata(ifp->if_row, &ifp->if_mib);
|
||||
|
||||
@ -364,7 +363,6 @@ static
|
||||
unsigned int
|
||||
getifnum(void)
|
||||
{
|
||||
int error = 0;
|
||||
u_int data = 0;
|
||||
size_t datalen = 0;
|
||||
static int name[] = { CTL_NET,
|
||||
@ -374,13 +372,8 @@ getifnum(void)
|
||||
IFMIB_IFCOUNT };
|
||||
|
||||
datalen = sizeof(data);
|
||||
error = sysctl(name,
|
||||
5,
|
||||
(void *)&data,
|
||||
(size_t *)&datalen,
|
||||
(void *)NULL,
|
||||
(size_t)0);
|
||||
if (error)
|
||||
if (sysctl(name, 5, (void *)&data, (size_t *)&datalen, (void *)NULL,
|
||||
(size_t)0) != 0)
|
||||
IFSTAT_ERR(1, "sysctl error");
|
||||
return data;
|
||||
}
|
||||
@ -388,7 +381,6 @@ getifnum(void)
|
||||
static void
|
||||
getifmibdata(int row, struct ifmibdata *data)
|
||||
{
|
||||
int error = 0;
|
||||
size_t datalen = 0;
|
||||
static int name[] = { CTL_NET,
|
||||
PF_LINK,
|
||||
@ -399,13 +391,8 @@ getifmibdata(int row, struct ifmibdata *data)
|
||||
datalen = sizeof(*data);
|
||||
name[4] = row;
|
||||
|
||||
error = sysctl(name,
|
||||
6,
|
||||
(void *)data,
|
||||
(size_t *)&datalen,
|
||||
(void *)NULL,
|
||||
(size_t)0);
|
||||
if (error)
|
||||
if (sysctl(name, 6, (void *)data, (size_t *)&datalen, (void *)NULL,
|
||||
(size_t)0) != 0)
|
||||
IFSTAT_ERR(2, "sysctl error getting interface data");
|
||||
}
|
||||
|
||||
|
@ -82,9 +82,7 @@ int use_kvm = 1;
|
||||
static WINDOW *wload; /* one line window for load average */
|
||||
|
||||
int
|
||||
main(argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char errbuf[_POSIX2_LINE_MAX], dummy;
|
||||
size_t size;
|
||||
|
Loading…
x
Reference in New Issue
Block a user