@matheusbsbs / matheus-bagliano / commits / fd499bcc9d
Fork 0

git-svn: use "no warnings 'once'" to disable false-positives

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'". [ew: minor formatting change] Signed-off-by: Eygene Ryabinkin <rea-git@codelabs.ru> Acked-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Eygene Ryabinkin committed Oct 15, 2007 at 11:19 UTC fd499bcc9d749db7c2108802701f6a1195e4a958
1 file changed +43 -44
git-svn.perl
+43 -44
@@ -2303,23 +2303,31 @@ sub ssl_server_trust {
2303 my ($cred, $realm, $failures, $cert_info, $may_save, $pool) = @_;
2304 $may_save = undef if $_no_auth_cache;
2305 print STDERR "Error validating server certificate for '$realm':\n";
2306 - if ($failures & $SVN::Auth::SSL::UNKNOWNCA) {
2307 - print STDERR " - The certificate is not issued by a trusted ",
2308 - "authority. Use the\n",
2309 - " fingerprint to validate the certificate manually!\n";
2310 - }
2311 - if ($failures & $SVN::Auth::SSL::CNMISMATCH) {
2312 - print STDERR " - The certificate hostname does not match.\n";
2313 - }
2314 - if ($failures & $SVN::Auth::SSL::NOTYETVALID) {
2315 - print STDERR " - The certificate is not yet valid.\n";
2316 - }
2317 - if ($failures & $SVN::Auth::SSL::EXPIRED) {
2318 - print STDERR " - The certificate has expired.\n";
2319 - }
2320 - if ($failures & $SVN::Auth::SSL::OTHER) {
2321 - print STDERR " - The certificate has an unknown error.\n";
2322 - }
2306 + {
2307 + no warnings 'once';
2308 + # All variables SVN::Auth::SSL::* are used only once,
2309 + # so we're shutting up Perl warnings about this.
2310 + if ($failures & $SVN::Auth::SSL::UNKNOWNCA) {
2311 + print STDERR " - The certificate is not issued ",
2312 + "by a trusted authority. Use the\n",
2313 + " fingerprint to validate ",
2314 + "the certificate manually!\n";
2315 + }
2316 + if ($failures & $SVN::Auth::SSL::CNMISMATCH) {
2317 + print STDERR " - The certificate hostname ",
2318 + "does not match.\n";
2319 + }
2320 + if ($failures & $SVN::Auth::SSL::NOTYETVALID) {
2321 + print STDERR " - The certificate is not yet valid.\n";
2322 + }
2323 + if ($failures & $SVN::Auth::SSL::EXPIRED) {
2324 + print STDERR " - The certificate has expired.\n";
2325 + }
2326 + if ($failures & $SVN::Auth::SSL::OTHER) {
2327 + print STDERR " - The certificate has ",
2328 + "an unknown error.\n";
2329 + }
2330 + } # no warnings 'once'
2331 printf STDERR
2332 "Certificate information:\n".
2333 " - Hostname: %s\n".
@@ -2403,20 +2411,6 @@ sub _read_password {
2411 $password;
2412 }
2413
2406 -package main;
2407 -
2408 -{
2409 - my $kill_stupid_warnings = $SVN::Node::none.$SVN::Node::file.
2410 - $SVN::Node::dir.$SVN::Node::unknown.
2411 - $SVN::Node::none.$SVN::Node::file.
2412 - $SVN::Node::dir.$SVN::Node::unknown.
2413 - $SVN::Auth::SSL::CNMISMATCH.
2414 - $SVN::Auth::SSL::NOTYETVALID.
2415 - $SVN::Auth::SSL::EXPIRED.
2416 - $SVN::Auth::SSL::UNKNOWNCA.
2417 - $SVN::Auth::SSL::OTHER;
2418 -}
2419 -
2414 package SVN::Git::Fetcher;
2415 use vars qw/@ISA/;
2416 use strict;
@@ -2833,16 +2827,21 @@ sub open_or_add_dir {
2827 if (!defined $t) {
2828 die "$full_path not known in r$self->{r} or we have a bug!\n";
2829 }
2836 - if ($t == $SVN::Node::none) {
2837 - return $self->add_directory($full_path, $baton,
2838 - undef, -1, $self->{pool});
2839 - } elsif ($t == $SVN::Node::dir) {
2840 - return $self->open_directory($full_path, $baton,
2841 - $self->{r}, $self->{pool});
2842 - }
2843 - print STDERR "$full_path already exists in repository at ",
2844 - "r$self->{r} and it is not a directory (",
2845 - ($t == $SVN::Node::file ? 'file' : 'unknown'),"/$t)\n";
2830 + {
2831 + no warnings 'once';
2832 + # SVN::Node::none and SVN::Node::file are used only once,
2833 + # so we're shutting up Perl's warnings about them.
2834 + if ($t == $SVN::Node::none) {
2835 + return $self->add_directory($full_path, $baton,
2836 + undef, -1, $self->{pool});
2837 + } elsif ($t == $SVN::Node::dir) {
2838 + return $self->open_directory($full_path, $baton,
2839 + $self->{r}, $self->{pool});
2840 + } # no warnings 'once'
2841 + print STDERR "$full_path already exists in repository at ",
2842 + "r$self->{r} and it is not a directory (",
2843 + ($t == $SVN::Node::file ? 'file' : 'unknown'),"/$t)\n";
2844 + } # no warnings 'once'
2845 exit 1;
2846 }
2847
@@ -3068,11 +3067,11 @@ sub new {
3067 my $dont_store_passwords = 1;
3068 my $conf_t = ${$config}{'config'};
3069 {
3070 + no warnings 'once';
3071 # The usage of $SVN::_Core::SVN_CONFIG_* variables
3072 # produces warnings that variables are used only once.
3073 # I had not found the better way to shut them up, so
3074 - # warnings are disabled in this block.
3075 - no warnings;
3074 + # the warnings of type 'once' are disabled in this block.
3075 if (SVN::_Core::svn_config_get_bool($conf_t,
3076 $SVN::_Core::SVN_CONFIG_SECTION_AUTH,
3077 $SVN::_Core::SVN_CONFIG_OPTION_STORE_PASSWORDS,
@@ -3087,7 +3086,7 @@ sub new {
3086 1) == 0) {
3087 $Git::SVN::Prompt::_no_auth_cache = 1;
3088 }
3090 - }
3089 + } # no warnings 'once'
3090 my $self = SVN::Ra->new(url => $url, auth => $baton,
3091 config => $config,
3092 pool => SVN::Pool->new,