summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Habets <thomas@habets.se>2022-12-19 20:08:53 +0000
committerThomas Habets <thomas@habets.se>2022-12-19 20:08:53 +0000
commitfa1a14af2e23f13a756b551a223fb65a1b753818 (patch)
tree2879eba374af1965c3a54345c3db6eb011d8fa51
parent797b7357f95467998b6b30cc6bc43ec86da354b5 (diff)
downloadarping-2.x.tar.gz
Fix clang-tidy complaints. No actual changes.HEADarping-2.x
-rwxr-xr-xextra/tidy.sh23
-rw-r--r--src/arping.c7
-rw-r--r--src/arping_test.c3
-rw-r--r--src/fuzz_pingmac.c1
4 files changed, 30 insertions, 4 deletions
diff --git a/extra/tidy.sh b/extra/tidy.sh
new file mode 100755
index 0000000..07b9558
--- /dev/null
+++ b/extra/tidy.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+
+set -e
+
+# src/findif_bsdroute.c
+# src/windows.c
+# src/findif_linux.c
+# src/findif_sysctl.c
+for f in src/arping.c \
+ src/arping_main.c \
+ src/arping_test.c \
+ src/cast.c \
+ src/findif_getifaddrs.c \
+ src/findif_other.c \
+ src/fuzz_pingip.c \
+ src/fuzz_pingmac.c \
+ src/mock_libnet.c \
+ src/mock_libpcap.c \
+ src/unix.c; do
+ echo "========================================================="
+ echo "Checking ${f?}…"
+ clang-tidy "${f?}" -- -DHAVE_CONFIG_H -I. -I.. -D_DEFAULT_SOURCE=1 -std=c99
+done
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 <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -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<string.h>
#include<stdio.h>
#include<stdlib.h>
+#include<time.h>
#include<unistd.h>
#include<inttypes.h>