This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Add cast in ctype.h macro to avoid gcc -pedantic warning.


Hi newlib,

A tiny patch to ctype.h.  I found that without this gcc will generate
a 'array subscript has type âcharâ' warnings when run with -pedantic
and -Wall.  I found this when compiling libssh which uses -pedandic
and -pedantic-errors.

cheers,
sam


---
 newlib/ChangeLog            | 5 +++++
 newlib/libc/include/ctype.h | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 0116fd1..ba4ac1f 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,8 @@
+2014-02-20  Sam Clegg  <sbc@chromium.org>
+
+       * newlib/libc/include/ctype.h (__ctype_lookup): Add extra cast to
+       prevent GCC warning when run with -Wall and -pedantic.
+
 2014-02-20  Corinna Vinschen  <vinschen@redhat.com>

        * libc/stdio/open_memstream.c (internal_open_memstream_r): Initialize
diff --git a/newlib/libc/include/ctype.h b/newlib/libc/include/ctype.h
index 56ad5ab..f4e8caf 100644
--- a/newlib/libc/include/ctype.h
+++ b/newlib/libc/include/ctype.h
@@ -54,7 +54,7 @@ extern        __IMPORT char   *__ctype_ptr__;
    Meanwhile, the real index to __ctype_ptr__+1 must be cast to int,
    since isalpha(0x100000001LL) must equal isalpha(1), rather than being
    an out-of-bounds reference on a 64-bit machine.  */
-#define __ctype_lookup(__c) ((__ctype_ptr__+sizeof(""[__c]))[(int)(__c)])
+#define __ctype_lookup(__c)
((__ctype_ptr__+sizeof(""[(int)(__c)]))[(int)(__c)])

 #define        isalpha(__c)    (__ctype_lookup(__c)&(_U|_L))
 #define        isupper(__c)    ((__ctype_lookup(__c)&(_U|_L))==_U)
-- 
1.9.0.rc1.175.g0b1dcb5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]