]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: Include stdlib.h in compiler.h if DEBUG_USE_ABORT is set
authorTim Duesterhus <tim@bastelstu.be>
Tue, 26 Jan 2021 18:24:24 +0000 (19:24 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 27 Jan 2021 11:44:39 +0000 (12:44 +0100)
Building with `"DEBUG=-DDEBUG_STRICT=1 -DDEBUG_USE_ABORT=1"` previously emitted the warning:

    In file included from include/haproxy/api.h:35:0,
                     from src/mux_pt.c:13:
    include/haproxy/buf.h: In function ‘br_init’:
    include/haproxy/bug.h:42:90: warning: implicit declaration of function ‘abort’ [-Wimplicit-function-declaration]
     #define ABORT_NOW() do { extern void ha_backtrace_to_stderr(); ha_backtrace_to_stderr(); abort(); } while (0)
                                                                                              ^
    include/haproxy/bug.h:56:21: note: in expansion of macro ‘ABORT_NOW’
     #define CRASH_NOW() ABORT_NOW()
                         ^
    include/haproxy/bug.h:68:4: note: in expansion of macro ‘CRASH_NOW’
        CRASH_NOW();                                           \
        ^
    include/haproxy/bug.h:62:35: note: in expansion of macro ‘__BUG_ON’
     #define _BUG_ON(cond, file, line) __BUG_ON(cond, file, line)
                                       ^
    include/haproxy/bug.h:61:22: note: in expansion of macro ‘_BUG_ON’
     #define BUG_ON(cond) _BUG_ON(cond, __FILE__, __LINE__)
                          ^
    include/haproxy/buf.h:875:2: note: in expansion of macro ‘BUG_ON’
      BUG_ON(size < 2);
      ^

This patch fixes that issue. The `DEBUG_USE_ABORT` option exists for use with
static analysis tools. No backport needed.

include/haproxy/compiler.h

index fba6dc35808db2c55af81e60c9eb29920ea5040e..87012d27c25f728c29ce3a9aea306eb7eb5e0547 100644 (file)
@@ -22,6 +22,9 @@
 #ifndef _HAPROXY_COMPILER_H
 #define _HAPROXY_COMPILER_H
 
+#ifdef DEBUG_USE_ABORT
+#include <stdlib.h>
+#endif
 
 /*
  * Gcc before 3.0 needs [0] to declare a variable-size array