Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sOd2l-000K2U-25 for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Jul 2024 12:55:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sOd2i-001n05-UT for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Jul 2024 12:55:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sOd2h-001mzx-T3 for pgsql-hackers@lists.postgresql.org; Tue, 02 Jul 2024 12:55:33 +0000 Received: from fout8-smtp.messagingengine.com ([103.168.172.151]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sOd2f-0002MT-Ao for pgsql-hackers@postgresql.org; Tue, 02 Jul 2024 12:55:31 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfout.nyi.internal (Postfix) with ESMTP id 5BD091380451; Tue, 2 Jul 2024 08:55:28 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Tue, 02 Jul 2024 08:55:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1719924928; x=1720011328; bh=ZMv1kV6Qxn KNzFWKFoNg2hDfUdm+7iCTnw6BJVu7R2s=; b=1sGtnky36geTZF7AAq4VNnOcgH PvXT5v09N5VsunbDtLT90W6htTuji/zn6YVFxOx+ZocKW5VD/Clg2hzrm4bNaBZT KA8VtSEqztuxerRoX5gL2mt8TzDwRa6Dd32IgPwKsYFR3H5vpBDi0UxH7r9k7OEF A9WIsNBiPssLrqO5YuXnS9EIQVX26srkelbwmqSmq3lQmtTOW9jDu0aEsxkVbEel MI5Z82s/n2gUsi03YOehHYQELMS2FM8Pk/DbMeO2vqqtc89YnuxCHeosL9xEHzxY vmnyp5x7c5VIPbozf/W2tUU5Xqq71Dh6Iy++ud8lwvVa7aEO+60vB6JW7fqw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1719924928; x=1720011328; bh=ZMv1kV6QxnKNzFWKFoNg2hDfUdm+ 7iCTnw6BJVu7R2s=; b=RXG5adFVqOnm8ymFaQPGtFy7JpImRMedCsbPeb2trLf+ 4YPdLGRnPtiHYxAsqFQwzdhSfwnYtkq4CGeE+iTKpbcS5op5Siht5Zu6ST9GSSvx JxEW2JX6ZDyfBZT/yz3RFnQY4MtHGKjY7IYjO+crhTzRYt7QKddbbYCI/JR65KRj TB5EwpmAInA/g8WU5G4RNpafhU9UK5h2GHOfiRDH6wZ0rUzzMNnjjSxIbBb0uMer 5acBSpZVPO4jO3tT62cTqLAGnMXQWVPo0Yogu6zvNSn7j7dySfNRq8LN3inbaM0t amyommmC5Bm5FYaOppOZ4b/u8GmVBy81iMSExsF2Hg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudehgdehiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculddvfedmnecujfgurhephffvvefufhffjgfkfgggtgesmhdtreertder jeenucfhrhhomhepffgrghhfihhnnhcukfhlmhgrrhhiucforghnnhhsnohkvghruceoih hlmhgrrhhisehilhhmrghrihdrohhrgheqnecuggftrfgrthhtvghrnhepteeiuddvhffh ffffgeejtedtffetvefhgfeilefftdettdehffejtedvgeevhfdtnecuffhomhgrihhnpe hgihhthhhusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpehilhhmrghrihesihhlmhgrrhhirdhorhhg X-ME-Proxy: Feedback-ID: i1ff147bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 2 Jul 2024 08:55:27 -0400 (EDT) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: Michael Paquier Cc: Alexander Lakhin , pgsql-hackers Subject: Re: Cleaning up perl code References: <70b340bc-244a-589d-ef8b-d8aebb707a84@gmail.com> <87ttisfcah.fsf@wibble.ilmari.org> <730c8376-77db-5af6-ea2f-d530f68c5fa3@gmail.com> Date: Tue, 02 Jul 2024 13:55:25 +0100 In-Reply-To: (Michael Paquier's message of "Tue, 2 Jul 2024 10:11:46 +0900") Message-ID: <87wmm4dkci.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Michael Paquier writes: > On Fri, May 24, 2024 at 02:09:49PM +0900, Michael Paquier wrote: >> For now, I have staged for commit the attached, that handles most of >> the changes from Alexander (msvc could go for more cleanup?). > > This one has been applied as of 0c1aca461481 now that v18 is > open. > >> I'll look at the changes from Dagfinn after that, including if perlcritic >> could be changed. I'll handle the first part when v18 opens up, as >> that's cosmetic. For clarity, I've rebased my addional unused-variable changes (except the errcodes-related ones, see below) onto current master, and split it into separate commits with detailed explaiations for each file file, see attached. > I'm still biased about the second set of changes proposed here, > though. ProhibitUnusedVariables would have benefits when writing perl > code in terms of clarity because we would avoid useless stuff, but it > seems to me that we should put more efforts into the unification of > the errcodes parsing paths first to have a cleaner long-term picture. > > That's not directly the fault of this proposal that we have the same > parsing rules spread across three PL languages, so perhaps what's > proposed is fine as-is, at the end. It turns out there are a couple more places that parse errcodes.txt, namely doc/src/sgml/generate-errcodes-table.pl and src/backend/utils/generate-errcodes.pl. I'll have a go refactoring all of these into a common function à la Catalog::ParseHeader() that returns a data structure these scripts can use as as appropriate. > Any thoughts or comments from others more familiar with > ProhibitUnusedVariables? Relatedly, I also had a look at prohibiting unused regex captures (RegularExpressions::ProhibitUnusedCapture), which found a few real cases, but also lots of false positives in Catalog.pm, because it doesn't understand that %+ uses all named captures, so I won't propose a patch for that until that's fixed upstream (https://github.com/Perl-Critic/Perl-Critic/pull/1065). - ilmari --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Remove-unused-variables-in-libq-encryption-negotiati.patch From 8e3c7721da86a670b279bb24b0fe9ae82351628f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Tue, 2 Jul 2024 13:25:16 +0100 Subject: [PATCH 1/3] Remove unused variables in libq encryption negotiation test The $node_conf parameter to test_matrix() was only ever used to set the %params hash (removed in commit d39a49c1e4598048), but that hash was itself never used for anything, so it (and the $server_config) hash were always useless. --- .../libpq/t/005_negotiate_encryption.pl | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/interfaces/libpq/t/005_negotiate_encryption.pl b/src/interfaces/libpq/t/005_negotiate_encryption.pl index c3f70d31bc..251c405926 100644 --- a/src/interfaces/libpq/t/005_negotiate_encryption.pl +++ b/src/interfaces/libpq/t/005_negotiate_encryption.pl @@ -215,11 +215,6 @@ BEGIN my @all_sslmodes = ('disable', 'allow', 'prefer', 'require'); my @all_sslnegotiations = ('postgres', 'direct'); -my $server_config = { - server_ssl => 0, - server_gss => 0, -}; - ### ### Run tests with GSS and SSL disabled in the server ### @@ -272,7 +267,7 @@ BEGIN }; note("Running tests with SSL and GSS disabled in the server"); -test_matrix($node, $server_config, +test_matrix($node, ['testuser'], \@all_gssencmodes, \@all_sslmodes, \@all_sslnegotiations, parse_table($test_table)); @@ -311,19 +306,15 @@ BEGIN # Enable SSL in the server $node->adjust_conf('postgresql.conf', 'ssl', 'on'); $node->reload; - $server_config->{server_ssl} = 1; note("Running tests with SSL enabled in server"); - test_matrix( - $node, $server_config, - [ 'testuser', 'ssluser', 'nossluser' ], ['disable'], - \@all_sslmodes, \@all_sslnegotiations, + test_matrix($node, [ 'testuser', 'ssluser', 'nossluser' ], + ['disable'], \@all_sslmodes, \@all_sslnegotiations, parse_table($test_table)); # Disable SSL again $node->adjust_conf('postgresql.conf', 'ssl', 'off'); $node->reload; - $server_config->{server_ssl} = 0; } ### @@ -336,7 +327,6 @@ BEGIN $krb->create_principal('gssuser', $gssuser_password); $krb->create_ticket('gssuser', $gssuser_password); - $server_config->{server_gss} = 1; $test_table = q{ # USER GSSENCMODE SSLMODE SSLNEGOTIATION EVENTS -> OUTCOME @@ -400,7 +390,7 @@ BEGIN } note("Running tests with GSS enabled in server"); - test_matrix($node, $server_config, [ 'testuser', 'gssuser', 'nogssuser' ], + test_matrix($node, [ 'testuser', 'gssuser', 'nogssuser' ], \@all_gssencmodes, $sslmodes, $sslnegotiations, parse_table($test_table)); } @@ -423,7 +413,6 @@ BEGIN # Enable SSL $node->adjust_conf('postgresql.conf', 'ssl', 'on'); $node->reload; - $server_config->{server_ssl} = 1; $test_table = q{ # USER GSSENCMODE SSLMODE SSLNEGOTIATION EVENTS -> OUTCOME @@ -510,7 +499,6 @@ BEGIN note("Running tests with both GSS and SSL enabled in server"); test_matrix( $node, - $server_config, [ 'testuser', 'gssuser', 'ssluser', 'nogssuser', 'nossluser' ], \@all_gssencmodes, \@all_sslmodes, @@ -546,8 +534,8 @@ sub test_matrix { local $Test::Builder::Level = $Test::Builder::Level + 1; - my ($pg_node, $node_conf, - $test_users, $gssencmodes, $sslmodes, $sslnegotiations, %expected) + my ($pg_node, $test_users, $gssencmodes, $sslmodes, $sslnegotiations, + %expected) = @_; foreach my $test_user (@{$test_users}) -- 2.39.2 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0002-msvc_gendef.pl-Remove-unused-variable.patch From 7127c5a8a45bdb1549fbd99cd37523fc1f848169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Tue, 2 Jul 2024 13:35:48 +0100 Subject: [PATCH 2/3] msvc_gendef.pl: Remove unused variable Commit a5eed4d770674904 swithced to using a hash instead of an array for the defs, but neglected to remove the unused variable. --- src/tools/msvc_gendef.pl | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/tools/msvc_gendef.pl b/src/tools/msvc_gendef.pl index 404076dbbc..97346cc892 100644 --- a/src/tools/msvc_gendef.pl +++ b/src/tools/msvc_gendef.pl @@ -6,8 +6,6 @@ use List::Util qw(min); use Getopt::Long; -my @def; - # # Script that generates a .DEF file for all objects in a directory # -- 2.39.2 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0003-pgindent-remove-unused-variable.patch From ef4aed0fb3fe7d96662b0b9a5c6b5998916d9d4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dagfinn=20Ilmari=20Manns=C3=A5ker?= Date: Tue, 2 Jul 2024 13:37:54 +0100 Subject: [PATCH 3/3] pgindent: remove unused variable Commit b16259b3c1897cf9 removed the --build option, but neglected to remove the corresponding $build variable. --- src/tools/pgindent/pgindent | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/pgindent/pgindent b/src/tools/pgindent/pgindent index 48d83bc434..063ec8ce63 100755 --- a/src/tools/pgindent/pgindent +++ b/src/tools/pgindent/pgindent @@ -22,7 +22,7 @@ my $indent_opts = my $devnull = File::Spec->devnull; my ($typedefs_file, $typedef_str, @excludes, - $indent, $build, $diff, + $indent, $diff, $check, $help, @commits,); $help = 0; -- 2.39.2 --=-=-=--