From f6dda4587cd95e7020cfdb3ecf0c7bad6b9baa9c Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Tue, 14 Oct 2025 12:38:08 +0300 Subject: [PATCH] m4/dovecot.m4, lib: Add ATTR_NONSTRING macro --- m4/dovecot.m4 | 11 ++++++++++- src/lib/macros.h | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/m4/dovecot.m4 b/m4/dovecot.m4 index 3e1aadf004..6e6bdc2101 100644 --- a/m4/dovecot.m4 +++ b/m4/dovecot.m4 @@ -6,7 +6,7 @@ dnl This file is free software; the authors give dnl unlimited permission to copy and/or distribute it, with or without dnl modifications, as long as this notice is preserved. -# serial 44 +# serial 45 dnl dnl Check for support for D_FORTIFY_SOURCE=2 @@ -79,6 +79,15 @@ AC_DEFUN([DC_DOVECOT_CFLAGS],[ dnl gcc4 AM_CFLAGS="$AM_CFLAGS -Wstrict-aliasing=2" ],[]) + + old_cflags=$CFLAGS + CFLAGS="$CFLAGS -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + const unsigned char foo[4] __attribute__((nonstring)) = "1234"; + ]], [[]])],[ + AC_DEFINE(HAVE_ATTR_NONSTRING,, [define if you have nonstring attribute]) + ]) + CFLAGS="$old_cflags" ]) ]) diff --git a/src/lib/macros.h b/src/lib/macros.h index b7c1adc789..ebc1bf23f8 100644 --- a/src/lib/macros.h +++ b/src/lib/macros.h @@ -127,6 +127,11 @@ #else # define ATTR_DEPRECATED(str) #endif +#ifdef HAVE_ATTR_NONSTRING +# define ATTR_NONSTRING __attribute__((nonstring)) +#else +# define ATTR_NONSTRING +#endif /* Macros to provide type safety for callback functions' context parameters. This is used like: -- 2.47.3