Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] compilation error in remote.c on sparc-solaris
@ 2008-03-07 18:28 Joel Brobecker
  2008-03-07 18:55 ` Michael Snyder
  0 siblings, 1 reply; 5+ messages in thread
From: Joel Brobecker @ 2008-03-07 18:28 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 942 bytes --]

Hello,

I get the following warning when compiling remote.c on a sparc-solaris
machine:

    remote.c: In function 'extended_remote_attach_1':
    remote.c:2859: warning: format '%x' expects type 'unsigned int', but argument 3 has type 'pid_t'

I think the problem is that, on sparc-solaris, type pid_t is defined
as a "long", whereas on other machines I've built GDB on, it's an int.

Variable pid is defined as follow:

  pid_t pid;

I think it's good enough to change its type to "int". I've never seen
a PID that's larger than 7 digits, so an int should always be big enough.
In any case, that's what the pid_t structure uses for the pid.

2008-03-07  Joel Brobecker  <brobecker@adacore.com>

        * remote.c (extended_remote_attach_1): Make local variable pid an int
        instead of a pid_t.

Tested on sparc-solaris by rebuilding remote.o (I tried with both
a 32bit compiler and a 64bit compiler).

OK to apply?

Thanks,
-- 
Joel

[-- Attachment #2: remote.c.diff --]
[-- Type: text/plain, Size: 369 bytes --]

Index: remote.c
===================================================================
--- remote.c	(revision 34865)
+++ remote.c	(revision 34866)
@@ -2841,7 +2841,7 @@ static void
 extended_remote_attach_1 (struct target_ops *target, char *args, int from_tty)
 {
   struct remote_state *rs = get_remote_state ();
-  pid_t pid;
+  int pid;
   char *dummy;
 
   if (!args)

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

* Re: [RFA] compilation error in remote.c on sparc-solaris
  2008-03-07 18:28 [RFA] compilation error in remote.c on sparc-solaris Joel Brobecker
@ 2008-03-07 18:55 ` Michael Snyder
  2008-03-07 19:02   ` Daniel Jacobowitz
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Snyder @ 2008-03-07 18:55 UTC (permalink / raw)
  To: Joel Brobecker; +Cc: gdb-patches

On Fri, 2008-03-07 at 10:27 -0800, Joel Brobecker wrote:
> Hello,
> 
> I get the following warning when compiling remote.c on a sparc-solaris
> machine:
> 
>     remote.c: In function 'extended_remote_attach_1':
>     remote.c:2859: warning: format '%x' expects type 'unsigned int', but argument 3 has type 'pid_t'
> 
> I think the problem is that, on sparc-solaris, type pid_t is defined
> as a "long", whereas on other machines I've built GDB on, it's an int.
> 
> Variable pid is defined as follow:
> 
>   pid_t pid;
> 
> I think it's good enough to change its type to "int". I've never seen
> a PID that's larger than 7 digits, so an int should always be big enough.
> In any case, that's what the pid_t structure uses for the pid.

Why not just cast it?


> 
> 2008-03-07  Joel Brobecker  <brobecker@adacore.com>
> 
>         * remote.c (extended_remote_attach_1): Make local variable pid an int
>         instead of a pid_t.
> 
> Tested on sparc-solaris by rebuilding remote.o (I tried with both
> a 32bit compiler and a 64bit compiler).
> 
> OK to apply?
> 
> Thanks,


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

* Re: [RFA] compilation error in remote.c on sparc-solaris
  2008-03-07 18:55 ` Michael Snyder
@ 2008-03-07 19:02   ` Daniel Jacobowitz
  2008-03-07 19:15     ` Michael Snyder
  2008-03-07 19:44     ` Joel Brobecker
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2008-03-07 19:02 UTC (permalink / raw)
  To: Michael Snyder; +Cc: Joel Brobecker, gdb-patches

On Fri, Mar 07, 2008 at 10:55:01AM -0800, Michael Snyder wrote:
> > Variable pid is defined as follow:
> > 
> >   pid_t pid;
> > 
> > I think it's good enough to change its type to "int". I've never seen
> > a PID that's larger than 7 digits, so an int should always be big enough.
> > In any case, that's what the pid_t structure uses for the pid.
> 
> Why not just cast it?

Because it's not a pid_t, it's an int.  pid_t is the type of a process
on the host system and we're not talking to any host system processes
here.

> > 2008-03-07  Joel Brobecker  <brobecker@adacore.com>
> > 
> >         * remote.c (extended_remote_attach_1): Make local variable pid an int
> >         instead of a pid_t.

This is OK - thanks, Joel, I'd been meaning to fix this since we
noticed it :-(  I can't find the number, but I'm pretty sure there's
a PR in gnats too.

-- 
Daniel Jacobowitz
CodeSourcery


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

* Re: [RFA] compilation error in remote.c on sparc-solaris
  2008-03-07 19:02   ` Daniel Jacobowitz
@ 2008-03-07 19:15     ` Michael Snyder
  2008-03-07 19:44     ` Joel Brobecker
  1 sibling, 0 replies; 5+ messages in thread
From: Michael Snyder @ 2008-03-07 19:15 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Joel Brobecker, gdb-patches

On Fri, 2008-03-07 at 14:01 -0500, Daniel Jacobowitz wrote:
> On Fri, Mar 07, 2008 at 10:55:01AM -0800, Michael Snyder wrote:
> > > Variable pid is defined as follow:
> > > 
> > >   pid_t pid;
> > > 
> > > I think it's good enough to change its type to "int". I've never seen
> > > a PID that's larger than 7 digits, so an int should always be big enough.
> > > In any case, that's what the pid_t structure uses for the pid.
> > 
> > Why not just cast it?
> 
> Because it's not a pid_t, it's an int.  pid_t is the type of a process
> on the host system and we're not talking to any host system processes
> here.

Good answer.  ;-)



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

* Re: [RFA] compilation error in remote.c on sparc-solaris
  2008-03-07 19:02   ` Daniel Jacobowitz
  2008-03-07 19:15     ` Michael Snyder
@ 2008-03-07 19:44     ` Joel Brobecker
  1 sibling, 0 replies; 5+ messages in thread
From: Joel Brobecker @ 2008-03-07 19:44 UTC (permalink / raw)
  To: gdb-patches

> > > 2008-03-07  Joel Brobecker  <brobecker@adacore.com>
> > > 
> > >         * remote.c (extended_remote_attach_1): Make local variable pid an int
> > >         instead of a pid_t.
> 
> This is OK - thanks, Joel, I'd been meaning to fix this since we
> noticed it :-(  I can't find the number, but I'm pretty sure there's
> a PR in gnats too.

Thank! I searched the database too, and couldn't find any PR either...

-- 
Joel


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

end of thread, other threads:[~2008-03-07 19:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-03-07 18:28 [RFA] compilation error in remote.c on sparc-solaris Joel Brobecker
2008-03-07 18:55 ` Michael Snyder
2008-03-07 19:02   ` Daniel Jacobowitz
2008-03-07 19:15     ` Michael Snyder
2008-03-07 19:44     ` Joel Brobecker

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