gdb under solaris7

Nick Duffek nsd@redhat.com
Thu Nov 9 23:42:00 GMT 2000


On 10-Nov-2000, Andrew Cagney wrote:

>> remote.c:
>> >!   scan = (char *) ref;
>> [...]
>> >!   scan = (unsigned char *) ref;
>> 
>> Looks right.
>
>? :-)

I left out the previous two lines of context from remote.c.  Here's the
relevant part:

  unsigned char *scan;

  scan = (char *) ref;

An obvious remote.c error, no?

>> remote.c:
>> >!       pkt = unpack_int (pkt, &tag);  /* tag */
>> [...]
>> >!       pkt = unpack_int (pkt, (int *)&tag);   /* tag */
>> 
>> How about declaring tag as an int instead?  Better not to use typecasts
>> when easily avoidable, I think.  Andrew?
>
>TAG should have the correct type for the reference parameter.

My point exactly.  TAG is currently declared as unsigned int; unpack_int()
expects a signed int; there's no reason I can see why TAG needs to be
unsigned; ergo, change:

  unsigned int tag;

to

  int tag;

>Could I suggest going back through and re-thinking any changes that
>involve casts.

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

becomes

  char *p;
  ...
  p = (char *) bfd_get_section_name (abfd, sect);

Nick


More information about the Gdb-patches mailing list