From fa1a14af2e23f13a756b551a223fb65a1b753818 Mon Sep 17 00:00:00 2001 From: Thomas Habets Date: Mon, 19 Dec 2022 20:08:53 +0000 Subject: Fix clang-tidy complaints. No actual changes. --- src/arping.c | 7 ++++--- src/arping_test.c | 3 ++- src/fuzz_pingmac.c | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/arping.c b/src/arping.c index 4064e04..0476f75 100644 --- a/src/arping.c +++ b/src/arping.c @@ -35,6 +35,7 @@ #include "config.h" #endif +#include #include #include #include @@ -1297,8 +1298,6 @@ pingmac_send(uint16_t id, uint16_t seq) payload_suffix, payload_suffix_size); } - int c; - if (-1 == (icmp = libnet_build_icmpv4_echo(ICMP_ECHO, /* type */ 0, /* code */ 0, /* checksum */ @@ -1366,7 +1365,7 @@ pingmac_send(uint16_t id, uint16_t seq) (long)lastpacketsent.tv_sec, (long)lastpacketsent.tv_nsec); } - if (-1 == (c = libnet_write(libnet))) { + if (-1 == libnet_write(libnet)) { fprintf(stderr, "arping: libnet_write(): %s\n", libnet_geterror(libnet)); sigint(0); @@ -1464,6 +1463,7 @@ pingip_recv(const char *unused, struct pcap_pkthdr *h, const char * const packet struct libnet_arp_hdr *harp; struct timespec arrival; UNUSED(unused); + assert(packet); if (verbose > 2) { printf("arping: received response for IP ping\n"); @@ -1671,6 +1671,7 @@ pingmac_recv(const char* unused, struct pcap_pkthdr *h, uint8_t *packet) struct libnet_icmpv4_hdr *hicmp; struct timespec arrival; UNUSED(unused); + assert(packet); if(verbose>2) { printf("arping: received response for mac ping\n"); diff --git a/src/arping_test.c b/src/arping_test.c index daaa579..4b4d7e0 100644 --- a/src/arping_test.c +++ b/src/arping_test.c @@ -232,6 +232,7 @@ START_TEST(test_mkpacket) dump_packet(packet, pkthdr.caplen); } fail_unless(!memcmp(packet, correct_packet, pkthdr.caplen)); + free(packet); } END_TEST @@ -437,7 +438,7 @@ START_TEST(strip_newline_test) int c; for (c = 0; tests[c][0]; c++){ char buf[128]; - strcpy(buf, tests[c][0]); + snprintf(buf, sizeof(buf), "%s", tests[c][0]); strip_newline(buf); fail_unless(!strcmp(buf, tests[c][1])); } diff --git a/src/fuzz_pingmac.c b/src/fuzz_pingmac.c index f595e28..5af7aed 100644 --- a/src/fuzz_pingmac.c +++ b/src/fuzz_pingmac.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include -- cgit v1.2.1