From: Denis Ovsienko Date: Wed, 6 Jul 2022 17:41:15 +0000 (+0100) Subject: Squelch a GCC warning on NetBSD/AArch64. [skip appveyor] X-Git-Tag: libpcap-1.10.2~121 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/2313c57f712eb052eae992f78ed255a1c5a6e7b7?ds=inline Squelch a GCC warning on NetBSD/AArch64. [skip appveyor] The warning is a result of upgrading GCC from 10.3 to 12.1 and it pops up only when GCC is NOT given -O2, which happens when build.sh runs "make -s CFLAGS=-Werror". This reproduces with both Autoconf and CMake. NetBSD netbsd-aarch64 9.2 NetBSD 9.2 (GENERIC64) #0 gcc12 (GCC) 12.1.0 pcap-bpf.c: In function 'bpf_open': pcap-bpf.c:529:75: error: 'snprintf' output may be truncated before the last format character [-Werror=format-truncation=] pcap-bpf.c:529:31: note: 'snprintf' output between 10 and 20 bytes into a destination of size 19 (cherry picked from commit 4e7f6e838acb98d70ba7680c02cb1edd4fd8ad99) --- diff --git a/pcap-bpf.c b/pcap-bpf.c index 72808ec1..6a8e7747 100644 --- a/pcap-bpf.c +++ b/pcap-bpf.c @@ -479,7 +479,7 @@ bpf_open(char *errbuf) int fd = -1; static const char cloning_device[] = "/dev/bpf"; int n = 0; - char device[sizeof "/dev/bpf0000000000"]; + char device[sizeof "/dev/bpf00000000000"]; static int no_cloning_bpf = 0; #ifdef _AIX