PATCH] OS: Add some noreturn and printf compiler attributes where appropriate

Alan Coopersmith alan.coopersmith at oracle.com
Sat Mar 27 18:39:15 PDT 2010


Jeremy Huddleston wrote:
> Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>
> ---
>  include/os.h |   28 +++++++++++++---------------
>  os/log.c     |    4 +---
>  2 files changed, 14 insertions(+), 18 deletions(-)
> 
> diff --git a/include/os.h b/include/os.h
> index 453ab82..957fc74 100644
> --- a/include/os.h
> +++ b/include/os.h
> @@ -83,6 +83,15 @@ typedef struct _NewClientRec *NewClientPtr;
>  #include <stdio.h>
>  #include <stdarg.h>
>  
> +/* XXX Need to check which GCC versions have the format(printf) attribute. */
> +#if defined(__GNUC__) && (__GNUC__ > 2)
> +#define _printf_attribute(a,b) __attribute((format(__printf__,a,b)))
> +#define _noreturn_attribute __attribute((noreturn))

Why not just use _X_ATTRIBUTE_PRINTF from X11/Xfuncproto.h ?
Unfortunately there's no noreturn there, but we could add it.

(Obviously I'm biased towards having one place to update as the
 Sun compilers are growing __attribute compatibility for various
 of the attributes in new releases.)

-- 
	-Alan Coopersmith-        alan.coopersmith at oracle.com
	 Oracle Solaris Platform Engineering: X Window System



More information about the xorg-devel mailing list