[apparmor] [patch] C tools: rename __unused macro
Steve Beattie
steve at nxnw.org
Tue Sep 23 01:55:26 UTC 2014
On Thu, Sep 11, 2014 at 07:49:36PM +0200, Christian Boltz wrote:
> 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?
Yes and no. Yes because it could potentially clash with some
compiler/system symbol that begins with __aa_, which, while unlikely is
possible. No, because the use of underscores gives a hint to a code
reader that it has a special meaning, and isn't just a weird complex
type or variable.
Anyway, attached is an updated version of the patch that converts it to
aa_unused, as well as making the use of it consistent by having it be
the last part of the variable declaration; i.e. "type var aa_unused",
rather than "aa_unused type var" or "type aa_unused var".
A second patch is attached that applies on top of that and adds a
second macro function called aa_unused_arg(), that wraps the variable
declaration name. so the above would be 'type aa_unused_arg(var)'.
I don't have a strong feeling either way about the second patch.
Both are Signed-off-by: Steve Beattie <steve at nxnw.org>.
Thanks.
--
Steve Beattie
<sbeattie at ubuntu.com>
http://NxNW.org/~steve/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: userspace-adjust_unused_attribute.patch
Type: text/x-diff
Size: 10365 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20140922/6c7ab93f/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: parser-make_aa_unused_arg_macro.patch
Type: text/x-diff
Size: 8892 bytes
Desc: not available
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20140922/6c7ab93f/attachment-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/apparmor/attachments/20140922/6c7ab93f/attachment.pgp>
More information about the AppArmor
mailing list