This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gdb under solaris7


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 ||

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]