]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
Protect C language extensions with two leading and trailing underscores
authorGuillem Jover <guillem@hadrons.org>
Sun, 17 Jun 2018 22:36:44 +0000 (00:36 +0200)
committerGuillem Jover <guillem@hadrons.org>
Mon, 18 Jun 2018 02:31:00 +0000 (04:31 +0200)
This should make their usage safer against user macros.

configure.ac
include/bsd/sys/cdefs.h
src/explicit_bzero.c
src/local-link.h
src/setproctitle.c
src/setproctitle_ctor.c

index 7769182a5099d36c05966dbadfdb0016f0f8a00a..6b2bb6cda157804787333de859fd2cd17995f72c 100644 (file)
@@ -87,7 +87,7 @@ AC_CACHE_CHECK(
 [[
 static int rc = 1;
 static void init(int argc) { if (argc == 1) rc = 0; }
-void (*init_func)(int argc) __attribute__((section(".init_array"))) = init;
+void (*init_func)(int argc) __attribute__((__section__(".init_array"))) = init;
 int main() { return rc; }
 ]]
                )],
index b5c8dad18633f47736332c1269eb4f82e99a1035..c574fc2728260b6f6e01e21f5d508bfb414a4c5c 100644 (file)
@@ -86,9 +86,9 @@
 #endif
 
 #if LIBBSD_GCC_VERSION >= 0x0405
-#define LIBBSD_DEPRECATED(x) __attribute__((deprecated(x)))
+#define LIBBSD_DEPRECATED(x) __attribute__((__deprecated__(x)))
 #elif LIBBSD_GCC_VERSION >= 0x0301
-#define LIBBSD_DEPRECATED(x) __attribute__((deprecated))
+#define LIBBSD_DEPRECATED(x) __attribute__((__deprecated__))
 #else
 #define LIBBSD_DEPRECATED(x)
 #endif
 #if 0
 #ifndef __unused
 # if LIBBSD_GCC_VERSION >= 0x0300
-#  define __unused __attribute__((unused))
+#  define __unused __attribute__((__unused__))
 # else
 #  define __unused
 # endif
 
 #ifndef __printflike
 # if LIBBSD_GCC_VERSION >= 0x0300
-#  define __printflike(x, y) __attribute((format(printf, (x), (y))))
+#  define __printflike(x, y) __attribute((__format__(__printf__, (x), (y))))
 # else
 #  define __printflike(x, y)
 # endif
 #ifndef __containerof
 # if LIBBSD_GCC_VERSION >= 0x0301
 #  define __containerof(x, s, m) ({ \
-       const volatile __typeof(((s *)0)->m) *__x = (x); \
+       const volatile __typeof__(((s *)0)->m) *__x = (x); \
        __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m)); \
 })
 # else
index 3e33ca85b83b2bb5059da992e900d680730acf47..52a7517dd4f57bf322d57d2b139c5d5a593ef358 100644 (file)
@@ -6,7 +6,7 @@
 
 #include <string.h>
 
-__attribute__((weak)) void
+__attribute__((__weak__)) void
 __explicit_bzero_hook(void *buf, size_t len)
 {
 }
index d518dcfd96c43cc645433a8765f2e4ba38a55f4d..5f3c0fdb20f94c73f18947b68b005c4c5ebceea8 100644 (file)
@@ -29,5 +29,5 @@
 
 #define libbsd_link_warning(symbol, msg) \
        static const char libbsd_emit_link_warning_##symbol[] \
-               __attribute__((used,section(".gnu.warning." #symbol))) = msg;
+               __attribute__((__used__,__section__(".gnu.warning." #symbol))) = msg;
 #endif
index 038ac7d535f0b60e0be4818d73e23bc788b007c2..6329bf4033111d1c66e9d25ea648726ff81ce9a1 100644 (file)
@@ -287,9 +287,12 @@ __asm__(".symver setproctitle_impl,setproctitle@@LIBBSD_0.5");
  * for code linking against that version, and change the default to use the
  * new version, so that new code depends on the implemented version. */
 #ifdef HAVE_TYPEOF
-extern typeof(setproctitle_impl) setproctitle_stub __attribute__((alias("setproctitle_impl")));
+extern __typeof__(setproctitle_impl)
+setproctitle_stub
+       __attribute__((__alias__("setproctitle_impl")));
 #else
-void setproctitle_stub(const char *fmt, ...)
-       __attribute__((alias("setproctitle_impl")));
+void
+setproctitle_stub(const char *fmt, ...)
+       __attribute__((__alias__("setproctitle_impl")));
 #endif
 __asm__(".symver setproctitle_stub,setproctitle@LIBBSD_0.2");
index 9360774694374b976514f39e3e09e4e6c8a35bec..2c5b6d0d6eaa37420ec22e2988e7dc2976572415 100644 (file)
@@ -49,4 +49,4 @@
  * move them from .ctors to .init_array.
  */
 void (*libbsd_init_func)(int argc, char *argv[], char *envp[])
-       __attribute__((section(".init_array"))) = setproctitle_init;
+       __attribute__((__section__(".init_array"))) = setproctitle_init;