Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
87dddc9
Add few more files to gitignore
sshedi May 26, 2026
ed1f841
arp: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
3ca7a6d
hostname: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
e19cf06
ifconfig: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
3cf99d3
iptunnel: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
ed744fa
ipmaddr: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
4b35b53
mii-tool: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
834a4e6
nameif: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
b7e47c2
netstat: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
4fe55d9
plipconfig: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
3e0feaf
rarp: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
b76ffad
route: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
cf720e0
slattach: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
84a9044
statistics: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
4f0378d
lib/arcnet: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
a6ca972
lib/ax25: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
3b9afa8
lib/ddp_gr: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
8683da9
lib/ec_hw: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
d25c6b7
lib/ether: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
21abaa6
lib/fddi: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
0f738a1
lib/hw: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
b573108
lib/ib: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
8b764ea
lib/interface: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
a182143
lib/ipx_gr: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
635bbf9
lib/loopback: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
9225950
lib/netrom_gr: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
9db05a7
lib/slip: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
435b7de
lib/strip: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
db9b76a
lib/tr: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
2ebde79
lib/unix: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
71e867a
lib/util-ank: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
efc37e4
lib/x25: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
2320a6a
lib/x25_gr: fix cppcheck issues and gcc build warnings
sshedi May 26, 2026
189cafa
Enforce Werror and Wextra to default CFLAGS
sshedi May 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
*.patch
*.rej
*.orig
.vimrc
tags
cscope.out

.gdb_history
.gdbinit
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ endif

# Compiler and Linker Options
CFLAGS ?= -O2 -g
CFLAGS += -Wall -Wtype-limits -Wunused-parameter
CFLAGS += -Wall -Wtype-limits -Wunused-parameter -Werror -Wextra
CFLAGS += -fno-strict-aliasing # code needs a lot of work before strict aliasing is safe
CPPFLAGS += -D_GNU_SOURCE
# Turn on transparent support for LFS
Expand Down
13 changes: 8 additions & 5 deletions arp.c
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,8 @@ static int arp_file(char *name)
{
char buff[1024];
char *sp, *args[32];
int linenr, argc;
unsigned int linenr;
int argc;
FILE *fp;

if ((fp = fopen(name, "r")) == NULL) {
Expand Down Expand Up @@ -532,7 +533,7 @@ static int arp_show(char *name)
char mask[100];
char line[200];
char dev[100];
int type, flags;
unsigned int type, flags;
FILE *fp;
const char *hostname;
int num, entries = 0, showed = 0;
Expand All @@ -559,7 +560,7 @@ static int arp_show(char *name)
safe_strncpy(dev, "-", sizeof(dev));
/* Read the ARP cache entries. */
for (; fgets(line, sizeof(line), fp);) {
num = sscanf(line, "%s 0x%x 0x%x %99s %99s %99s\n",
num = sscanf(line, "%99s 0x%x 0x%x %99s %99s %99s\n",
ip, &type, &flags, hwa, mask, dev);
if (num < 4)
break;
Expand All @@ -568,14 +569,14 @@ static int arp_show(char *name)
* This happens for incomplete ARP entries for which there is
* no hardware address in the line.
*/
num = sscanf(line, "%s 0x%x 0x%x %99s %99s\n",
num = sscanf(line, "%99s 0x%x 0x%x %99s %99s\n",
ip, &type, &flags, mask, dev);
hwa[0] = 0;
}

entries++;
/* if the user specified hw-type differs, skip it */
if (hw_set && (type != hw->type))
if (hw_set && (type != (unsigned)hw->type))
continue;

/* if the user specified address differs, skip it */
Expand Down Expand Up @@ -750,8 +751,10 @@ int main(int argc, char **argv)

case 'V':
version();
break;
case 'h':
usage(E_USAGE);
break;
case '?':
default:
usage(E_OPTERR);
Expand Down
5 changes: 3 additions & 2 deletions hostname.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,16 +386,17 @@ int main(int argc, char **argv)
exit(1);
}
type = 'd';
/* NOBREAK */
/* fall through */
case 0:
if (file) {
setfilename(file, SETHOST);
break;
}
if (optind < argc) {
if (optind < (int)argc) {
sethname(argv[optind]);
break;
}
/* fall through */
case 1:
gethostname(myname, sizeof(myname));
if (opt_v)
Expand Down
5 changes: 2 additions & 3 deletions ifconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ int main(int argc, char **argv)
#endif
#if HAVE_AFINET
{ /* ipv4 address a.b.c.d */
in_addr_t ip, nm, bc;
in_addr_t ip, nm = 0, bc = 0;
safe_strncpy(host, *spp, (sizeof host));
if (inet_aftype.input(0, host, &_sa) < 0) {
ap->herror(host);
Expand Down Expand Up @@ -880,7 +880,7 @@ int main(int argc, char **argv)
#if HAVE_AFINET
{
/* ipv4 address a.b.c.d */
in_addr_t ip, nm, bc;
in_addr_t ip, nm = 0, bc = 0;
safe_strncpy(host, *spp, (sizeof host));
if (inet_aftype.input(0, host, &_sa) < 0) {
ap->herror(host);
Expand Down Expand Up @@ -1064,7 +1064,6 @@ int main(int argc, char **argv)

if (neednetmask) {
goterr |= set_netmask(skfd, &ifr, samask);
didnetmask++;
}

if (opt_v && goterr)
Expand Down
2 changes: 0 additions & 2 deletions include/util-ank.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ extern int do_ipaddr(int argc, char **argv);
extern int do_iproute(int argc, char **argv);
extern int do_iprule(int argc, char **argv);
extern int do_ipneigh(int argc, char **argv);
extern int do_iptunnel(int argc, char **argv);
extern int do_iplink(int argc, char **argv);
extern int do_ipmonitor(int argc, char **argv);
extern int do_multiaddr(int argc, char **argv);
extern int do_qdisc(int argc, char **argv);
extern int do_class(int argc, char **argv);
extern int do_filter(int argc, char **argv);
Expand Down
41 changes: 16 additions & 25 deletions ipmaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static int parse_lla(char *str, char *addr)
int len=0;

while (*str) {
int tmp;
unsigned int tmp;
if (str[0] == ':' || str[0] == '.') {
str++;
continue;
Expand All @@ -93,10 +93,10 @@ static int parse_lla(char *str, char *addr)

static int parse_hex(char *str, unsigned char *dst, size_t dstlen)
{
int len=0;
size_t len = 0;

while (len < dstlen && *str) {
int tmp;
unsigned int tmp;
if (str[1] == 0)
return -1;
if (sscanf(str, "%02x", &tmp) != 1)
Expand All @@ -118,7 +118,7 @@ struct ma_info
inet_prefix addr;
};

void maddr_ins(struct ma_info **lst, struct ma_info *m)
static void maddr_ins(struct ma_info **lst, struct ma_info *m)
{
struct ma_info *mp;

Expand All @@ -130,7 +130,7 @@ void maddr_ins(struct ma_info **lst, struct ma_info *m)
*lst = m;
}

void read_dev_mcast(struct ma_info **result_p)
static void read_dev_mcast(struct ma_info **result_p)
{
char buf[256];
FILE *fp = fopen(_PATH_PROCNET_DEV_MCAST, "r");
Expand All @@ -145,7 +145,7 @@ void read_dev_mcast(struct ma_info **result_p)
int st;

memset(&m, 0, sizeof(m));
sscanf(buf, "%d%s%d%d%s", &m.index, m.name, &m.users, &st,
sscanf(buf, "%d%15s%d%d%255s", &m.index, m.name, &m.users, &st,
hexa);
if (filter_dev[0] && strcmp(filter_dev, m.name))
continue;
Expand All @@ -166,7 +166,7 @@ void read_dev_mcast(struct ma_info **result_p)
fclose(fp);
}

void read_igmp(struct ma_info **result_p)
static void read_igmp(struct ma_info **result_p)
{
struct ma_info m, *ma = NULL;
char buf[256];
Expand All @@ -175,16 +175,17 @@ void read_igmp(struct ma_info **result_p)
if (!fp)
return;
memset(&m, 0, sizeof(m));
if (fgets(buf, sizeof(buf), fp))
if (fgets(buf, sizeof(buf), fp)) {
/* eat line */;
}

m.addr.family = AF_INET;
m.addr.bitlen = 32;
m.addr.bytelen = 4;

while (fgets(buf, sizeof(buf), fp)) {
if (buf[0] != '\t') {
sscanf(buf, "%d%s", &m.index, m.name);
sscanf(buf, "%d%15s", &m.index, m.name);
continue;
}

Expand All @@ -200,8 +201,7 @@ void read_igmp(struct ma_info **result_p)
fclose(fp);
}


void read_igmp6(struct ma_info **result_p)
static void read_igmp6(struct ma_info **result_p)
{
char buf[256];
FILE *fp = fopen(_PATH_PROCNET_IGMP6, "r");
Expand All @@ -215,7 +215,7 @@ void read_igmp6(struct ma_info **result_p)
int len;

memset(&m, 0, sizeof(m));
sscanf(buf, "%d%s%s%d", &m.index, m.name, hexa, &m.users);
sscanf(buf, "%d%15s%255s%d", &m.index, m.name, hexa, &m.users);

if (filter_dev[0] && strcmp(filter_dev, m.name))
continue;
Expand Down Expand Up @@ -289,7 +289,7 @@ static int multiaddr_list(int argc, char **argv)
if (strcmp(*argv, "dev") == 0) {
NEXT_ARG();
l = strlen(*argv);
if (l <= 0 || l >= sizeof(filter_dev))
if (l == 0 || l >= sizeof(filter_dev))
usage(E_OPTERR);
strncpy(filter_dev, *argv, sizeof (filter_dev));
} else if (strcmp(*argv, "all") == 0) {
Expand All @@ -302,7 +302,7 @@ static int multiaddr_list(int argc, char **argv)
filter_family = AF_PACKET;
} else {
l = strlen(*argv);
if (l <= 0 || l >= sizeof(filter_dev))
if (l == 0 || l >= sizeof(filter_dev))
usage(E_OPTERR);
strncpy(filter_dev, *argv, sizeof (filter_dev));
}
Expand All @@ -319,7 +319,7 @@ static int multiaddr_list(int argc, char **argv)
return 0;
}

int multiaddr_modify(int cmd, int argc, char **argv)
static int multiaddr_modify(int cmd, int argc, char **argv)
{
struct ifreq ifr;
int fd;
Expand Down Expand Up @@ -362,8 +362,7 @@ int multiaddr_modify(int cmd, int argc, char **argv)
exit(0);
}


int do_multiaddr(int argc, char **argv)
static int do_multiaddr(int argc, char **argv)
{
if (argc < 1)
return multiaddr_list(0, NULL);
Expand All @@ -383,20 +382,12 @@ int resolve_hosts = 0;

int main(int argc, char **argv)
{
char *basename;

#if I18N
setlocale (LC_ALL, "");
bindtextdomain("net-tools", "/usr/share/locale");
textdomain("net-tools");
#endif

basename = strrchr(argv[0], '/');
if (basename == NULL)
basename = argv[0];
else
basename++;

while (argc > 1) {
if (argv[1][0] != '-')
break;
Expand Down
26 changes: 10 additions & 16 deletions iptunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ static int do_add(int cmd, int argc, char **argv)
return -1;
}

int do_del(int argc, char **argv)
static int do_del(int argc, char **argv)
{
struct ip_tunnel_parm p;

Expand All @@ -402,7 +402,7 @@ int do_del(int argc, char **argv)
return -1;
}

void print_tunnel(struct ip_tunnel_parm *p)
static void print_tunnel(struct ip_tunnel_parm *p)
{
char s1[256];
char s2[256];
Expand Down Expand Up @@ -476,16 +476,18 @@ static int do_tunnels_list(struct ip_tunnel_parm *p)
return -1;
}

if (fgets(buf, sizeof(buf), fp))
if (fgets(buf, sizeof(buf), fp)) {
/* eat line */;
if (fgets(buf, sizeof(buf), fp))
}
if (fgets(buf, sizeof(buf), fp)) {
/* eat line */;
}

while (fgets(buf, sizeof(buf), fp) != NULL) {
char *ptr;
buf[sizeof(buf) - 1] = 0;
if ((ptr = strchr(buf, ':')) == NULL ||
(*ptr++ = 0, sscanf(buf, "%s", name) != 1)) {
(*ptr++ = 0, sscanf(buf, "%511s", name) != 1)) {
fprintf(stderr, _("Wrong format of /proc/net/dev. Sorry.\n"));
fclose(fp);
return -1;
Expand Down Expand Up @@ -517,10 +519,10 @@ static int do_tunnels_list(struct ip_tunnel_parm *p)
print_tunnel(&p1);
if (show_stats) {
printf(_("RX: Packets Bytes Errors CsumErrs OutOfSeq Mcasts\n"));
printf(" %-10ld %-12ld %-6ld %-8ld %-8ld %-8ld\n",
printf(" %-10lu %-12lu %-6lu %-8lu %-8lu %-8lu\n",
rx_packets, rx_bytes, rx_errs, rx_frame, rx_fifo, rx_multi);
printf(_("TX: Packets Bytes Errors DeadLoop NoRoute NoBufs\n"));
printf(" %-10ld %-12ld %-6ld %-8ld %-8ld %-6ld\n\n",
printf(" %-10lu %-12lu %-6lu %-8lu %-8lu %-6lu\n\n",
tx_packets, tx_bytes, tx_errs, tx_colls, tx_carrier, tx_drops);
}
}
Expand Down Expand Up @@ -557,7 +559,7 @@ static int do_show(int argc, char **argv)
return 0;
}

int do_iptunnel(int argc, char **argv)
static int do_iptunnel(int argc, char **argv)
{
if (argc > 0) {
if (matches(*argv, "add") == 0)
Expand All @@ -583,20 +585,12 @@ int resolve_hosts = 0;

int main(int argc, char **argv)
{
char *basename;

#if I18N
setlocale (LC_ALL, "");
bindtextdomain("net-tools", "/usr/share/locale");
textdomain("net-tools");
#endif

basename = strrchr(argv[0], '/');
if (basename == NULL)
basename = argv[0];
else
basename++;

while (argc > 1) {
if (argv[1][0] != '-')
break;
Expand Down
2 changes: 1 addition & 1 deletion lib/arcnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ static int in_arcnet(char *bufp, struct sockaddr_storage *sasp)
struct hwtype arcnet_hwtype =
{
"arcnet", NULL, /*"2.5Mbps ARCnet", */ ARPHRD_ARCNET, 1,
pr_arcnet, in_arcnet, NULL
pr_arcnet, in_arcnet, NULL, 0
};


Expand Down
4 changes: 2 additions & 2 deletions lib/ax25.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static int AX25_input(int type, char *bufp, struct sockaddr_storage *sasp)
struct sockaddr *sap = (struct sockaddr *)sasp;
char *ptr;
char *orig, c;
int i;
size_t i;

(void)type; /* unused */
sap->sa_family = ax25_aftype.af;
Expand Down Expand Up @@ -190,7 +190,7 @@ static int KISS_init(int fd)
struct hwtype ax25_hwtype =
{
"ax25", NULL, /*"AMPR AX.25", */ ARPHRD_AX25, 7,
AX25_print, AX25_hinput, NULL
AX25_print, AX25_hinput, NULL, 0
};

struct aftype ax25_aftype =
Expand Down
Loading