This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 06/13] Installed header hygiene (BZ#20366): Macros used in #if without checking whether they are defined.
- From: Carlos O'Donell <carlos at redhat dot com>
- To: Zack Weinberg <zackw at panix dot com>, libc-alpha at sourceware dot org
- Cc: joseph at codesourcery dot com
- Date: Wed, 21 Sep 2016 14:02:04 -0400
- Subject: Re: [PATCH 06/13] Installed header hygiene (BZ#20366): Macros used in #if without checking whether they are defined.
- Authentication-results: sourceware.org; auth=none
- References: <20160830011645.25769-1-zackw@panix.com> <20160830011645.25769-2-zackw@panix.com> <20160830011645.25769-3-zackw@panix.com> <20160830011645.25769-4-zackw@panix.com> <20160830011645.25769-5-zackw@panix.com> <20160830011645.25769-6-zackw@panix.com> <20160830011645.25769-7-zackw@panix.com>
On 08/29/2016 09:16 PM, Zack Weinberg wrote:
> sysdeps/unix/sysv/linux/bits/socket.h wants to know whether __flexarr
> will produce a real flexible array member -- specifically, one that
> doesn't alter sizeof(the structure containing it). Rather than make
> its approximation to that condition any more complicated, I added a
> new macro to sys/cdefs.h, __flexarr_is_fake, which reveals exactly
> what it wants to know. I also took the opportunity to flatten the
> rather messy conditional nest defining __flexarr.
>
> It seems to me that _LIBC should not appear in installed headers, but
> avoiding that for argp specifically would require more surgery than
> feels appropriate for this patch set. It's possible that
> "#ifdef _LIBC" would be sufficient, but I wanted to be conservative.
>
> * argp/argp.h: Check whether _LIBC is defined before expanding it.
> * posix/glob.h: Check whether __USE_XOPEN2K8 is defined instead
> of expanding it.
>
> * misc/sys/cdefs.h: Tidy up conditional nest defining __flexarr.
> Define __flexarr_is_fake when the compiler does not support
> flexible array members.
> * sysdeps/unix/sysv/linux/bits/socket.h: Use __flexarr_is_fake
> in definitions of struct cmsghdr and CMSG_DATA.
This patch fails to follow the Macro API best practice that all macros
be defined and that we should check for their values not their defined-ness
which can introduce subtle errors e.g. __flexarr_is_fake.
Please see:
https://sourceware.org/glibc/wiki/Wundef
At a high level I would expect _LIBC to always be defined as either 0 or 1.
--
Cheers,
Carlos.