Re: proper format for printing GetLastError()

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: proper format for printing GetLastError()
Date: 2011-07-06 11:48:30
Message-ID: CABUevEx8-CRhka-uj6JVEs8oGj5b7wvBieRbFJhRtZSFKxn3zg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jul 4, 2011 at 17:29, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
> About half of our code prints GetLastError() using %d after casting it
> to int (actually, about half of that half uses %i, another thing to sort
> out, perhaps), and the other half uses %lu without casting.  I gather
> from online documentation that GetLastError() returns DWORD, which
> appears to be unsigned 32 bits.  So using %lu appears to be more
> correct.  Any arguments against standardizing on %lu?

Nope. I think it's only in there because of lazyness, in general. %lu
seems to be the correct choice.

> Secondly, it might also be good if we could standardize on printing
>
>    actual message: error code %lu
>
> instead of just
>
>    actual message: %lu

Or "actual error code: %lu"?

> Thirdly, why are we not trying to print a textual message?

I'd say that depends on where it is. In some cases probably because
it's "can never happen" messages. In other cases because, well, no
reason :)

--
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2011-07-06 12:11:17 Re: proper format for printing GetLastError()
Previous Message Fujii Masao 2011-07-06 11:27:39 Re: Cascade replication