All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eygene Ryabinkin <rea-git@codelabs.ru>
To: git@vger.kernel.org
Cc: normalperson@yhbt.net
Subject: [PATCH] git-svn: use "no warnings 'once'" to disable false-positives
Date: Mon, 15 Oct 2007 11:19:12 +0400	[thread overview]
Message-ID: <20071015071912.GG984@void.codelabs.ru> (raw)

Some variables coming from the Subversion's Perl bindings are used
in our code only once, so the interpreter warns us about it.  These
warnings are false-positives, because the variables themselves are
initialized in the binding's guts, that are made by SWIG.

Credits to Sam Vilain for his note about "no warnings 'once'".

Signed-off-by: Eygene Ryabinkin <rea-git@codelabs.ru>
---
 git-svn.perl |   86 +++++++++++++++++++++++++++------------------------------
 1 files changed, 41 insertions(+), 45 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index f7ef421..39a70bf 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2293,23 +2293,30 @@ sub ssl_server_trust {
 	my ($cred, $realm, $failures, $cert_info, $may_save, $pool) = @_;
 	$may_save = undef if $_no_auth_cache;
 	print STDERR "Error validating server certificate for '$realm':\n";
-	if ($failures & $SVN::Auth::SSL::UNKNOWNCA) {
-		print STDERR " - The certificate is not issued by a trusted ",
-		      "authority. Use the\n",
-	              "   fingerprint to validate the certificate manually!\n";
-	}
-	if ($failures & $SVN::Auth::SSL::CNMISMATCH) {
-		print STDERR " - The certificate hostname does not match.\n";
-	}
-	if ($failures & $SVN::Auth::SSL::NOTYETVALID) {
-		print STDERR " - The certificate is not yet valid.\n";
-	}
-	if ($failures & $SVN::Auth::SSL::EXPIRED) {
-		print STDERR " - The certificate has expired.\n";
-	}
-	if ($failures & $SVN::Auth::SSL::OTHER) {
-		print STDERR " - The certificate has an unknown error.\n";
-	}
+	{ no warnings 'once';
+		# All variables SVN::Auth::SSL::* are used only once,
+		# so we're shutting up Perl warnings about this.
+		if ($failures & $SVN::Auth::SSL::UNKNOWNCA) {
+			print STDERR " - The certificate is not issued ",
+			    "by a trusted authority. Use the\n",
+			    "   fingerprint to validate ",
+			    "the certificate manually!\n";
+		}
+		if ($failures & $SVN::Auth::SSL::CNMISMATCH) {
+			print STDERR " - The certificate hostname ",
+			    "does not match.\n";
+		}
+		if ($failures & $SVN::Auth::SSL::NOTYETVALID) {
+			print STDERR " - The certificate is not yet valid.\n";
+		}
+		if ($failures & $SVN::Auth::SSL::EXPIRED) {
+			print STDERR " - The certificate has expired.\n";
+		}
+		if ($failures & $SVN::Auth::SSL::OTHER) {
+			print STDERR " - The certificate has ",
+			    "an unknown error.\n";
+		}
+	} # no warnings 'once'
 	printf STDERR
 	        "Certificate information:\n".
 	        " - Hostname: %s\n".
@@ -2393,20 +2400,6 @@ sub _read_password {
 	$password;
 }
 
-package main;
-
-{
-	my $kill_stupid_warnings = $SVN::Node::none.$SVN::Node::file.
-				$SVN::Node::dir.$SVN::Node::unknown.
-				$SVN::Node::none.$SVN::Node::file.
-				$SVN::Node::dir.$SVN::Node::unknown.
-				$SVN::Auth::SSL::CNMISMATCH.
-				$SVN::Auth::SSL::NOTYETVALID.
-				$SVN::Auth::SSL::EXPIRED.
-				$SVN::Auth::SSL::UNKNOWNCA.
-				$SVN::Auth::SSL::OTHER;
-}
-
 package SVN::Git::Fetcher;
 use vars qw/@ISA/;
 use strict;
@@ -2823,16 +2816,20 @@ sub open_or_add_dir {
 	if (!defined $t) {
 		die "$full_path not known in r$self->{r} or we have a bug!\n";
 	}
-	if ($t == $SVN::Node::none) {
-		return $self->add_directory($full_path, $baton,
-						undef, -1, $self->{pool});
-	} elsif ($t == $SVN::Node::dir) {
-		return $self->open_directory($full_path, $baton,
-						$self->{r}, $self->{pool});
-	}
-	print STDERR "$full_path already exists in repository at ",
-		"r$self->{r} and it is not a directory (",
-		($t == $SVN::Node::file ? 'file' : 'unknown'),"/$t)\n";
+	{ no warnings 'once';
+		# SVN::Node::none and SVN::Node::file are used only once,
+		# so we're shutting up Perl's warnings about them.
+		if ($t == $SVN::Node::none) {
+			return $self->add_directory($full_path, $baton,
+			    undef, -1, $self->{pool});
+		} elsif ($t == $SVN::Node::dir) {
+			return $self->open_directory($full_path, $baton,
+			    $self->{r}, $self->{pool});
+		} # no warnings 'once'
+		print STDERR "$full_path already exists in repository at ",
+		    "r$self->{r} and it is not a directory (",
+		    ($t == $SVN::Node::file ? 'file' : 'unknown'),"/$t)\n";
+	} # no warnings 'once'
 	exit 1;
 }
 
@@ -3053,12 +3050,11 @@ sub new {
 	$RA = undef;
 	my $dont_store_passwords = 1;
 	my $conf_t = ${$config}{'config'};
-	{
+	{ no warnings 'once';
 		# The usage of $SVN::_Core::SVN_CONFIG_* variables
 		# produces warnings that variables are used only once.
 		# I had not found the better way to shut them up, so
-		# warnings are disabled in this block.
-		no warnings;
+		# the warnings of type 'once' are disabled in this block.
 		if (SVN::_Core::svn_config_get_bool($conf_t,
 		    $SVN::_Core::SVN_CONFIG_SECTION_AUTH,
 		    $SVN::_Core::SVN_CONFIG_OPTION_STORE_PASSWORDS,
@@ -3073,7 +3069,7 @@ sub new {
 		    1) == 0) {
 			$Git::SVN::Prompt::_no_auth_cache = 1;
 		}
-	}
+	} # no warnings 'once'
 	my $self = SVN::Ra->new(url => $url, auth => $baton,
 	                      config => $config,
 			      pool => SVN::Pool->new,
-- 
1.5.3.2

             reply	other threads:[~2007-10-15  7:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-15  7:19 Eygene Ryabinkin [this message]
2007-10-16  7:43 ` [PATCH] git-svn: use "no warnings 'once'" to disable false-positives Eric Wong
2007-10-16 16:50   ` Eygene Ryabinkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20071015071912.GG984@void.codelabs.ru \
    --to=rea-git@codelabs.ru \
    --cc=git@vger.kernel.org \
    --cc=normalperson@yhbt.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.