Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] trying to kill a warning in hpread.c (from call to complaint)
@ 2003-01-10 14:26 Joel Brobecker
  2003-01-10 14:34 ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Joel Brobecker @ 2003-01-10 14:26 UTC (permalink / raw)
  To: gdb-patches

Hello,

I see the following warnings when compiling hpread.c:

        hpread.c:1920: warning: int format, pointer arg (arg 3)
        hpread.c:2025: warning: int format, pointer arg (arg 3)
        hpread.c:2051: warning: int format, pointer arg (arg 3)
        hpread.c:2072: warning: int format, pointer arg (arg 3)
        hpread.c:2146: warning: int format, pointer arg (arg 3)
        hpread.c:2230: warning: int format, pointer arg (arg 3)

These warnings point to the following macro:

#define SET_NAMESTRING(SYM, NAMEP, OBJFILE) \
  if (! hpread_has_name ((SYM)->dblock.kind)) \
    *NAMEP = ""; \
  else if (((unsigned)(SYM)->dsfile.name) >= VT_SIZE (OBJFILE)) \
    { \
      complaint (&symfile_complaints, "bad string table offset in symbol %d", \
                 (char *) symnum); \
      *NAMEP = ""; \
    } \
  else \
    *NAMEP = (SYM)->dsfile.name + VT (OBJFILE)

I think that the warning comes from the call to complaint where the
format string contains "%d", but the next parameter is casted to a
"char *".

Is the cast to "char *" necessary? Can/Should I remove it?

Thanks,
-- 
Joel


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] trying to kill a warning in hpread.c (from call to complaint)
  2003-01-10 14:26 [RFC] trying to kill a warning in hpread.c (from call to complaint) Joel Brobecker
@ 2003-01-10 14:34 ` Daniel Jacobowitz
  2003-01-10 16:08   ` Andrew Cagney
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2003-01-10 14:34 UTC (permalink / raw)
  To: gdb-patches

On Fri, Jan 10, 2003 at 06:26:39PM +0400, Joel Brobecker wrote:
> Hello,
> 
> I see the following warnings when compiling hpread.c:
> 
>         hpread.c:1920: warning: int format, pointer arg (arg 3)
>         hpread.c:2025: warning: int format, pointer arg (arg 3)
>         hpread.c:2051: warning: int format, pointer arg (arg 3)
>         hpread.c:2072: warning: int format, pointer arg (arg 3)
>         hpread.c:2146: warning: int format, pointer arg (arg 3)
>         hpread.c:2230: warning: int format, pointer arg (arg 3)
> 
> These warnings point to the following macro:
> 
> #define SET_NAMESTRING(SYM, NAMEP, OBJFILE) \
>   if (! hpread_has_name ((SYM)->dblock.kind)) \
>     *NAMEP = ""; \
>   else if (((unsigned)(SYM)->dsfile.name) >= VT_SIZE (OBJFILE)) \
>     { \
>       complaint (&symfile_complaints, "bad string table offset in symbol %d", \
>                  (char *) symnum); \
>       *NAMEP = ""; \
>     } \
>   else \
>     *NAMEP = (SYM)->dsfile.name + VT (OBJFILE)
> 
> I think that the warning comes from the call to complaint where the
> format string contains "%d", but the next parameter is casted to a
> "char *".
> 
> Is the cast to "char *" necessary? Can/Should I remove it?

Looks like a typo in Kevin's complaint patch.  I'd say yes; and in the
calls to lbrac_unmatched_complaint, too.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] trying to kill a warning in hpread.c (from call to complaint)
  2003-01-10 14:34 ` Daniel Jacobowitz
@ 2003-01-10 16:08   ` Andrew Cagney
  2003-01-10 16:13     ` Daniel Jacobowitz
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2003-01-10 16:08 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches


>>       complaint (&symfile_complaints, "bad string table offset in symbol %d", \
>>                  (char *) symnum); \
>>       *NAMEP = ""; \
>>     } \
>>   else \
>>     *NAMEP = (SYM)->dsfile.name + VT (OBJFILE)
>> 
>> I think that the warning comes from the call to complaint where the
>> format string contains "%d", but the next parameter is casted to a
>> "char *".
>> 
>> Is the cast to "char *" necessary? Can/Should I remove it?
> 
> 
> Looks like a typo in Kevin's complaint patch.

Nope.  The original code was broken:

	complain (&string_table_offset_complaint, (char *) symnum);

(complaint -> complaints finds another victim / bug).

 > I'd say yes; and in the calls to lbrac_unmatched_complaint, too.

Joel, if you encounter a macro, first thing to do is always to convert 
it to a function :-)

Andrew



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RFC] trying to kill a warning in hpread.c (from call to complaint)
  2003-01-10 16:08   ` Andrew Cagney
@ 2003-01-10 16:13     ` Daniel Jacobowitz
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2003-01-10 16:13 UTC (permalink / raw)
  To: gdb-patches

On Fri, Jan 10, 2003 at 11:08:37AM -0500, Andrew Cagney wrote:
> 
> >>      complaint (&symfile_complaints, "bad string table offset in symbol 
> >>      %d", \
> >>                 (char *) symnum); \
> >>      *NAMEP = ""; \
> >>    } \
> >>  else \
> >>    *NAMEP = (SYM)->dsfile.name + VT (OBJFILE)
> >>
> >>I think that the warning comes from the call to complaint where the
> >>format string contains "%d", but the next parameter is casted to a
> >>"char *".
> >>
> >>Is the cast to "char *" necessary? Can/Should I remove it?
> >
> >
> >Looks like a typo in Kevin's complaint patch.
> 
> Nope.  The original code was broken:
> 
> 	complain (&string_table_offset_complaint, (char *) symnum);
> 
> (complaint -> complaints finds another victim / bug).

Agh!  CVS logs foil me again!

No offense intended to Kevin.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-01-10 16:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-10 14:26 [RFC] trying to kill a warning in hpread.c (from call to complaint) Joel Brobecker
2003-01-10 14:34 ` Daniel Jacobowitz
2003-01-10 16:08   ` Andrew Cagney
2003-01-10 16:13     ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox