Re: pg_logging_init() can return ENOTTY with TAP tests

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_logging_init() can return ENOTTY with TAP tests
Date: 2020-09-18 13:56:14
Message-ID: 445428.1600437374@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Michael Paquier <michael(at)paquier(dot)xyz> writes:
> Some system calls may not set errno even if they succeed, like
> strtol() on Linux for example, so in this case it can cause option
> handling to fail because of the error set by logging initialization.
> Shouldn't we reset errno to 0 once logging initialization is done? It
> seems to me that this code path should finish with a clean sheet, and
> attached is a proposal of patch to address this issue.

No, this is a bad idea. The right place to fix this is whatever code
segment is relying on errno to be initially zero; that is NEVER a sane
assumption. That is, a valid coding pattern is something like

errno = 0;
strtol(...);
if (errno) ...

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2020-09-18 14:11:13 Re: OpenSSL 3.0.0 compatibility
Previous Message Masahiko Sawada 2020-09-18 13:56:12 Re: Transactions involving multiple postgres foreign servers, take 2