]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
charset.c: fix -Wpointer-sign
authorPedro Alves <palves@redhat.com>
Thu, 7 Mar 2013 19:10:46 +0000 (19:10 +0000)
committerPedro Alves <palves@redhat.com>
Thu, 7 Mar 2013 19:10:46 +0000 (19:10 +0000)
$ make WERROR_CFLAGS="-Wpointer-sign -Werror" charset.o 2>&1 1>/dev/null
../../src/gdb/charset.c: In function ‘wchar_iterate’:
../../src/gdb/charset.c:665:13: error: pointer targets in assignment differ in signedness [-Werror=pointer-sign]
../../src/gdb/charset.c:691:13: error: pointer targets in assignment differ in signedness [-Werror=pointer-sign]
../../src/gdb/charset.c:706:12: error: pointer targets in assignment differ in signedness [-Werror=pointer-sign]

The encoding conversion code works with gdb_byte arrays as the generic
buffers that hold strings of any encoding/width.  Changing the type of
this field to gdb_byte* removes the need for one cast, and makes
everything work with the same types.  That's good -- WRT to strings,
"char *" is (almost) consistently throughout GDB only used for
ascii-ish strings.

gdb/
2013-03-07  Pedro Alves  <palves@redhat.com>

* charset.c (struct wchar_iterator) <input>: Change type to 'const
gdb_byte *'.
(make_wchar_iterator): Remove cast to char*.
(wchar_iterate): Change type of local.

gdb/ChangeLog
gdb/charset.c

index ceeecb705eeca263f3b5615346f28e6eb2f4dfa6..a57e2c1f326a1fce4fa954a1180eb4c105ce3683 100644 (file)
@@ -1,3 +1,10 @@
+2013-03-07  Pedro Alves  <palves@redhat.com>
+
+       * charset.c (struct wchar_iterator) <input>: Change type to 'const
+       gdb_byte *'.
+       (make_wchar_iterator): Remove cast to char*.
+       (wchar_iterate): Change type of local.
+
 2013-03-07  Pedro Alves  <palves@redhat.com>
 
        * regcache.c (regcache_xmalloc_1): Call XCALLOC with signed char
index 165f90fb97b92c773c265b9a4ffed8ec2b8a22ff..4cd6f205a7d6f9eee61cc8483b3b74cd5e916534 100644 (file)
@@ -571,7 +571,7 @@ struct wchar_iterator
   iconv_t desc;
 
   /* The input string.  This is updated as convert characters.  */
-  char *input;
+  const gdb_byte *input;
   /* The number of bytes remaining in the input.  */
   size_t bytes;
 
@@ -597,7 +597,7 @@ make_wchar_iterator (const gdb_byte *input, size_t bytes,
 
   result = XNEW (struct wchar_iterator);
   result->desc = desc;
-  result->input = (char *) input;
+  result->input = input;
   result->bytes = bytes;
   result->width = width;
 
@@ -641,7 +641,7 @@ wchar_iterate (struct wchar_iterator *iter,
   while (iter->bytes > 0)
     {
       char *outptr = (char *) &iter->out[0];
-      char *orig_inptr = iter->input;
+      const gdb_byte *orig_inptr = iter->input;
       size_t orig_in = iter->bytes;
       size_t out_avail = out_request * sizeof (gdb_wchar_t);
       size_t num;