[apparmor] [patch] C tools: rename __unused macro

Christian Boltz apparmor at cboltz.de
Thu Sep 11 17:49:36 UTC 2014


Hello,

Am Donnerstag, 11. September 2014 schrieb Steve Beattie:
> Bug: https://bugzilla.novell.com/show_bug.cgi?id=895495
> 
> We define the __unused macro as a shortcut for __attribute__((unused))
> to quiet compiler warnings for functions where an argument is unused,
> for whatever reason. However, on 64 bit architectures, older glibc's
> bits/stat.h header defines an array variable with the name __unused
> that collides with our macro and causes the parser to fail to build,
> because the resulting macro expansion generates invalid C code.
> 
> This patch renames the macro to __aa_unused, 

>From https://bugzilla.novell.com/show_bug.cgi?id=895495#c4

    it's invalid to use the implementation namespace (two leading 
    underscores).

That's exactly what we have - with or without your patch. The little 
difference is that your patch adds an additional "aa" to make it less 
likely to clash with existing names.

Wouldn't it be a better idea to use something that does _not_ start with 
two underscores?


> as well as getting rid of it from the mod_apparmor codebase, where it 
> is unneeded.

Good idea!

> Index: b/changehat/mod_apparmor/mod_apparmor.c
> ===================================================================
> --- a/changehat/mod_apparmor/mod_apparmor.c
> +++ b/changehat/mod_apparmor/mod_apparmor.c
> @@ -29,9 +29,6 @@
> 
>  #include <unistd.h>
>  
>  /* #define DEBUG */
> 
> -#ifndef __unused
> -#define __unused __attribute__((unused))
> -#endif
> 
>  /* should the following be configurable? */
>  #define DEFAULT_HAT "HANDLING_UNTRUSTED_INPUT"

Only for the mod_apparmor.c part:
Acked-by: Christian Boltz <apparmor at cboltz.de>

For the renaming to __aa_unused, I'd send you a NAK if I were more 
familiar with C ;-)


Regards,

Christian Boltz
-- 
<intrigeri> there's enough of "curl | sudo bash ..." around..
* mhayden hides under his desk
[from #apparmor]




More information about the AppArmor mailing list