]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
If we don't include sys/queue.h directly the clang analyzer complains
authorRoy Marples <roy@marples.name>
Tue, 11 Nov 2014 10:33:28 +0000 (10:33 +0000)
committerRoy Marples <roy@marples.name>
Tue, 11 Nov 2014 10:33:28 +0000 (10:33 +0000)
about using freed memory.
That seems to be a workaround for this upstream bug:
http://llvm.org/bugs/show_bug.cgi?id=18222

configure

index 24c79f5b981cf1079ac76559c2a42418d696075e..fc62a5b6faf198d01336503fe97463faf735bb74 100755 (executable)
--- a/configure
+++ b/configure
@@ -660,12 +660,14 @@ int main(void) {
 EOF
        if $XCC _queue.c -o _queue 2>&3; then
                TAILQ_FOREACH_SAFE=yes
+               TAILQ_FOREACH=yes
        else
                TAILQ_FOREACH_SAFE=no
        fi
        echo "$TAILQ_FOREACH_SAFE"
        rm -f _queue.c _queue
 fi
+
 if [ -z "$TAILQ_CONCAT" ]; then
        printf "Testing for TAILQ_CONCAT ..."
        cat <<EOF >_queue.c
@@ -679,13 +681,43 @@ int main(void) {
 EOF
        if $XCC _queue.c -o _queue 2>&3; then
                TAILQ_CONCAT=yes
+               TAILQ_FOREACH=yes
        else
                TAILQ_CONCAT=no
        fi
        echo "$TAILQ_CONCAT"
        rm -f _queue.c _queue
 fi
+
+if [ -z "$TAILQ_FOREACH" ]; then
+       printf "Testing for TAILQ_FOREACH ... "
+       cat <<EOF >_queue.c
+#include <sys/queue.h>
+int main(void) {
+#ifndef TAILQ_FOREACH
+#error TAILQ_FOREACH
+#endif
+       return 0;
+}
+EOF
+       if $XCC _queue.c -o _queue 2>&3; then
+               TAILQ_FOREACH=yes
+       else
+               TAILQ_FOREACH=no
+       fi
+       echo "$TAILQ_FOREACH"
+       rm -f _queue.c _queue
+fi
+
 if [ "$TAILQ_FOREACH_SAFE" = no -o "$TAILQ_CONCAT" = no ]; then
+       # If we don't include sys/queue.h then clang analyser finds
+       # too many false positives.
+       # See http://llvm.org/bugs/show_bug.cgi?id=18222
+       # Strictly speaking this isn't needed, but I like it to help
+       # catch any nasties.
+       if [ "$TAILQ_FOREACH" = yes ]; then
+               echo "#include          <sys/queue.h>">>$CONFIG_H
+       fi
        echo "#include          \"compat/queue.h\"">>$CONFIG_H
 else
        echo "#include          <sys/queue.h>" >>$CONFIG_H