Fix compilation on head and while here:

- remove unwanted whitespaces
- remove useless function ifphys()
- fix the Makefile to install it into /usr/bin

PR:		250133
Reviewed by:	glebius, maxim
Approved by:	glebius
Differential Revision:	https://reviews.freebsd.org/D27155
This commit is contained in:
Olivier Cochard 2020-11-30 15:04:35 +00:00
parent b2e9e573a3
commit 6b97a6e365
2 changed files with 11 additions and 22 deletions

View File

@ -3,5 +3,6 @@
PROG= ifinfo
SRCS= ifinfo.c rfc1650.c
MAN=
BINDIR?= /usr/bin
.include <bsd.prog.mk>

View File

@ -12,7 +12,7 @@
* no representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied
* warranty.
*
*
* THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
* ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
@ -49,7 +49,6 @@
static void printit(const struct ifmibdata *, const char *);
static const char *iftype(int);
static const char *ifphys(int, int);
static int isit(int, char **, const char *);
static printfcn findlink(int);
@ -83,7 +82,7 @@ main(int argc, char **argv)
usage(argv[0]);
}
}
retval = 1;
name[0] = CTL_NET;
@ -132,15 +131,15 @@ main(int argc, char **argv)
if (dolink && (pf = findlink(ifmd.ifmd_data.ifi_type))) {
name[5] = IFDATA_LINKSPECIFIC;
if (sysctl(name, 6, 0, &linkmiblen, 0, 0) < 0)
err(EX_OSERR,
err(EX_OSERR,
"sysctl(net.link.ifdata.%d.linkspec) size",
i);
linkmib = malloc(linkmiblen);
if (!linkmib)
err(EX_OSERR, "malloc(%lu)",
err(EX_OSERR, "malloc(%lu)",
(u_long)linkmiblen);
if (sysctl(name, 6, linkmib, &linkmiblen, 0, 0) < 0)
err(EX_OSERR,
err(EX_OSERR,
"sysctl(net.link.ifdata.%d.linkspec)",
i);
pf(linkmib, linkmiblen);
@ -165,15 +164,13 @@ printit(const struct ifmibdata *ifmd, const char *dname)
printf("\tsend queue max length: %d\n", ifmd->ifmd_snd_maxlen);
printf("\tsend queue drops: %d\n", ifmd->ifmd_snd_drops);
printf("\ttype: %s\n", iftype(ifmd->ifmd_data.ifi_type));
printf("\tphysical: %s\n", ifphys(ifmd->ifmd_data.ifi_type,
ifmd->ifmd_data.ifi_physical));
printf("\taddress length: %d\n", ifmd->ifmd_data.ifi_addrlen);
printf("\theader length: %d\n", ifmd->ifmd_data.ifi_hdrlen);
printf("\tlink state: %u\n", ifmd->ifmd_data.ifi_link_state);
printf("\tvhid: %u\n", ifmd->ifmd_data.ifi_vhid);
printf("\tdatalen: %u\n", ifmd->ifmd_data.ifi_datalen);
printf("\tmtu: %lu\n", ifmd->ifmd_data.ifi_mtu);
printf("\tmetric: %lu\n", ifmd->ifmd_data.ifi_metric);
printf("\tmtu: %u\n", ifmd->ifmd_data.ifi_mtu);
printf("\tmetric: %u\n", ifmd->ifmd_data.ifi_metric);
printf("\tline rate: %lu bit/s\n", ifmd->ifmd_data.ifi_baudrate);
printf("\tpackets received: %lu\n", ifmd->ifmd_data.ifi_ipackets);
printf("\tinput errors: %lu\n", ifmd->ifmd_data.ifi_ierrors);
@ -185,7 +182,7 @@ printit(const struct ifmibdata *ifmd, const char *dname)
printf("\tmulticasts received: %lu\n", ifmd->ifmd_data.ifi_imcasts);
printf("\tmulticasts transmitted: %lu\n", ifmd->ifmd_data.ifi_omcasts);
printf("\tinput queue drops: %lu\n", ifmd->ifmd_data.ifi_iqdrops);
printf("\tpackets for unknown protocol: %lu\n",
printf("\tpackets for unknown protocol: %lu\n",
ifmd->ifmd_data.ifi_noproto);
printf("\tHW offload capabilities: 0x%lx\n",
ifmd->ifmd_data.ifi_hwassist);
@ -193,7 +190,7 @@ printit(const struct ifmibdata *ifmd, const char *dname)
ifmd->ifmd_data.ifi_epoch);
#ifdef notdef
printf("\treceive timing: %lu usec\n", ifmd->ifmd_data.ifi_recvtiming);
printf("\ttransmit timing: %lu usec\n",
printf("\ttransmit timing: %lu usec\n",
ifmd->ifmd_data.ifi_xmittiming);
#endif
}
@ -258,7 +255,7 @@ static const char *const if_types[] = {
"IPv6-to-IPv4 TCP relay capturing interface",
"6to4 tunnel interface"
};
#define NIFTYPES ((sizeof if_types)/(sizeof if_types[0]))
#define NIFTYPES (int)((sizeof if_types)/(sizeof if_types[0]))
static const char *
iftype(int type)
@ -273,15 +270,6 @@ iftype(int type)
return if_types[type];
}
static const char *
ifphys(int type, int phys)
{
static char buf[256];
sprintf(buf, "unknown physical %d", phys);
return buf;
}
static int
isit(int argc, char **argv, const char *name)
{