Re: Make all Perl warnings fatal

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Make all Perl warnings fatal
Date: 2023-08-21 15:51:24
Message-ID: 57346790-53cb-67ac-b62f-42813110f9fc@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


On 2023-08-21 Mo 02:20, Peter Eisentraut wrote:
> To avoid a complete bloodbath on cfbot, here is an updated patch set
> that includes a workaround for the getprotobyname() issue mentioned
> below.
>
>
> On 10.08.23 07:58, Peter Eisentraut wrote:
>> We have a lot of Perl scripts in the tree, mostly code generation and
>> TAP tests.  Occasionally, these scripts produce warnings.  These are
>> AFAICT always mistakes on the developer side (true positives). 
>> Typical examples are warnings from genbki.pl or related when you make
>> a mess in the catalog files during development, or warnings from
>> tests when they massage a config file that looks different on
>> different hosts, or mistakes during merges (e.g., duplicate
>> subroutine definitions), or just mistakes that weren't noticed,
>> because, you know, there is a lot of output in a verbose build.
>>
>> I wanted to figure put if we can catch these more reliably, in the
>> style of -Werror.  AFAICT, there is no way to automatically turn all
>> warnings into fatal errors.  But there is a way to do it per script,
>> by replacing
>>
>>      use warnings;
>>
>> by
>>
>>      use warnings FATAL => 'all';
>>
>> See attached patch to try it out.
>>
>> The documentation at
>> <https://perldoc.perl.org/warnings#Fatal-Warnings> appears to sort of
>> hand-wave against doing that.  Their argument appears to be something
>> like, the modules you use might in the future produce additional
>> warnings, thus breaking your scripts.  On balance, I'd take that
>> risk, if it means I would notice the warnings in a more timely and
>> robust way.  But that's just me at a moment in time.
>>
>> Thoughts?

It's not really the same as -Werror, because many warnings can be
generated at runtime rather than compile-time.

Still, I guess that might not matter too much since apart from plperl we
only use perl for building / testing.

Regarding the dangers mentioned, I guess we can undo it if it proves a
nuisance.

+1 to getting rid if the unnecessary call to getprotobyname().

cheers

andrew

--
Andrew Dunstan
EDB:https://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Davis 2023-08-21 16:08:43 Re: [17] Special search_path names "!pg_temp" and "!pg_catalog"
Previous Message Tristan Partin 2023-08-21 15:48:23 Re: meson: pgxs Makefile.global differences