Fix -Wpointer-sign around strings/encoding conversions.
authorPedro Alves <palves@redhat.com>
Thu, 7 Mar 2013 19:24:32 +0000 (19:24 +0000)
committerPedro Alves <palves@redhat.com>
Thu, 7 Mar 2013 19:24:32 +0000 (19:24 +0000)
Trimmed for brevity:

$ make WERROR_CFLAGS="-Wpointer-sign -Werror" c-lang.o expprint.o utils.o valprint.o varobj.o -k 2>&1 1>/dev/null
../../src/gdb/c-lang.c: In function ‘parse_one_string’:
../../src/gdb/c-lang.c:540:8: error: pointer targets in passing argument 3 of ‘convert_between_encodings’ differ in signedness [-Werror=pointer-sign]
In file included from ../../src/gdb/c-lang.c:30:0:
../../src/gdb/charset.h:64:6: note: expected ‘const gdb_byte *’ but argument is of type ‘char *’

../../src/gdb/expprint.c: In function ‘print_subexp_standard’:
../../src/gdb/expprint.c:205:2: error: pointer targets in passing argument 3 of ‘current_language->la_printstr’ differ in signedness [-Werror=pointer-sign]
../../src/gdb/expprint.c:205:2: note: expected ‘const gdb_byte *’ but argument is of type ‘char *’

cc1: all warnings being treated as errors
make: *** [expprint.o] Error 1
../../src/gdb/utils.c: In function ‘host_char_to_target’:
../../src/gdb/utils.c:1474:9: error: pointer targets in passing argument 3 of ‘convert_between_encodings’ differ in signedness [-Werror=pointer-sign]

../../src/gdb/varobj.c: In function ‘value_get_print_value’:
../../src/gdb/varobj.c:2934:8: error: pointer targets in return differ in signedness [-Werror=pointer-sign]
../../src/gdb/varobj.c:2968:12: error: pointer targets in assignment differ in signedness [-Werror=pointer-sign]
../../src/gdb/varobj.c:2971:3: error: pointer targets in return differ in signedness [-Werror=pointer-sign]
cc1: all warnings being treated as errors
make: *** [varobj.o] Error 1

As with the previous patch, the encoding conversion code works with
gdb_byte arrays as the generic buffers that hold strings of any
encoding/width.  This patch adds casts where appropriate.

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

* c-lang.c (parse_one_string): Cast argument to gdb_byte *.
* expprint.c (print_subexp_standard): Likewise.
* utils.c (host_char_to_target): Likewise.
* valprint.c (generic_emit_char, generic_printstr): Likewise.
* varobj.c (value_get_print_value): Change type of local to char*.
Cast it gdb_byte * in call to language printer.

gdb/ChangeLog
gdb/c-lang.c
gdb/expprint.c
gdb/utils.c
gdb/valprint.c
gdb/varobj.c

index a57e2c1f326a1fce4fa954a1180eb4c105ce3683..c8787fc454f2b17db9adf7a0761881ed980fd92c 100644 (file)
@@ -1,3 +1,12 @@
+2013-03-07  Pedro Alves  <palves@redhat.com>
+
+       * c-lang.c (parse_one_string): Cast argument to gdb_byte *.
+       * expprint.c (print_subexp_standard): Likewise.
+       * utils.c (host_char_to_target): Likewise.
+       * valprint.c (generic_emit_char, generic_printstr): Likewise.
+       * varobj.c (value_get_print_value): Change type of local to char*.
+       Cast it gdb_byte * in call to language printer.
+
 2013-03-07  Pedro Alves  <palves@redhat.com>
 
        * charset.c (struct wchar_iterator) <input>: Change type to 'const
index 91cb21ecd2e416492412738119f9f27017a0bd25..1c1d60b4f53578e89e0094adc3cbe44b374d6122 100644 (file)
@@ -536,7 +536,7 @@ parse_one_string (struct obstack *output, char *data, int len,
       /* If we saw a run of characters, convert them all.  */
       if (p > data)
        convert_between_encodings (host_charset (), dest_charset,
-                                  data, p - data, 1,
+                                  (gdb_byte *) data, p - data, 1,
                                   output, translit_none);
       /* If we saw an escape, convert it.  */
       if (p < limit)
index 4dd2d7c9f7285fbcd41cfea3ae1d75574e25a986..69055348cf64993e4f3a640ae9132d8968885f62 100644 (file)
@@ -203,7 +203,8 @@ print_subexp_standard (struct expression *exp, int *pos,
           additional parameter to LA_PRINT_STRING.  -fnf */
        get_user_print_options (&opts);
        LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
-                        &exp->elts[pc + 2].string, nargs, NULL, 0, &opts);
+                        (gdb_byte *) &exp->elts[pc + 2].string, nargs,
+                        NULL, 0, &opts);
       }
       return;
 
@@ -217,7 +218,8 @@ print_subexp_standard (struct expression *exp, int *pos,
        fputs_filtered ("@\"", stream);
        get_user_print_options (&opts);
        LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
-                        &exp->elts[pc + 2].string, nargs, NULL, 0, &opts);
+                        (gdb_byte *) &exp->elts[pc + 2].string, nargs,
+                        NULL, 0, &opts);
        fputs_filtered ("\"", stream);
       }
       return;
@@ -307,7 +309,7 @@ print_subexp_standard (struct expression *exp, int *pos,
 
          get_user_print_options (&opts);
          LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char,
-                          tempstr, nargs - 1, NULL, 0, &opts);
+                          (gdb_byte *) tempstr, nargs - 1, NULL, 0, &opts);
          (*pos) = pc;
        }
       else
index 6065d8221b3f7dc476acd165e3b925c3cf60bf4b..4c2f08c91b84082f410d39c56113f2125ea60131 100644 (file)
@@ -1471,7 +1471,8 @@ host_char_to_target (struct gdbarch *gdbarch, int c, int *target_c)
   cleanups = make_cleanup_obstack_free (&host_data);
 
   convert_between_encodings (target_charset (gdbarch), host_charset (),
-                            &the_char, 1, 1, &host_data, translit_none);
+                            (gdb_byte *) &the_char, 1, 1,
+                            &host_data, translit_none);
 
   if (obstack_object_size (&host_data) == 1)
     {
index 05d6c3e11570f7dd333729ed7f86cf1222a708a2..18cff49f3b50a11dbfb5a710de692e584623be69 100644 (file)
@@ -2071,7 +2071,7 @@ generic_emit_char (int c, struct type *type, struct ui_file *stream,
   make_cleanup_obstack_free (&output);
 
   convert_between_encodings (INTERMEDIATE_ENCODING, host_charset (),
-                            obstack_base (&wchar_buf),
+                            (gdb_byte *) obstack_base (&wchar_buf),
                             obstack_object_size (&wchar_buf),
                             sizeof (gdb_wchar_t), &output, translit_char);
   obstack_1grow (&output, '\0');
@@ -2426,7 +2426,7 @@ generic_printstr (struct ui_file *stream, struct type *type,
   make_cleanup_obstack_free (&output);
 
   convert_between_encodings (INTERMEDIATE_ENCODING, host_charset (),
-                            obstack_base (&wchar_buf),
+                            (gdb_byte *) obstack_base (&wchar_buf),
                             obstack_object_size (&wchar_buf),
                             sizeof (gdb_wchar_t), &output, translit_char);
   obstack_1grow (&output, '\0');
index 9255dc4dced09a85098f8f1ac6f293ce8f84820c..33ed7cf5194e1b12f43d8631e7ad5aa9adfd1abc 100644 (file)
@@ -2844,7 +2844,7 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
 {
   struct ui_file *stb;
   struct cleanup *old_chain;
-  gdb_byte *thevalue = NULL;
+  char *thevalue = NULL;
   struct value_print_options opts;
   struct type *type = NULL;
   long len = 0;
@@ -2956,7 +2956,7 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
 
   /* If the THEVALUE has contents, it is a regular string.  */
   if (thevalue)
-    LA_PRINT_STRING (stb, type, thevalue, len, encoding, 0, &opts);
+    LA_PRINT_STRING (stb, type, (gdb_byte *) thevalue, len, encoding, 0, &opts);
   else if (string_print)
     /* Otherwise, if string_print is set, and it is not a regular
        string, it is a lazy string.  */
This page took 0.037045 seconds and 4 git commands to generate.