This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Suppress sign-conversion warning from FD_SET
- From: Paul Eggert <eggert at cs dot ucla dot edu>
- To: Carlos O'Donell <carlos_odonell at mentor dot com>
- Cc: Mike Frysinger <vapier at gentoo dot org>, libc-alpha at sourceware dot org, Paul Pluzhnikov <ppluzhnikov at google dot com>,Pedro Alves <palves at redhat dot com>, yunlian at google dot com
- Date: Wed, 13 Jun 2012 07:53:29 -0700
- Subject: Re: [PATCH] Suppress sign-conversion warning from FD_SET
- References: <20120525162702.053F819076C@elbrus2.mtv.corp.google.com> <4FC49810.5090203@redhat.com> <CALoOobOMaSQNOHudNhMQxOu+6Wd3Tsw3Ye=Hs_R_-5Rx19tv_Q@mail.gmail.com> <201206130036.47712.vapier@gentoo.org> <4FD8A718.5070309@mentor.com>
On 06/13/2012 07:43 AM, Carlos O'Donell wrote:
> Could you please repost the final patch and I'll ACK that?
Here it is, taken from the attachment to Paul Pluzhnikov's email
<http://sourceware.org/ml/libc-alpha/2012-05/msg01879.html>.
I just now wrote the ChangeLog entry.
2012-06-13 Paul Pluzhnikov <ppluzhnikov@google.com>
Suppress sign-conversion warning from FD_SET.
See <http://sourceware.org/ml/libc-alpha/2012-05/msg01794.html>.
* debug/fdelt_chk.c (__fdelt_chk): Accept and return long int,
not unsigned long int.
* misc/bits/select2.h (__fdelt_chk, __fdelt_warn, __FD_ELT): Likewise.
diff --git a/debug/fdelt_chk.c b/debug/fdelt_chk.c
index 5e06f8f..ded3f2f 100644
--- a/debug/fdelt_chk.c
+++ b/debug/fdelt_chk.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2011 Free Software Foundation, Inc.
+/* Copyright (C) 2011, 2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -18,10 +18,10 @@
#include <sys/select.h>
-unsigned long int
-__fdelt_chk (unsigned long int d)
+long int
+__fdelt_chk (long int d)
{
- if (d >= FD_SETSIZE)
+ if (d < 0 || d >= FD_SETSIZE)
__chk_fail ();
return d / __NFDBITS;
diff --git a/misc/bits/select2.h b/misc/bits/select2.h
index 9679925..76ae368 100644
--- a/misc/bits/select2.h
+++ b/misc/bits/select2.h
@@ -1,5 +1,5 @@
/* Checking macros for select functions.
- Copyright (C) 2011 Free Software Foundation, Inc.
+ Copyright (C) 2011, 2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -21,14 +21,15 @@
#endif
/* Helper functions to issue warnings and errors when needed. */
-extern unsigned long int __fdelt_chk (unsigned long int __d);
-extern unsigned long int __fdelt_warn (unsigned long int __d)
+extern long int __fdelt_chk (long int __d);
+extern long int __fdelt_warn (long int __d)
__warnattr ("bit outside of fd_set selected");
#undef __FD_ELT
#define __FD_ELT(d) \
__extension__ \
- ({ unsigned long int __d = (d); \
+ ({ long int __d = (d); \
(__builtin_constant_p (__d) \
- ? (__d >= __FD_SETSIZE \
- ? __fdelt_warn (__d) : (__d / __NFDBITS)) \
+ ? (0 <= __d && __d < __FD_SETSIZE \
+ ? (__d / __NFDBITS) \
+ : __fdelt_warn (__d)) \
: __fdelt_chk (__d)); })