This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/3] sys/cdefs.h: export __attribute_alloc_size__
- From: Roland McGrath <roland at hack dot frob dot com>
- To: Mike Frysinger <vapier at gentoo dot org>
- Cc: libc-alpha at sourceware dot org
- Date: Wed, 23 Jan 2013 15:09:31 -0800 (PST)
- Subject: Re: [PATCH 2/3] sys/cdefs.h: export __attribute_alloc_size__
- References: <1356817894-16212-1-git-send-email-vapier@gentoo.org><1356908471-13739-1-git-send-email-vapier@gentoo.org><1356908471-13739-2-git-send-email-vapier@gentoo.org>
__VA_ARGS__ is C99 and so gets warnings under -std=c89 -pedantic.
We should avoid it rather than relying on the system-header exception.
Here it's trivial just to do:
# define __attribute_alloc_size__(params) \
__attribute__ ((__alloc_size__ params))
extern void *blah (size_t, size_t) __attribute_alloc_size__ ((1, 2));
> * include/sys/cdefs.h (__attribute_alloc_size): Delete.
Say, "Macro removed."
> * misc/sys/cdefs.h (__attribute_alloc_size__): Define.
Say, "New macro."
> +/* Tell gcc where to find the size param for malloc funcs. */
Use full English words, correct capitalization for things like proper nouns
(i.e. "GCC"), and a fully coherent explanation. Here I'd write:
/* Tell the compiler which arguments to an allocation function
indicate the size of the allocation. */
> +# define __attribute_alloc_size__(...) \
> + __attribute__ ((__alloc_size__ (__VA_ARGS__)))
The norm here is to indent the continuation line just two spaces.
A reasonable alternative is two spaces from "define". Three spaces
from "define" is not compatible with our style.
> +# define __attribute_alloc_size__(...) /* Ignore */
It's preferable to use a tab (or multiple tabs, if there is something
nearby to line up with) between the lhs and rhs of a macro definition.
The comment is not really necessary at all here, but if it's there
it should read "/* Ignore. */".
The contrary style examples in the file are errors to be fixed,
not models to be followed.
The change is OK with those issues fixed.
Thanks,
Roland