Re: cast pid_t to int when using *printf

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Neil Conway <neilc(at)samurai(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Oliver Jowett <oliver(at)opencloud(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>, pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: cast pid_t to int when using *printf
Date: 2004-10-09 22:08:19
Message-ID: 200410092208.i99M8KT23309@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Sean Chittenden 2004-10-10 06:24:21 Slightly better testing for pg_ctl(1)'s -w...
Previous Message Magnus Hagander 2004-10-09 20:06:03 Small win32 build cleanup (versioninfo)