* [PATCH] Warning patrol - iconvdata/*
@ 2007-07-26 21:00 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2007-07-26 21:00 UTC (permalink / raw)
To: Ulrich Drepper; +Cc: Glibc hackers
Hi!
I spent some time today trying to get rid of a bunch of warnings.
This patch cures iconvdata/, mostly
warning:.*pointer targets in.*differ in signedness
warning:.*unused variable
and some
warning:.*may be used uninitialized in this function
Most of this is hopefully not controversial and one of the may be used
unitialized warnings even showed what looked like a real bug - see
ucs4_to_jisx0212 routine, where if cp[0] was != '\0', but cp[1], it would
return 2 as if both s[0] and s[1] were set, but only s[0] would be set
and s[1] left unitialized. By inspection I found the table fortunately
doesn't contain such strings, so it is pointless to special case it
(furthermore incorrectly), __jisx0212_from_ucs table either contains
both chars '\0', or none of them '\0'.
The only slightly controversial changes are in euc-jp-ms.c (the hunk
initializing endp) and in euc-kr.c - this is a gcc fault for not being
to determine very complex graphs which initialize the var in some leafs
and not in others, but IMHO the workaround is very cheap (in euc-kr.c
it is even on very rarely executed branch) and helps both gcc 4.1 and
gcc 4.3 not to warn about this. I have left a few places where
gcc 4.1 warns about may be unitialized vars, but gcc 4.3 no longer does.
Tested with gcc 4.1 and gcc 4.3 on x86_64-linux.
2007-07-26 Jakub Jelinek <jakub@redhat.com>
* iconvdata/gbk.c (BODY): Make buf and cp char instead of unsigned
char array resp. pointer.
* iconvdata/iso-2022-kr.c (BODY): Make buf unsigned char instead of
char array.
* iconvdata/cns11643.h (cns11643_to_ucs4): Change first argument
to const unsigned char **.
(ucs4_to_cns11643): Change second argument to unsigned char *.
* iconvdata/euc-tw.c (BODY): Change endp type to
const unsigned char *.
* iconvdata/iso-ir-165.h (ucs4_to_isoir165): Change second argument
to unsigned char *.
* iconvdata/ibm1008_420.c (LOOP_NEED_FLAGS): Don't define.
* iconvdata/iso-2022-cn.c (BODY): Change buf to unsigned char array.
* iconvdata/iso-2022-cn-ext.c (BODY): Change buf, tmpbuf, tmp
types to unsigned char pointers/arrays instead of char.
* iconvdata/jis0201.h (ucs4_to_jisx0201): Change second argument
to unsigned char *.
* iconvdata/jis0208.h (ucs4_to_jisx0208): Likewise.
* iconvdata/jis0212.h: Include assert.h.
(ucs4_to_jisx0212): Change second argument to unsigned char *.
assert that if cp[0] is not '\0', cp[1] is not '\0' either instead
of trying to handle that.
* iconvdata/euc-kr.c (euckr_from_ucs4): Initialize also cp[1] to
shut up a warning.
* iconvdata/euc-jp-ms.c (from_ucs4_lat1, from_ucs4_greek,
from_ucs4_cjk, from_ucs4_cjkcpt, from_ucs4_extra): Change type to
two dimensional const unsigned char arrays.
(BODY): Cast "" to (const unsigned char *) for assignment to cp.
Initialize endp to inptr to shut up a warning.
--- libc/iconvdata/gbk.c.jj 2007-07-26 09:43:30.000000000 +0200
+++ libc/iconvdata/gbk.c 2007-07-26 13:17:14.000000000 +0200
@@ -13213,8 +13213,8 @@ static const char __gbk_from_ucs4_tab12[
#define BODY \
{ \
uint32_t ch = get32 (inptr); \
- unsigned char buf[2]; \
- const unsigned char *cp = buf; \
+ char buf[2]; \
+ const char *cp = buf; \
\
if (ch <= L'\x7f') \
/* It's plain ASCII. */ \
--- libc/iconvdata/iso-2022-kr.c.jj 2002-06-28 23:13:14.000000000 +0200
+++ libc/iconvdata/iso-2022-kr.c 2007-07-26 13:17:14.000000000 +0200
@@ -1,5 +1,5 @@
/* Conversion module for ISO-2022-KR.
- Copyright (C) 1998, 1999, 2000-2002 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000-2002, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -223,7 +223,7 @@ enum
} \
else \
{ \
- char buf[2]; \
+ unsigned char buf[2]; \
size_t written; \
\
written = ucs4_to_ksc5601 (ch, buf, 2); \
--- libc/iconvdata/cns11643.h.jj 2003-06-11 23:40:42.000000000 +0200
+++ libc/iconvdata/cns11643.h 2007-07-26 13:17:14.000000000 +0200
@@ -1,5 +1,6 @@
/* Access functions for CNS 11643 handling.
- Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
+ Copyright (C) 1998,1999,2000,2001,2002,2003,2007
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -41,7 +42,7 @@ extern const uint32_t __cns11643l15_to_u
static inline uint32_t
__attribute ((always_inline))
-cns11643_to_ucs4 (const char **s, size_t avail, unsigned char offset)
+cns11643_to_ucs4 (const unsigned char **s, size_t avail, unsigned char offset)
{
unsigned char ch = *(*s);
unsigned char ch2;
@@ -142,7 +143,7 @@ extern const char __cns11643_from_ucs4p2
static inline size_t
__attribute ((always_inline))
-ucs4_to_cns11643 (uint32_t wch, char *s, size_t avail)
+ucs4_to_cns11643 (uint32_t wch, unsigned char *s, size_t avail)
{
unsigned int ch = (unsigned int) wch;
char buf[2];
--- libc/iconvdata/euc-tw.c.jj 2003-03-26 08:58:49.000000000 +0100
+++ libc/iconvdata/euc-tw.c 2007-07-26 13:17:14.000000000 +0200
@@ -1,5 +1,6 @@
/* Mapping tables for EUC-TW handling.
- Copyright (C) 1998, 1999, 2000-2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000-2002, 2003, 2007
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -74,7 +75,7 @@
if (ch == 0x8e) \
{ \
/* This is code set 2: CNS 11643, planes 1 to 16. */ \
- const char *endp = inptr + 1; \
+ const unsigned char *endp = inptr + 1; \
\
ch = cns11643_to_ucs4 (&endp, inend - inptr - 1, 0x80); \
\
--- libc/iconvdata/iso-ir-165.h.jj 2003-06-13 22:40:36.000000000 +0200
+++ libc/iconvdata/iso-ir-165.h 2007-07-26 13:17:14.000000000 +0200
@@ -1,6 +1,6 @@
/* Tables for conversion to and from ISO-IR-165.
converting from UCS using gaps.
- Copyright (C) 2000, 2003 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2003, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
@@ -72,7 +72,7 @@ extern const char __isoir165_from_tab[];
static inline size_t
__attribute ((always_inline))
-ucs4_to_isoir165 (uint32_t wch, char *s, size_t avail)
+ucs4_to_isoir165 (uint32_t wch, unsigned char *s, size_t avail)
{
unsigned int ch = (unsigned int) wch;
const char *cp;
--- libc/iconvdata/euc-jp-ms.c.jj 2003-08-14 10:37:44.000000000 +0200
+++ libc/iconvdata/euc-jp-ms.c 2007-07-26 18:40:11.000000000 +0200
@@ -1,5 +1,5 @@
/* Mapping tables for EUCJP-MS handling.
- Copyright (C) 1998,1999,2000,2001,2003 Free Software Foundation, Inc.
+ Copyright (C) 1998,1999,2000,2001,2003,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by MORIYAMA Masayuki <msyk@mtg.biglobe.ne.jp>, 2003.
@@ -158,7 +158,7 @@ static const uint16_t cjk_block_ibm[268]
/* 0x8ff4fd */ 0xfa2d, 0x9ed1
};
-static const char from_ucs4_lat1[256][2] =
+static const unsigned char from_ucs4_lat1[256][2] =
{
/* start = 0x0000, end = 0x00ff */
[ 0] = "\x00\x00", [ 1] = "\x01\x00", [ 2] = "\x02\x00",
@@ -244,7 +244,7 @@ static const char from_ucs4_lat1[256][2]
[ 255] = "\xab\x73"
};
-static const char from_ucs4_greek[864][2] =
+static const unsigned char from_ucs4_greek[864][2] =
{
/* start = 0x0100, end = 0x045f */
[ 0] = "\xaa\x27", [ 1] = "\xab\x27", [ 2] = "\xaa\x25",
@@ -351,7 +351,7 @@ static const char from_ucs4_greek[864][2
[ 860] = "\xa7\x7c", [ 862] = "\xa7\x7d", [ 863] = "\xa7\x7e"
};
-static const char from_ucs4_cjk[32662][2] =
+static const unsigned char from_ucs4_cjk[32662][2] =
{
/* start = 0x2010, end = 0x9fa5 */
[ 0] = "\xa1\xbe", [ 4] = "\xa1\xbd", [ 5] = "\xa1\xbd",
@@ -4556,7 +4556,7 @@ static const char from_ucs4_cjk[32662][2
[32661] = "\xed\x63"
};
-static const char from_ucs4_cjkcpt[261][2] =
+static const unsigned char from_ucs4_cjkcpt[261][2] =
{
/* start = 0xf929, end = 0xfa2d */
[ 0] = "\xf4\x45", [ 179] = "\xf4\x72", [ 229] = "\xf4\x34",
@@ -4573,7 +4573,7 @@ static const char from_ucs4_cjkcpt[261][
[ 260] = "\xf4\x7d"
};
-static const char from_ucs4_extra[229][2] =
+static const unsigned char from_ucs4_extra[229][2] =
{
/* start = 0xff01, end = 0xffe5 */
[ 0] = "\xa1\xaa", [ 1] = "\xf4\x2a", [ 2] = "\xa1\xf4",
@@ -4719,7 +4719,7 @@ static const char from_ucs4_extra[229][2
} \
else \
{ \
- const unsigned char *endp; \
+ const unsigned char *endp = inptr; \
int mblen = 1; \
\
if (__builtin_expect(ch == 0x8f, 0)) \
@@ -4758,7 +4758,7 @@ static const char from_ucs4_extra[229][2
ch = __UNKNOWN_10646_CHAR; \
} \
else \
- ch = __UNKNOWN_10646_CHAR; \
+ ch = __UNKNOWN_10646_CHAR; \
} \
else if (ch2 <= 0xfe) \
{ \
@@ -4766,7 +4766,7 @@ static const char from_ucs4_extra[229][2
endp = inptr + mblen; \
} \
else \
- ch = __UNKNOWN_10646_CHAR; \
+ ch = __UNKNOWN_10646_CHAR; \
} \
} \
else if (__builtin_expect(0xa1 <= ch, 1)) \
@@ -4804,10 +4804,10 @@ static const char from_ucs4_extra[229][2
endp = inptr + mblen; \
} \
else \
- ch = __UNKNOWN_10646_CHAR; \
+ ch = __UNKNOWN_10646_CHAR; \
} \
else \
- ch = __UNKNOWN_10646_CHAR; \
+ ch = __UNKNOWN_10646_CHAR; \
\
if (__builtin_expect (ch, 1) == 0) \
{ \
@@ -4880,7 +4880,7 @@ static const char from_ucs4_extra[229][2
{ \
UNICODE_TAG_HANDLER (ch, 4); \
/* Illegal character. */ \
- cp = ""; \
+ cp = (const unsigned char *) ""; \
} \
} \
else \
--- libc/iconvdata/ibm1008_420.c.jj 2005-09-30 00:06:32.000000000 +0200
+++ libc/iconvdata/ibm1008_420.c 2007-07-26 13:17:14.000000000 +0200
@@ -176,7 +176,6 @@ static const char __from_ibm420_to_ibm10
*outptr++ = ch; \
++inptr; \
}
-#define LOOP_NEED_FLAGS
#include <iconv/loop.c>
@@ -190,7 +189,6 @@ static const char __from_ibm420_to_ibm10
*outptr++ = ch; \
++inptr; \
}
-#define LOOP_NEED_FLAGS
#include <iconv/loop.c>
/* Now define the toplevel functions. */
--- libc/iconvdata/iso-2022-cn.c.jj 2002-06-28 23:13:14.000000000 +0200
+++ libc/iconvdata/iso-2022-cn.c 2007-07-26 13:17:14.000000000 +0200
@@ -1,5 +1,5 @@
/* Conversion module for ISO-2022-CN.
- Copyright (C) 1999, 2000-2002 Free Software Foundation, Inc.
+ Copyright (C) 1999, 2000-2002, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1999.
@@ -263,7 +263,7 @@ enum
} \
else \
{ \
- char buf[2]; \
+ unsigned char buf[2]; \
int used; \
size_t written = 0; \
\
--- libc/iconvdata/iso-2022-cn-ext.c.jj 2004-03-07 10:33:54.000000000 +0100
+++ libc/iconvdata/iso-2022-cn-ext.c 2007-07-26 13:17:14.000000000 +0200
@@ -1,5 +1,5 @@
/* Conversion module for ISO-2022-CN-EXT.
- Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2000-2002, 2004, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
@@ -304,8 +304,8 @@ enum
{ \
/* This is a character from CNS 11643 plane 3 or higher. \
XXX Currently GB7590 and GB13132 are not supported. */ \
- char buf[3]; \
- const char *tmp = buf; \
+ unsigned char buf[3]; \
+ const unsigned char *tmp = buf; \
\
buf[1] = inptr[2]; \
buf[2] = inptr[3]; \
@@ -426,7 +426,7 @@ enum
} \
else \
{ \
- char buf[2]; \
+ unsigned char buf[2]; \
int used; \
\
if (set == GB2312_set || ((ann & SO_ann) != CNS11643_1_ann \
@@ -456,7 +456,7 @@ enum
used = CNS11643_2_set; \
else \
{ \
- char tmpbuf[3]; \
+ unsigned char tmpbuf[3]; \
\
switch (0) \
{ \
--- libc/iconvdata/jis0208.h.jj 2005-09-23 20:47:44.000000000 +0200
+++ libc/iconvdata/jis0208.h 2007-07-26 13:17:14.000000000 +0200
@@ -1,5 +1,6 @@
/* Access functions for JISX0208 conversion.
- Copyright (C) 1997,1998,1999,2000,2003,2005 Free Software Foundation, Inc.
+ Copyright (C) 1997,1998,1999,2000,2003,2005,2007
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -75,7 +76,7 @@ jisx0208_to_ucs4 (const unsigned char **
static inline size_t
__attribute ((always_inline))
-ucs4_to_jisx0208 (uint32_t wch, char *s, size_t avail)
+ucs4_to_jisx0208 (uint32_t wch, unsigned char *s, size_t avail)
{
unsigned int ch = (unsigned int) wch;
const char *cp;
--- libc/iconvdata/jis0201.h.jj 2003-06-11 23:40:42.000000000 +0200
+++ libc/iconvdata/jis0201.h 2007-07-26 13:17:14.000000000 +0200
@@ -1,5 +1,5 @@
/* Access functions for JISX0201 conversion.
- Copyright (C) 1997, 1998, 1999, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999, 2003, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -40,9 +40,9 @@ jisx0201_to_ucs4 (char ch)
static inline size_t
__attribute ((always_inline))
-ucs4_to_jisx0201 (uint32_t wch, char *s)
+ucs4_to_jisx0201 (uint32_t wch, unsigned char *s)
{
- char ch;
+ unsigned char ch;
if (wch == 0xa5)
ch = '\x5c';
--- libc/iconvdata/jis0212.h.jj 2003-06-11 23:40:42.000000000 +0200
+++ libc/iconvdata/jis0212.h 2007-07-26 18:33:35.000000000 +0200
@@ -1,5 +1,5 @@
/* Access functions for JISX0212 conversion.
- Copyright (C) 1997, 1998, 1999, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998, 1999, 2003, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
@@ -21,6 +21,7 @@
#ifndef _JIS0212_H
#define _JIS0212_H 1
+#include <assert.h>
#include <gconv.h>
#include <stdint.h>
@@ -79,7 +80,7 @@ jisx0212_to_ucs4 (const unsigned char **
static inline size_t
__attribute ((always_inline))
-ucs4_to_jisx0212 (uint32_t wch, char *s, size_t avail)
+ucs4_to_jisx0212 (uint32_t wch, unsigned char *s, size_t avail)
{
const struct jisx0212_idx *rp = __jisx0212_from_ucs_idx;
unsigned int ch = (unsigned int) wch;
@@ -98,14 +99,11 @@ ucs4_to_jisx0212 (uint32_t wch, char *s,
return __UNKNOWN_10646_CHAR;
s[0] = cp[0];
- if (cp[1] != '\0')
- {
- if (avail < 2)
- return 0;
-
- s[1] = cp[1];
- }
+ assert (cp[1] != '\0');
+ if (avail < 2)
+ return 0;
+ s[1] = cp[1];
return 2;
}
--- libc/iconvdata/euc-kr.c.jj 2007-07-26 14:06:38.000000000 +0200
+++ libc/iconvdata/euc-kr.c 2007-07-26 14:06:55.000000000 +0200
@@ -1,5 +1,6 @@
/* Mapping tables for EUC-KR handling.
- Copyright (C) 1998, 1999, 2000-2002, 2003 Free Software Foundation, Inc.
+ Copyright (C) 1998, 1999, 2000-2002, 2003, 2007
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jungshik Shin <jshin@pantheon.yale.edu>
and Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -46,7 +47,7 @@ euckr_from_ucs4 (uint32_t ch, unsigned c
cp[1] |= 0x80;
}
else
- cp[0] = '\0';
+ cp[0] = cp[1] = '\0';
}
else
{
Jakub
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-07-26 21:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-26 21:00 [PATCH] Warning patrol - iconvdata/* Jakub Jelinek
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).