This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: gdb under solaris7
- To: Nick Duffek <nsd at redhat dot com>
- Subject: Re: gdb under solaris7
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Fri, 10 Nov 2000 19:12:18 +1100
- Cc: cagney at redhat dot com, and at genesyslab dot com, gdb-patches at sourceware dot cygnus dot com
- References: <3A0B99FF.CB71F51A@cygnus.com> <200011100748.eAA7mcp25422@rtl.cygnus.com>
Nick Duffek wrote:
> There's one other change that involves a cast, and it's as obviously
> correct as the "scan" change above:
>
> char *p;
> ...
> p = (unsigned char *) bfd_get_section_name (abfd, sect);
Assuming that bfd_get_section_name() returns a ``const char *'' (I'm
very much relying on memory here) then the code is ``wrong''. Not
because the cast is incorrect, rather because it needed a cast in the
first place. The code shouldn't be throwing away the knowledge that the
pointer is into a constant memory region.
I'm just suggesting is that the proposed changes be re-examined to
determine if the casts being added/tweeked are even needed. In general,
even in C, casts are not necessary (ignoring botched system header files
:-).
Anyway, attatched is an alternative fix for the above case :-)
enjoy,
Andrew
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.27
diff -p -r1.27 remote.c
*** remote.c 2000/11/03 22:00:56 1.27
--- remote.c 2000/11/10 08:11:18
*************** remote_cisco_section_offsets (bfd_vma te
*** 1873,1879 ****
asection *sect;
bfd *abfd;
int len;
- char *p;
if (symfile_objfile == NULL)
return -1; /* no can do nothin' */
--- 1873,1878 ----
*************** remote_cisco_section_offsets (bfd_vma te
*** 1890,1896 ****
sect != 0;
sect = sect->next)
{
! p = (unsigned char *) bfd_get_section_name (abfd, sect);
len = strlen (p);
if (strcmp (p + len - 4, "data") == 0) /* ends in "data" */
if (data_base == 0 ||
--- 1889,1895 ----
sect != 0;
sect = sect->next)
{
! const char *p = bfd_get_section_name (abfd, sect);
len = strlen (p);
if (strcmp (p + len - 4, "data") == 0) /* ends in "data" */
if (data_base == 0 ||