public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] linux-generic: avoid "redefined" warnings for open_not_cancel{,_2}
@ 2012-05-15 20:20 Chris Metcalf
  2012-05-15 20:23 ` Roland McGrath
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Metcalf @ 2012-05-15 20:20 UTC (permalink / raw)
  To: libc-ports, Roland McGrath

In general we just try to include <not-cancel.h> once, thus avoiding
any issues with redefinition.

However, the getaddrinfo sources are somewhat tangled, and .c files
include each other to get the final result.  Each .c file currently has
its own include of <not-cancel.h>.  While you could properly re-factor
this for the case of gai.c, the posix/tst-rfc3484.c tests directly include
one of the sub-files (sysdeps/posix/getaddrinfo.c), and it starts to
feel fragile.

We could also use a multiple-inclusion guard here, but since this is an
overriding sysdeps file that includes another sysdeps file, that also
feels fragile unless we spell out the full filename in the inclusion
guard, which feels clunky.

Just doing an undef seems simplest here.
---
 ChangeLog.linux-generic                      |    6 ++++++
 sysdeps/unix/sysv/linux/generic/not-cancel.h |    4 ++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/ChangeLog.linux-generic b/ChangeLog.linux-generic
index 9f563e3..ec991c8 100644
--- a/ChangeLog.linux-generic
+++ b/ChangeLog.linux-generic
@@ -1,3 +1,9 @@
+2012-05-15  Chris Metcalf  <cmetcalf@tilera.com>
+
+	* sysdeps/unix/sysv/linux/generic/not-cancel.h
+        (open_not_cancel, open_not_cancel_2): undef before including
+        the standard Linux not-cancel.h.
+
 2012-05-14  Chris Metcalf  <cmetcalf@tilera.com>
 
 	* sysdeps/unix/sysv/linux/generic/bits/stat.h,
diff --git a/sysdeps/unix/sysv/linux/generic/not-cancel.h b/sysdeps/unix/sysv/linux/generic/not-cancel.h
index ae46e16..421f863 100644
--- a/sysdeps/unix/sysv/linux/generic/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/generic/not-cancel.h
@@ -17,7 +17,11 @@
    License along with the GNU C Library.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+/* If <not-cancel.h> is included a second time, avoid warnings.  */
+#undef open_not_cancel
+#undef open_not_cancel_2
 #include <sysdeps/unix/sysv/linux/not-cancel.h>
+
 #include <fcntl.h>
 
 /* Uncancelable open with openat.  */
-- 
1.6.5.2

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] linux-generic: avoid "redefined" warnings for open_not_cancel{,_2}
  2012-05-15 20:20 [PATCH] linux-generic: avoid "redefined" warnings for open_not_cancel{,_2} Chris Metcalf
@ 2012-05-15 20:23 ` Roland McGrath
  2012-05-15 20:38   ` Chris Metcalf
  0 siblings, 1 reply; 5+ messages in thread
From: Roland McGrath @ 2012-05-15 20:23 UTC (permalink / raw)
  To: Chris Metcalf; +Cc: libc-ports

That's a kludge.  Just use a guard.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] linux-generic: avoid "redefined" warnings for open_not_cancel{,_2}
  2012-05-15 20:23 ` Roland McGrath
@ 2012-05-15 20:38   ` Chris Metcalf
  2012-05-15 20:46     ` Roland McGrath
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Metcalf @ 2012-05-15 20:38 UTC (permalink / raw)
  To: Roland McGrath; +Cc: libc-ports

On 5/15/2012 4:22 PM, Roland McGrath wrote:
> That's a kludge.  Just use a guard.

Fair enough, but my concern was: what guard?  Should I be very explicit and use

#ifndef _SYSDEPS_UNIX_SYSV_LINUX_GENERIC_NOT_CANCEL_H
# define _SYSDEPS_UNIX_SYSV_LINUX_GENERIC_NOT_CANCEL_H
...
#endif

The problem is the internal recursive include of another "not-cancel.h",
which would fail to work properly if the included file also ended up using
the same guard.  That seems to rule out _NOT_CANCEL_H, for example.

You could imagine #including the recursive "not-cancel.h" before
#define'ing the guard, but that also seems like a kludge.  :-)

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] linux-generic: avoid "redefined" warnings for open_not_cancel{,_2}
  2012-05-15 20:38   ` Chris Metcalf
@ 2012-05-15 20:46     ` Roland McGrath
  2012-05-15 20:50       ` Chris Metcalf
  0 siblings, 1 reply; 5+ messages in thread
From: Roland McGrath @ 2012-05-15 20:46 UTC (permalink / raw)
  To: Chris Metcalf; +Cc: libc-ports

> Fair enough, but my concern was: what guard?  Should I be very explicit and use
> 
> #ifndef _SYSDEPS_UNIX_SYSV_LINUX_GENERIC_NOT_CANCEL_H
> # define _SYSDEPS_UNIX_SYSV_LINUX_GENERIC_NOT_CANCEL_H
> ...
> #endif

That is OK but we've usually been not quite so verbose and just use a name
that is sufficiently unique, e.g. _LINUX_GENERIC_NOT_CANCEL_H.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] linux-generic: avoid "redefined" warnings for open_not_cancel{,_2}
  2012-05-15 20:46     ` Roland McGrath
@ 2012-05-15 20:50       ` Chris Metcalf
  0 siblings, 0 replies; 5+ messages in thread
From: Chris Metcalf @ 2012-05-15 20:50 UTC (permalink / raw)
  To: Roland McGrath; +Cc: libc-ports

On 5/15/2012 4:46 PM, Roland McGrath wrote:
>> Fair enough, but my concern was: what guard?  Should I be very explicit and use
>>
>> #ifndef _SYSDEPS_UNIX_SYSV_LINUX_GENERIC_NOT_CANCEL_H
>> # define _SYSDEPS_UNIX_SYSV_LINUX_GENERIC_NOT_CANCEL_H
>> ...
>> #endif
> That is OK but we've usually been not quite so verbose and just use a name
> that is sufficiently unique, e.g. _LINUX_GENERIC_NOT_CANCEL_H.

OK, I'll commit the obvious change using that name.  Thanks.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-05-15 20:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-15 20:20 [PATCH] linux-generic: avoid "redefined" warnings for open_not_cancel{,_2} Chris Metcalf
2012-05-15 20:23 ` Roland McGrath
2012-05-15 20:38   ` Chris Metcalf
2012-05-15 20:46     ` Roland McGrath
2012-05-15 20:50       ` Chris Metcalf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).