Clang 10.0.1 on NetBSD 9.2 and OpenBSD 6.9:
./savefile.c:354:4: warning: code will never be executed
[-Wunreachable-code]
In Linux, for example, stdin is a pointer to FILE, so it can be NULL or
non-NULL. In NetBSD and OpenBSD it is a macro:
#define stdin (&__sF[0])
By definition, address of a variable is never NULL hence the warning.
However, assigning the address to a pointer and then immediately
comparing the pointer with NULL is not a condition that is always false,
as far as Clang sees it. Apply the workaround and remove two exemption
rules from build.sh.
(cherry picked from commit
57c96726059fa3f05bc1cbeeb2de37497c9ec9ed)
# 'long' to 'suseconds_t' (aka 'int') [-Wshorten-64-to-32]
LIBPCAP_TAINTED=yes
;;
-clang-*/NetBSD-*)
- # savefile.c:354:4: warning: code will never be executed
- # [-Wunreachable-code]
- LIBPCAP_TAINTED=yes
- ;;
-clang-*/OpenBSD-*)
- # Same as the above.
- LIBPCAP_TAINTED=yes
- ;;
esac
# shellcheck disable=SC2006
[ "$LIBPCAP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags`
if (fname[0] == '-' && fname[1] == '\0')
{
fp = stdin;
- if (stdin == NULL) {
+ if (fp == NULL) {
snprintf(errbuf, PCAP_ERRBUF_SIZE,
"The standard input is not open");
return (NULL);