[PATCH] Suppress sign-conversion warning from FD_SET
Paul Pluzhnikov
ppluzhnikov@google.com
Sat May 26 17:51:00 GMT 2012
On Fri, May 25, 2012 at 5:31 PM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:
> On Fri, May 25, 2012 at 2:23 PM, Paul Eggert <eggert@cs.ucla.edu> wrote:
>
>> Instead, how about using 'long int', since that's guaranteed
>> to work without munging the sign?
>
> Sounds good to me. I'll send an updated patch.
Here is the updated patch. Tested on Linux/x86_64.
Thanks,
--
Paul Pluzhnikov
2012-05-26 Paul Pluzhnikov <ppluzhnikov@google.com>
* debug/fdelt_chk.c (__fdelt_chk): Use signed long to avoid warning.
* misc/bits/select2.h (__FD_ELT): Adjust for above.
-------------- next part --------------
diff --git a/debug/fdelt_chk.c b/debug/fdelt_chk.c
index 5e06f8f..0dcbd15 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
@@ -19,9 +19,9 @@
unsigned long int
-__fdelt_chk (unsigned long int d)
+__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..07bd42f 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,13 +21,13 @@
#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 unsigned long int __fdelt_chk (long int __d);
+extern unsigned 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)) \
More information about the Libc-alpha
mailing list