From 7be5d8df1f74b78620167d3abf32ee607e728919 Mon Sep 17 00:00:00 2001 From: Andrew Dunstan Date: Mon, 13 Apr 2020 11:55:45 -0400 Subject: [PATCH] Use perl warnings pragma consistently We've had a mixture of the warnings pragma, the -w switch on the shebang line, and no warnings at all. This patch removes the -w swicth and add the warnings pragma to all perl sources missing it. It raises the severity of the TestingAndDebugging::RequireUseWarnings perlcritic policy to level 5, so that we catch any future violations. Discussion: https://postgr.es/m/20200412074245.GB623763@rfd.leadboat.com --- contrib/intarray/bench/bench.pl | 1 + contrib/intarray/bench/create_test.pl | 2 ++ contrib/seg/seg-validate.pl | 1 + contrib/seg/sort-segments.pl | 1 + doc/src/sgml/mk_feature_tables.pl | 3 ++- src/backend/catalog/genbki.pl | 2 +- src/backend/utils/Gen_fmgrtab.pl | 2 +- src/backend/utils/mb/Unicode/UCS_to_BIG5.pl | 2 ++ src/backend/utils/mb/Unicode/UCS_to_EUC_CN.pl | 2 ++ src/backend/utils/mb/Unicode/UCS_to_EUC_JIS_2004.pl | 2 ++ src/backend/utils/mb/Unicode/UCS_to_EUC_JP.pl | 2 ++ src/backend/utils/mb/Unicode/UCS_to_EUC_KR.pl | 2 ++ src/backend/utils/mb/Unicode/UCS_to_EUC_TW.pl | 2 ++ src/backend/utils/mb/Unicode/UCS_to_GB18030.pl | 2 ++ src/backend/utils/mb/Unicode/UCS_to_JOHAB.pl | 2 ++ src/backend/utils/mb/Unicode/UCS_to_SHIFT_JIS_2004.pl | 2 ++ src/backend/utils/mb/Unicode/UCS_to_SJIS.pl | 2 ++ src/backend/utils/mb/Unicode/UCS_to_UHC.pl | 2 ++ src/backend/utils/mb/Unicode/UCS_to_most.pl | 2 ++ src/backend/utils/mb/Unicode/convutils.pm | 1 + src/backend/utils/sort/gen_qsort_tuple.pl | 3 ++- src/bin/psql/create_help.pl | 3 ++- src/interfaces/libpq/test/regress.pl | 3 ++- src/pl/plperl/plc_perlboot.pl | 1 + src/pl/plperl/plperl_opmask.pl | 2 +- src/test/locale/sort-test.pl | 1 + src/test/perl/SimpleTee.pm | 1 + src/tools/fix-old-flex-code.pl | 2 +- src/tools/msvc/build.pl | 1 + src/tools/msvc/pgbison.pl | 2 ++ src/tools/msvc/pgflex.pl | 2 ++ src/tools/msvc/vcregress.pl | 1 + src/tools/perlcheck/perlcriticrc | 4 ++++ src/tools/pginclude/pgcheckdefines | 3 ++- src/tools/version_stamp.pl | 3 ++- 35 files changed, 59 insertions(+), 10 deletions(-) diff --git a/contrib/intarray/bench/bench.pl b/contrib/intarray/bench/bench.pl index 92035d6c06..daf3febc80 100755 --- a/contrib/intarray/bench/bench.pl +++ b/contrib/intarray/bench/bench.pl @@ -1,6 +1,7 @@ #!/usr/bin/perl use strict; +use warnings; # make sure we are in a sane environment. use DBI(); diff --git a/contrib/intarray/bench/create_test.pl b/contrib/intarray/bench/create_test.pl index d2c678bb53..3f2a6e4da2 100755 --- a/contrib/intarray/bench/create_test.pl +++ b/contrib/intarray/bench/create_test.pl @@ -3,6 +3,8 @@ # contrib/intarray/bench/create_test.pl use strict; +use warnings; + print < SHIFT_JIS_2004 table diff --git a/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl b/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl index c65091159b..5f4512ec87 100755 --- a/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl +++ b/src/backend/utils/mb/Unicode/UCS_to_SJIS.pl @@ -11,6 +11,8 @@ # ftp site. use strict; +use warnings; + use convutils; my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_SJIS.pl'; diff --git a/src/backend/utils/mb/Unicode/UCS_to_UHC.pl b/src/backend/utils/mb/Unicode/UCS_to_UHC.pl index 78b982a22e..3282106d7f 100755 --- a/src/backend/utils/mb/Unicode/UCS_to_UHC.pl +++ b/src/backend/utils/mb/Unicode/UCS_to_UHC.pl @@ -14,6 +14,8 @@ # and the "b" field is the hex byte sequence for UHC use strict; +use warnings; + use convutils; my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_UHC.pl'; diff --git a/src/backend/utils/mb/Unicode/UCS_to_most.pl b/src/backend/utils/mb/Unicode/UCS_to_most.pl index 7ff724558d..8a7b26a5c5 100755 --- a/src/backend/utils/mb/Unicode/UCS_to_most.pl +++ b/src/backend/utils/mb/Unicode/UCS_to_most.pl @@ -16,6 +16,8 @@ # # and Unicode name (not used in this script) use strict; +use warnings; + use convutils; my $this_script = 'src/backend/utils/mb/Unicode/UCS_to_most.pl'; diff --git a/src/backend/utils/mb/Unicode/convutils.pm b/src/backend/utils/mb/Unicode/convutils.pm index 1903b345cb..2f64a12ea1 100644 --- a/src/backend/utils/mb/Unicode/convutils.pm +++ b/src/backend/utils/mb/Unicode/convutils.pm @@ -6,6 +6,7 @@ package convutils; use strict; +use warnings; use Carp; use Exporter 'import'; diff --git a/src/backend/utils/sort/gen_qsort_tuple.pl b/src/backend/utils/sort/gen_qsort_tuple.pl index b6b2ffa7d0..9ed6cfc7ea 100644 --- a/src/backend/utils/sort/gen_qsort_tuple.pl +++ b/src/backend/utils/sort/gen_qsort_tuple.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl # # gen_qsort_tuple.pl @@ -26,6 +26,7 @@ # use strict; +use warnings; my $SUFFIX; my $EXTRAARGS; diff --git a/src/bin/psql/create_help.pl b/src/bin/psql/create_help.pl index a3b34603ef..ee82e64583 100644 --- a/src/bin/psql/create_help.pl +++ b/src/bin/psql/create_help.pl @@ -1,4 +1,4 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl ################################################################# # create_help.pl -- converts SGML docs to internal psql help @@ -20,6 +20,7 @@ # use strict; +use warnings; my $docdir = $ARGV[0] or die "$0: missing required argument: docdir\n"; my $hfile = $ARGV[1] . '.h' diff --git a/src/interfaces/libpq/test/regress.pl b/src/interfaces/libpq/test/regress.pl index 3ad638a91b..54db4f1abf 100644 --- a/src/interfaces/libpq/test/regress.pl +++ b/src/interfaces/libpq/test/regress.pl @@ -1,6 +1,7 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl use strict; +use warnings; # use of SRCDIR/SUBDIR is required for supporting VPath builds my $srcdir = $ENV{'SRCDIR'} or die 'SRCDIR environment variable is not set'; diff --git a/src/pl/plperl/plc_perlboot.pl b/src/pl/plperl/plc_perlboot.pl index f41aa80e80..ee1b9bf463 100644 --- a/src/pl/plperl/plc_perlboot.pl +++ b/src/pl/plperl/plc_perlboot.pl @@ -1,6 +1,7 @@ # src/pl/plperl/plc_perlboot.pl use strict; +use warnings; use 5.008001; use vars qw(%_SHARED $_TD); diff --git a/src/pl/plperl/plperl_opmask.pl b/src/pl/plperl/plperl_opmask.pl index e4e64b843f..3b33112ff9 100644 --- a/src/pl/plperl/plperl_opmask.pl +++ b/src/pl/plperl/plperl_opmask.pl @@ -1,4 +1,4 @@ -#!perl -w +#!perl use strict; use warnings; diff --git a/src/test/locale/sort-test.pl b/src/test/locale/sort-test.pl index b8fc93aab1..b61968b7e0 100755 --- a/src/test/locale/sort-test.pl +++ b/src/test/locale/sort-test.pl @@ -1,6 +1,7 @@ #! /usr/bin/perl use strict; +use warnings; use locale; open(my $in_fh, '<', $ARGV[0]) || die; diff --git a/src/test/perl/SimpleTee.pm b/src/test/perl/SimpleTee.pm index 9de7b1ac32..74409bde6d 100644 --- a/src/test/perl/SimpleTee.pm +++ b/src/test/perl/SimpleTee.pm @@ -9,6 +9,7 @@ package SimpleTee; use strict; +use warnings; sub TIEHANDLE { diff --git a/src/tools/fix-old-flex-code.pl b/src/tools/fix-old-flex-code.pl index 2954cf5a72..1bbb7cdb84 100644 --- a/src/tools/fix-old-flex-code.pl +++ b/src/tools/fix-old-flex-code.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl #---------------------------------------------------------------------- # # fix-old-flex-code.pl diff --git a/src/tools/msvc/build.pl b/src/tools/msvc/build.pl index 2e47f24783..3c886fcd49 100644 --- a/src/tools/msvc/build.pl +++ b/src/tools/msvc/build.pl @@ -3,6 +3,7 @@ # src/tools/msvc/build.pl use strict; +use warnings; use File::Basename; use File::Spec; diff --git a/src/tools/msvc/pgbison.pl b/src/tools/msvc/pgbison.pl index 490df83367..774d5be059 100644 --- a/src/tools/msvc/pgbison.pl +++ b/src/tools/msvc/pgbison.pl @@ -3,6 +3,8 @@ # src/tools/msvc/pgbison.pl use strict; +use warnings; + use File::Basename; # assume we are in the postgres source root diff --git a/src/tools/msvc/pgflex.pl b/src/tools/msvc/pgflex.pl index aceed5ffd6..26c73dbfad 100644 --- a/src/tools/msvc/pgflex.pl +++ b/src/tools/msvc/pgflex.pl @@ -3,6 +3,8 @@ # src/tools/msvc/pgflex.pl use strict; +use warnings; + use File::Basename; # silence flex bleatings about file path style diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl index 82dca29a61..c39178a93c 100644 --- a/src/tools/msvc/vcregress.pl +++ b/src/tools/msvc/vcregress.pl @@ -3,6 +3,7 @@ # src/tools/msvc/vcregress.pl use strict; +use warnings; our $config; diff --git a/src/tools/perlcheck/perlcriticrc b/src/tools/perlcheck/perlcriticrc index bd848a9a65..314c83c6a5 100644 --- a/src/tools/perlcheck/perlcriticrc +++ b/src/tools/perlcheck/perlcriticrc @@ -19,6 +19,10 @@ verbose = %f: %m at line %l, column %c. %e. ([%p] Severity: %s)\n # allow octal constants with leading zeros [-ValuesAndExpressions::ProhibitLeadingZeros] +# insist on use of the warnings pragma +[TestingAndDebugging::RequireUseWarnings] +severity = 5 + # for now raise severity of this to level 5 [Subroutines::RequireFinalReturn] severity = 5 diff --git a/src/tools/pginclude/pgcheckdefines b/src/tools/pginclude/pgcheckdefines index 4edf7fc56e..0a760d6eca 100755 --- a/src/tools/pginclude/pgcheckdefines +++ b/src/tools/pginclude/pgcheckdefines @@ -1,4 +1,4 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl # # This script looks for symbols that are referenced in #ifdef or defined() @@ -21,6 +21,7 @@ # use strict; +use warnings; use Cwd; use File::Basename; diff --git a/src/tools/version_stamp.pl b/src/tools/version_stamp.pl index cb59ad234a..fcd3f18048 100755 --- a/src/tools/version_stamp.pl +++ b/src/tools/version_stamp.pl @@ -1,4 +1,4 @@ -#! /usr/bin/perl -w +#! /usr/bin/perl ################################################################# # version_stamp.pl -- update version stamps throughout the source tree @@ -21,6 +21,7 @@ # use strict; +use warnings; # Major version is hard-wired into the script. We update it when we branch # a new development version.