git: 6d88f9fed6a2 - main - systat: mostly clean up warns
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 01 Nov 2021 23:11:44 UTC
The branch main has been updated by mjg:
URL: https://cgit.FreeBSD.org/src/commit/?id=6d88f9fed6a2aa1ffd2c856d246209f24b7dbea0
commit 6d88f9fed6a2aa1ffd2c856d246209f24b7dbea0
Author: Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2021-11-01 20:45:42 +0000
Commit: Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2021-11-01 23:11:16 +0000
systat: mostly clean up warns
Sponsored by: Rubicon Communications, LLC ("Netgate")
---
usr.bin/systat/Makefile | 4 ++--
usr.bin/systat/devs.c | 10 +++++-----
usr.bin/systat/extern.h | 5 +++++
usr.bin/systat/ifstat.c | 35 +++++++++++++----------------------
usr.bin/systat/main.c | 12 ++++++------
usr.bin/systat/netstat.c | 2 +-
usr.bin/systat/proc.c | 30 ++++++++----------------------
usr.bin/systat/sysput.c | 36 +++++++++++++++++++++---------------
usr.bin/systat/vmstat.c | 16 ++++------------
9 files changed, 65 insertions(+), 85 deletions(-)
diff --git a/usr.bin/systat/Makefile b/usr.bin/systat/Makefile
index 58b6c855d6af..e0575ff0d15a 100644
--- a/usr.bin/systat/Makefile
+++ b/usr.bin/systat/Makefile
@@ -14,8 +14,8 @@ SRCS+= icmp6.c ip6.c
CFLAGS+= -DINET6
.endif
-WARNS?= 1
-
LIBADD= tinfow ncursesw m devstat kvm util procstat
.include <bsd.prog.mk>
+
+CFLAGS+= -Wno-cast-align -Wno-cast-qual
diff --git a/usr.bin/systat/devs.c b/usr.bin/systat/devs.c
index 87d04f989ea3..63990bab5f81 100644
--- a/usr.bin/systat/devs.c
+++ b/usr.bin/systat/devs.c
@@ -86,16 +86,16 @@ typedef enum {
struct statinfo cur_dev, last_dev, run_dev;
-last_match_type last_type;
+static last_match_type last_type;
struct device_selection *dev_select;
long generation;
int num_devices, num_selected;
int num_selections;
long select_generation;
-struct devstat_match *matches = NULL;
-int num_matches = 0;
-char **specified_devices;
-int num_devices_specified = 0;
+static struct devstat_match *matches = NULL;
+static int num_matches = 0;
+static char **specified_devices;
+static int num_devices_specified = 0;
static int dsmatchselect(const char *args, devstat_select_mode select_mode,
int maxshowdevs, struct statinfo *s1);
diff --git a/usr.bin/systat/extern.h b/usr.bin/systat/extern.h
index 322065f79312..3b5597598b8b 100644
--- a/usr.bin/systat/extern.h
+++ b/usr.bin/systat/extern.h
@@ -58,6 +58,11 @@ extern int protos;
extern int verbose;
extern unsigned int delay;
+extern int curscale;
+extern char *matchline;
+extern int showpps;
+extern int needsort;
+
struct in_conninfo;
extern struct device_selection *dev_select;
diff --git a/usr.bin/systat/ifstat.c b/usr.bin/systat/ifstat.c
index 82e3429dbfda..c97e586ae7a3 100644
--- a/usr.bin/systat/ifstat.c
+++ b/usr.bin/systat/ifstat.c
@@ -56,15 +56,11 @@
#define C4 60 /* 60-80 */
#define C5 80 /* Used for label positioning. */
-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;
-SLIST_HEAD(, if_stat_disp) displist;
+static SLIST_HEAD(, if_stat) curlist;
struct if_stat {
SLIST_ENTRY(if_stat) link;
@@ -87,11 +83,6 @@ struct if_stat {
u_int match;
};
-extern int curscale;
-extern char *matchline;
-extern int showpps;
-extern int needsort;
-
static int needclear = 0;
static bool displayall = false;
@@ -217,19 +208,19 @@ showifstat(void)
struct if_stat *ifp = NULL;
SLIST_FOREACH(ifp, &curlist, link) {
- if (ifp->if_ypos < LINES - 3 && ifp->if_ypos != -1)
+ if (ifp->if_ypos < LINES - 3 && ifp->if_ypos != -1) {
if (!ifp->display || ifp->match == 0) {
wmove(wnd, ifp->if_ypos, 0);
wclrtoeol(wnd);
wmove(wnd, ifp->if_ypos + 1, 0);
wclrtoeol(wnd);
- }
- else {
+ } else {
PUTNAME(ifp);
PUTRATE(col2, ifp->if_ypos);
PUTRATE(col3, ifp->if_ypos);
PUTTOTAL(col4, ifp->if_ypos);
}
+ }
}
return;
@@ -390,9 +381,9 @@ format_device_name(struct if_stat *ifp)
static int
check_match(const char *ifname)
{
- char *p = matchline, *c, t;
+ char *p = matchline, *ch, t;
int match = 0, mlen;
-
+
if (matchline == NULL)
return (0);
@@ -400,21 +391,21 @@ check_match(const char *ifname)
while (*p == ' ')
p ++;
- c = p;
- while ((mlen = strcspn(c, " ;,")) != 0) {
- p = c + mlen;
+ ch = p;
+ while ((mlen = strcspn(ch, " ;,")) != 0) {
+ p = ch + mlen;
t = *p;
- if (p - c > 0) {
+ if (p - ch > 0) {
*p = '\0';
- if (fnmatch(c, ifname, FNM_CASEFOLD) == 0) {
+ if (fnmatch(ch, ifname, FNM_CASEFOLD) == 0) {
*p = t;
return (1);
}
*p = t;
- c = p + strspn(p, " ;,");
+ ch = p + strspn(p, " ;,");
}
else {
- c = p + strspn(p, " ;,");
+ ch = p + strspn(p, " ;,");
}
}
diff --git a/usr.bin/systat/main.c b/usr.bin/systat/main.c
index b84351379f41..3266fa187714 100644
--- a/usr.bin/systat/main.c
+++ b/usr.bin/systat/main.c
@@ -38,7 +38,7 @@ static const char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/6/93";
#endif
#ifndef lint
-static const char copyright[] =
+static const char copyright[] __unused =
"@(#) Copyright (c) 1980, 1992, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif
@@ -65,12 +65,11 @@ static const char copyright[] =
static int dellave;
kvm_t *kd;
-sig_t sigtstpdfl;
double avenrun[3];
int col;
unsigned int delay = 5000000; /* in microseconds */
int verbose = 1; /* to report kvm read errs */
-struct clockinfo clkinfo;
+static struct clockinfo clkinfo;
double hertz;
char c;
char *namp;
@@ -86,7 +85,7 @@ struct cmdentry {
char *cmd; /* Command name */
char *argv; /* Arguments vector for a command */
};
-SLIST_HEAD(, cmdentry) commands;
+static SLIST_HEAD(, cmdentry) commands;
static void
parse_cmd_args (int argc, char **argv)
@@ -277,6 +276,7 @@ void
display(void)
{
uint64_t arc_stat;
+ unsigned int ui;
int i, j;
/* Get the load average over the last minute. */
@@ -316,8 +316,8 @@ display(void)
GETSYSCTL("kstat.zfs.misc.arcstats.dbuf_size", arc_stat);
arc[6] += arc_stat;
wmove(wload, 0, 0); wclrtoeol(wload);
- for (i = 0 ; i < nitems(arc); i++)
- sysputuint64(wload, 0, i*8+2, 6, arc[i], 0);
+ for (ui = 0 ; ui < nitems(arc); ui++)
+ sysputuint64(wload, 0, ui*8+2, 6, arc[ui], 0);
}
}
(*curcmd->c_refresh)();
diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c
index a334e03beb5a..8199d0c81586 100644
--- a/usr.bin/systat/netstat.c
+++ b/usr.bin/systat/netstat.c
@@ -115,7 +115,7 @@ struct netinfo {
u_int ni_sndcc; /* snd buffer character count */
};
-TAILQ_HEAD(netinfohead, netinfo) netcb = TAILQ_HEAD_INITIALIZER(netcb);
+static TAILQ_HEAD(netinfohead, netinfo) netcb = TAILQ_HEAD_INITIALIZER(netcb);
static int aflag = 0;
static int nflag = 0;
diff --git a/usr.bin/systat/proc.c b/usr.bin/systat/proc.c
index 58c3bea64239..deb27fc2f4bb 100644
--- a/usr.bin/systat/proc.c
+++ b/usr.bin/systat/proc.c
@@ -64,14 +64,14 @@ static struct proc_usage {
uint64_t total;
uint32_t pages;
} **pu = NULL;
-static unsigned int nproc;
+static int nproc;
static int proc_compar(const void *, const void *);
static void
display_proc_line(int idx, int y, uint64_t totalswappages)
{
int offset = 0, rate;
- const char *uname, *pname;
+ const char *uname;
char buf[30];
uint64_t swapbytes;
@@ -210,25 +210,11 @@ per_proc_swap_usage(struct kinfo_proc *kipp)
}
void
-closeproc(WINDOW *w)
-{
-
- if (prstat != NULL)
- procstat_close(prstat);
- prstat = NULL;
- if (w == NULL)
- return;
- wclear(w);
- wrefresh(w);
- delwin(w);
-}
-
-void
-procshow(int col, int hight, uint64_t totalswappages)
+procshow(int lcol, int hight, uint64_t totalswappages)
{
int i, y;
- for (i = 0, y = col + 1 /* HEADING */; i < hight; i++, y++)
+ for (i = 0, y = lcol + 1 /* HEADING */; i < hight; i++, y++)
display_proc_line(i, y, totalswappages);
}
@@ -244,7 +230,7 @@ procinit(void)
void
procgetinfo(void)
{
- static unsigned int maxnproc = 0;
+ static int maxnproc = 0;
int cnt, i;
uint32_t pages;
struct kinfo_proc *kipp;
@@ -289,12 +275,12 @@ procgetinfo(void)
}
void
-proclabel(int col)
+proclabel(int lcol)
{
- wmove(wnd, col, 0);
+ wmove(wnd, lcol, 0);
wclrtoeol(wnd);
- mvwaddstr(wnd, col, 0,
+ mvwaddstr(wnd, lcol, 0,
"Pid Username Command Swap/Total "
"Per-Process Per-System");
}
diff --git a/usr.bin/systat/sysput.c b/usr.bin/systat/sysput.c
index 6e14f9eb752f..bccc00f65165 100644
--- a/usr.bin/systat/sysput.c
+++ b/usr.bin/systat/sysput.c
@@ -41,36 +41,42 @@ __FBSDID("$FreeBSD$");
#include "extern.h"
void
-sysputspaces(WINDOW *wd, int row, int col, int width)
+sysputspaces(WINDOW *wd, int row, int lcol, int width)
{
static char str60[] = " "
" ";
- mvwaddstr(wd, row, col, str60 + sizeof(str60) - width - 1);
+ mvwaddstr(wd, row, lcol, str60 + sizeof(str60) - width - 1);
}
void
-sysputstrs(WINDOW *wd, int row, int col, int width)
+sysputstrs(WINDOW *wd __unused, int row, int lcol, int width)
{
static char str60[] = "********************"
"****************************************";
- mvwaddstr(wnd, row, col, str60 + sizeof(str60) - width - 1);
+ /*
+ * XXX wnd instead of wd?
+ */
+ mvwaddstr(wnd, row, lcol, str60 + sizeof(str60) - width - 1);
}
void
-sysputXs(WINDOW *wd, int row, int col, int width)
+sysputXs(WINDOW *wd __unused, int row, int lcol, int width)
{
static char str60[] = "XXXXXXXXXXXXXXXXXXXX"
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
- mvwaddstr(wnd, row, col, str60 + sizeof(str60) - width - 1);
+ /*
+ * XXX wnd instead of wd?
+ */
+ mvwaddstr(wnd, row, lcol, str60 + sizeof(str60) - width - 1);
}
void
-sysputuint64(WINDOW *wd, int row, int col, int width, uint64_t val, int flags)
+sysputuint64(WINDOW *wd, int row, int lcol, int width, uint64_t val, int flags)
{
- char unit, *ptr, *start, wrtbuf[width + width + 1];
+ char unit, *start, wrtbuf[width + width + 1];
int len;
unit = 0;
@@ -88,25 +94,25 @@ sysputuint64(WINDOW *wd, int row, int col, int width, uint64_t val, int flags)
memset(wrtbuf + len, ' ', width - len);
start += len;
- mvwaddstr(wd, row, col, start);
+ mvwaddstr(wd, row, lcol, start);
return;
error:
- sysputstrs(wd, row, col, width);
+ sysputstrs(wd, row, lcol, width);
}
void
-sysputwuint64(WINDOW *wd, int row, int col, int width, uint64_t val, int flags)
+sysputwuint64(WINDOW *wd, int row, int lcol, int width, uint64_t val, int flags)
{
if(val == 0)
- sysputspaces(wd, row, col, width);
+ sysputspaces(wd, row, lcol, width);
else
- sysputuint64(wd, row, col, width, val, flags);
+ sysputuint64(wd, row, lcol, width, val, flags);
}
void
-sysputpage(WINDOW *wd, int row, int col, int width, uint64_t pages, int flags)
+sysputpage(WINDOW *wd, int row, int lcol, int width, uint64_t pages, int flags)
{
- sysputuint64(wd, row, col, width, ptoa(pages), flags);
+ sysputuint64(wd, row, lcol, width, ptoa(pages), flags);
}
diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c
index e84b79bdd184..57697284a6ab 100644
--- a/usr.bin/systat/vmstat.c
+++ b/usr.bin/systat/vmstat.c
@@ -136,7 +136,6 @@ static void copyinfo(struct Info *, struct Info *);
static float cputime(int);
static void do_putuint64(uint64_t, int, int, int, int);
static void getinfo(struct Info *);
-static void putuint64(uint64_t, int, int, int);
static int ucount(void);
static int ncpu;
@@ -298,7 +297,7 @@ fetchkre(void)
void
labelkre(void)
{
- int i, j;
+ int i;
clear();
mvprintw(STATROW, STATCOL + 6, "users Load");
@@ -634,19 +633,12 @@ putint(int n, int l, int lc, int w)
do_putuint64(n, l, lc, w, SI);
}
-static void
-putuint64(uint64_t n, int l, int lc, int w)
-{
-
- do_putuint64(n, l, lc, w, IEC);
-}
-
static void
do_putuint64(uint64_t n, int l, int lc, int w, int div)
{
int snr;
char b[128];
- char buf[128];
+ char lbuf[128];
move(l, lc);
#ifdef DEBUG
@@ -661,9 +653,9 @@ do_putuint64(uint64_t n, int l, int lc, int w, int div)
}
snr = snprintf(b, sizeof(b), "%*ju", w, (uintmax_t)n);
if (snr != w) {
- humanize_number(buf, w, n, "", HN_AUTOSCALE,
+ humanize_number(lbuf, w, n, "", HN_AUTOSCALE,
HN_NOSPACE | HN_DECIMAL | div);
- snr = snprintf(b, sizeof(b), "%*s", w, buf);
+ snr = snprintf(b, sizeof(b), "%*s", w, lbuf);
}
if (snr != w) {
while (w-- > 0)