aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAdrian Chadd <adrian@FreeBSD.org>2020-12-29 17:50:49 +0000
committerAdrian Chadd <adrian@FreeBSD.org>2020-12-29 18:24:36 +0000
commit66585c3fe278c71ffa995c296a9a1e712482418e (patch)
tree284eaa38dc36dd90dfb8237fe21a1da5828734da /tools
parent1fef838b913a3541cf11b6e412ce3e83381c921a (diff)
downloadsrc-66585c3fe278c71ffa995c296a9a1e712482418e.tar.gz
src-66585c3fe278c71ffa995c296a9a1e712482418e.zip
[wlanwatch] fix compiler warnings-as-errors on gcc-6.4 mips
* argc/argv are currently unused * msglen is currently unused * "default" is a const buffer, but char *cp isn't, so change default string to be a non-const global string variable * Make 'cp' private to each context that's using it, which fixes a "variable shadows previous declaration" warning and makes it easier to track where it was being leaked between address family sections
Diffstat (limited to 'tools')
-rw-r--r--tools/tools/net80211/wlanwatch/wlanwatch.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/tools/net80211/wlanwatch/wlanwatch.c b/tools/tools/net80211/wlanwatch/wlanwatch.c
index 254d3be24448..7ff81cc1253a 100644
--- a/tools/tools/net80211/wlanwatch/wlanwatch.c
+++ b/tools/tools/net80211/wlanwatch/wlanwatch.c
@@ -84,6 +84,9 @@ main(int argc, char *argv[])
int n, s;
char msg[2048];
+ (void) argc; /* UNUSED */
+ (void) argv; /* UNUSED */
+
s = socket(PF_ROUTE, SOCK_RAW, 0);
if (s < 0)
err(EX_OSERR, "socket");
@@ -135,16 +138,18 @@ char ifnetflags[] =
char addrnames[] =
"\1DST\2GATEWAY\3NETMASK\4GENMASK\5IFP\6IFA\7AUTHOR\010BRD";
+char defaultname[] = "default";
+
static const char *
routename(struct sockaddr *sa)
{
- char *cp;
static char line[MAXHOSTNAMELEN + 1];
struct hostent *hp;
static char domain[MAXHOSTNAMELEN + 1];
static int first = 1, n;
if (first) {
+ char *cp = NULL;
first = 0;
if (gethostname(domain, MAXHOSTNAMELEN) == 0 &&
(cp = strchr(domain, '.'))) {
@@ -160,12 +165,14 @@ routename(struct sockaddr *sa)
case AF_INET:
{ struct in_addr in;
+ char *cp;
+
in = ((struct sockaddr_in *)sa)->sin_addr;
- cp = 0;
+ cp = NULL;
if (in.s_addr == INADDR_ANY || sa->sa_len < 4)
- cp = "default";
- if (cp == 0 && !nflag) {
+ cp = defaultname;
+ if (cp == NULL && !nflag) {
hp = gethostbyaddr((char *)&in, sizeof (struct in_addr),
AF_INET);
if (hp) {
@@ -291,6 +298,8 @@ print_rtmsg(struct rt_msghdr *rtm, int msglen)
time_t now = time(NULL);
char *cnow = ctime(&now);
+ (void) msglen; /* UNUSED */
+
if (rtm->rtm_version != RTM_VERSION) {
(void) printf("routing message version %d not understood\n",
rtm->rtm_version);