Define _FORTIFY_SOURCE in common-defs.h
authorTom Tromey <tom@tromey.com>
Fri, 10 Aug 2018 15:03:47 +0000 (09:03 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 13 Aug 2018 16:02:00 +0000 (10:02 -0600)
This defines _FORTIFY_SOURCE in common-defs.h.  This seems like a
sensible safety measure, and also it may help avoid build problems
with -Wunused-result on distros that already define _FORTIFY_SOURCE by
default.

Tested by the buildbot.

gdb/ChangeLog
2018-08-13  Tom Tromey  <tom@tromey.com>

* common/common-defs.h (_FORTIFY_SOURCE): Define.

gdb/ChangeLog
gdb/common/common-defs.h

index 0e1848c00c1fa52cf38005d607c4ced1596fb241..37ab81b0a93b7c6ad2ea678247cf7dbbc9ce879a 100644 (file)
@@ -1,3 +1,7 @@
+2018-08-13  Tom Tromey  <tom@tromey.com>
+
+       * common/common-defs.h (_FORTIFY_SOURCE): Define.
+
 2018-08-13  Alan Hayward  <alan.hayward@arm.com>
 
        * aarch64-linux-tdep.c (aarch64_linux_supply_sve_regset): New function.
index 80f1ff4f5609f96fb89b053e7fd8f65b863283cb..58445b161105f7c74a454f00703077508b8b0f05 100644 (file)
 #define __STDC_LIMIT_MACROS 1
 #define __STDC_FORMAT_MACROS 1
 
+/* Some distros enable _FORTIFY_SOURCE by default, which on occasion
+   has caused build failures with -Wunused-result when a patch is
+   developed on a distro that does not enable _FORTIFY_SOURCE.  We
+   enable it here in order to try to catch these problems earlier;
+   plus this seems like a reasonable safety measure.  The check for
+   optimization is required because _FORTIFY_SOURCE only works when
+   optimization is enabled.  */
+
+#if defined __OPTIMIZE__ && __OPTIMIZE__ > 0
+#define _FORTIFY_SOURCE 2
+#endif
+
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
This page took 0.03685 seconds and 4 git commands to generate.