Re: [PATCH 02/26] -Wpointer-sign: gdb_byte -> char.

Yao Qi
2013-04-12T02:32:20Z

On 04/12/2013 06:59 AM, Pedro Alves wrote:
> diff --git a/gdb/i386-cygwin-tdep.c b/gdb/i386-cygwin-tdep.c
> index cee2adf..26ffbaa 100644
> --- a/gdb/i386-cygwin-tdep.c
> +++ b/gdb/i386-cygwin-tdep.c
> @@ -125,11 +125,11 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj)
> struct cpms_data *data = obj;
> enum bfd_endian byte_order = gdbarch_byte_order (data->gdbarch);
>
> - char *module_name;
> + gdb_byte *module_name;
> size_t module_name_size;
> CORE_ADDR base_addr;
>
> - char *buf = NULL;
> + gdb_byte *buf = NULL;
>
> if (strncmp (sect->name, ".module", 7) != 0)
> return;
> @@ -160,7 +160,7 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj)
>
> /* The first module is the .exe itself. */
> if (data->module_count != 0)
> - windows_xfer_shared_library (module_name, base_addr,
> + windows_xfer_shared_library ((char *) module_name, base_addr,
> data->gdbarch, data->obstack);
> data->module_count++;
>

It would be nice to keep 'module_name' of type 'char *', because it is a
string.

> diff --git a/gdb/solib-dsbt.c b/gdb/solib-dsbt.c
> index e2822c1..86ce062 100644
> --- a/gdb/solib-dsbt.c
> +++ b/gdb/solib-dsbt.c
> @@ -840,7 +840,7 @@ enable_break2 (void)
> if (interp_sect)
> {
> unsigned int interp_sect_size;
> - gdb_byte *buf;
> + char *buf;
> bfd *tmp_bfd = NULL;
> CORE_ADDR addr;
> gdb_byte addr_buf[TIC6X_PTR_SIZE];
> @@ -852,7 +852,7 @@ enable_break2 (void)
> interp_sect_size = bfd_section_size (exec_bfd, interp_sect);
> buf = alloca (interp_sect_size);
> bfd_get_section_contents (exec_bfd, interp_sect,
> - buf, 0, interp_sect_size);
> + (bfd_byte *) buf, 0, interp_sect_size);

The declaration of bfd_get_section_contents is,

bfd_boolean bfd_get_section_contents
(bfd *abfd, asection *section, void *location, file_ptr offset,
bfd_size_type count);

the parameter 'location' 's type is 'void *', do we really need to cast
'buf' to 'bfd_byte *'?

>
> /* Now we need to figure out where the dynamic linker was
> loaded so that we can load its symbols and place a breakpoint
> diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
> index 52588bc..1765969 100644
> --- a/gdb/solib-frv.c
> +++ b/gdb/solib-frv.c
> @@ -535,7 +535,7 @@ enable_break2 (void)
> if (interp_sect)
> {
> unsigned int interp_sect_size;
> - gdb_byte *buf;
> + char *buf;
> bfd *tmp_bfd = NULL;
> int status;
> CORE_ADDR addr, interp_loadmap_addr;
> @@ -548,7 +548,7 @@ enable_break2 (void)
> interp_sect_size = bfd_section_size (exec_bfd, interp_sect);
> buf = alloca (interp_sect_size);
> bfd_get_section_contents (exec_bfd, interp_sect,
> - buf, 0, interp_sect_size);
> + (gdb_byte *) buf, 0, interp_sect_size);

Likewise.

--
Yao (é½å°§)