Re: cast pid_t to int when using *printf - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: cast pid_t to int when using *printf
Date
Msg-id 200410092208.i99M8KT23309@candle.pha.pa.us
Whole thread Raw
In response to Re: cast pid_t to int when using *printf  (Neil Conway <neilc@samurai.com>)
Responses Re: cast pid_t to int when using *printf  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-patches
Neil Conway wrote:
> Bruce Momjian wrote:
> > Tom Lane wrote:
> >>Traditionally PIDs fit in 16 bits, let alone 32.  I'd recommend that we
> >>standardize on casting pid_t to int for printing purposes;
> >
> >
> > Done.
>
> Uh, what? Your patch removes the casting of pid_t to int -- Tom was
> suggesting that we consistently cast pid_t to int. (Also your patch
> removes casting from uid_t to int in the case of geteuid() -- why?)
>
> For instance:
>
> http://developer.postgresql.org/cvsweb.cgi/pgsql-server/src/bin/psql/command.c.diff?r1=1.126&r2=1.127

From Tom:

> Traditionally PIDs fit in 16 bits, let alone 32.  I'd recommend that we
> standardize on casting pid_t to int for printing purposes;

OK, I read Tom's email saying that we use %d consistently.  I didn't
realize he was also saying cast getpid(), but that is easy to do.

Before we had "%ld" sometimes, (int) cast others, and sometimes neither.
It is now consistent and we can make the change all at once.

So I assume everyone wants:

    printf("%d", (int) getpid())?

Is this correct?

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

pgsql-patches by date:

Previous
From: "Magnus Hagander"
Date:
Subject: Small win32 build cleanup (versioninfo)
Next
From: Sean Chittenden
Date:
Subject: Slightly better testing for pg_ctl(1)'s -w...