ソースを参照

perl: Try to avoid boolean operators after predicates on error checks

Using boolean operators after predicates for error checking makes the
code flow slightly confusing, do that only after actions, to check if
they succeeded and error out otherwise.
Guillem Jover 12 年 前
コミット
ee37c9202b

+ 8 - 5
dselect/methods/disk/install

@@ -63,10 +63,11 @@ do
 			@filename= split(/ /,$_) if s/^Filename: //i;
 			@filename= split(/ /,$_) if s/^Filename: //i;
 			@msdosfilename= split(/ /,$_) if s/^MSDOS-Filename: //i;
 			@msdosfilename= split(/ /,$_) if s/^MSDOS-Filename: //i;
 		}
 		}
-		length($package) || die "internal error - no package";
-		@filename || die "internal error - no filename";
-		@filename==@msdosfilename || !@filename || !@msdosfilename ||
-			die "internal error - mismatch >@filename< >@msdosfilename<";
+		die "internal error - no package" if length($package) == 0;
+		die "internal error - no filename" if not @filename;
+		die "internal error - mismatch >@filename< >@msdosfilename<"
+			if @filename && @msdosfilename &&
+			   @filename != @msdosfilename;
 		@invoke=(); $|=1;
 		@invoke=(); $|=1;
 		for ($i=0; $i<=$#filename; $i++) {
 		for ($i=0; $i<=$#filename; $i++) {
 			$ppart= $i+1;
 			$ppart= $i+1;
@@ -80,8 +81,10 @@ do
 			} else {
 			} else {
 				$base= $filename[$i]; $base =~ s,.*/,,;
 				$base= $filename[$i]; $base =~ s,.*/,,;
 				$msdosbase= $msdosfilename[$i]; $msdosbase =~ s,.*/,,;
 				$msdosbase= $msdosfilename[$i]; $msdosbase =~ s,.*/,,;
-				defined($c= open(X,"-|")) ||
+				$c = open(X, "-|"));
+				if (not defined $c) {
 					die "failed to fork for find: $!\n";
 					die "failed to fork for find: $!\n";
+				}
 				if (!$c) {
 				if (!$c) {
 					exec("find", "-L",
 					exec("find", "-L",
 					     length($binaryprefix) ?
 					     length($binaryprefix) ?

+ 8 - 5
dselect/methods/multicd/install

@@ -118,10 +118,11 @@ do
 			@filename= split(/ /,$_) if s/^Filename: //i;
 			@filename= split(/ /,$_) if s/^Filename: //i;
 			@msdosfilename= split(/ /,$_) if s/^MSDOS-Filename: //i;
 			@msdosfilename= split(/ /,$_) if s/^MSDOS-Filename: //i;
 		}
 		}
-		length($package) || die "internal error - no package";
-		@filename || die "internal error - no filename";
-		@filename==@msdosfilename || !@filename || !@msdosfilename ||
-			die "internal error - mismatch >@filename< >@msdosfilename<";
+		die "internal error - no package" if length($package) == 0;
+		die "internal error - no filename" if not @filename;
+		die "internal error - mismatch >@filename< >@msdosfilename<"
+			if @filename && @msdosfilename &&
+			   @filename != @msdosfilename;
 		if ($medium && ($medium ne $thisdisk)) {
 		if ($medium && ($medium ne $thisdisk)) {
 			print "
 			print "
 
 
@@ -147,8 +148,10 @@ Please change the discs and press <RETURN>.
 			} else {
 			} else {
 				$base= $filename[$i]; $base =~ s,.*/,,;
 				$base= $filename[$i]; $base =~ s,.*/,,;
 				$msdosbase= $msdosfilename[$i]; $msdosbase =~ s,.*/,,;
 				$msdosbase= $msdosfilename[$i]; $msdosbase =~ s,.*/,,;
-				defined($c= open(X,"-|")) ||
+				$c = open(X, "-|"));
+				if (not defined $c) {
 					die "failed to fork for find: $!\n";
 					die "failed to fork for find: $!\n";
+				}
 				if (!$c) {
 				if (!$c) {
 					exec("find", "-L",
 					exec("find", "-L",
 					     length($binaryprefix) ? $binaryprefix : ".",
 					     length($binaryprefix) ? $binaryprefix : ".",

+ 7 - 4
dselect/mkcurkeys.pl

@@ -23,7 +23,7 @@ use warnings;
 
 
 use Scalar::Util qw(looks_like_number);
 use Scalar::Util qw(looks_like_number);
 
 
-$#ARGV == 1 || die('usage: mkcurkeys.pl <filename> <curses.h>');
+die 'usage: mkcurkeys.pl <filename> <curses.h>' if @ARGV != 2;
 
 
 my (%over, %base, %name);
 my (%over, %base, %name);
 
 
@@ -32,9 +32,12 @@ while (<$override_fh>) {
     chomp;
     chomp;
     /^#/ && next; # skip comments
     /^#/ && next; # skip comments
     /\S/ || next; # ignore blank lines
     /\S/ || next; # ignore blank lines
-    /^(\w+)\s+(\S.*\S)\s*$/ || die ("cannot parse line:\n$_\n");
-    $over{$1}= $2;
-    $base{$1}= '';
+    if (/^(\w+)\s+(\S.*\S)\s*$/) {
+        $over{$1} = $2;
+        $base{$1} = '';
+    } else {
+        die "cannot parse line:\n$_\n";
+    }
 }
 }
 close($override_fh);
 close($override_fh);
 
 

+ 2 - 1
scripts/Dpkg/Control/HashCore.pm

@@ -224,9 +224,10 @@ sub parse {
 	    if ($expect_pgp_sig) {
 	    if ($expect_pgp_sig) {
 		# Skip empty lines
 		# Skip empty lines
 		$_ = <$fh> while defined($_) && $_ =~ /^\s*$/;
 		$_ = <$fh> while defined($_) && $_ =~ /^\s*$/;
-		length($_) ||
+		unless (length $_) {
 		    $self->parse_error($desc, _g('expected PGP signature, ' .
 		    $self->parse_error($desc, _g('expected PGP signature, ' .
 		                                 'found EOF after blank line'));
 		                                 'found EOF after blank line'));
+		}
 		s/\s*\n$//;
 		s/\s*\n$//;
 		unless (m/^-----BEGIN PGP SIGNATURE-----$/) {
 		unless (m/^-----BEGIN PGP SIGNATURE-----$/) {
 		    $self->parse_error($desc, _g('expected PGP signature, ' .
 		    $self->parse_error($desc, _g('expected PGP signature, ' .

+ 6 - 3
scripts/Dpkg/Package.pm

@@ -29,12 +29,15 @@ our @EXPORT = qw(pkg_name_is_illegal);
 sub pkg_name_is_illegal($) {
 sub pkg_name_is_illegal($) {
     my $name = shift || '';
     my $name = shift || '';
 
 
-    $name eq '' &&
+    if ($name eq '') {
         return _g('may not be empty string');
         return _g('may not be empty string');
-    $name =~ m/[^-+.0-9a-z]/o &&
+    }
+    if ($name =~ m/[^-+.0-9a-z]/o) {
         return sprintf(_g("character '%s' not allowed"), $&);
         return sprintf(_g("character '%s' not allowed"), $&);
-    $name =~ m/^[0-9a-z]/o ||
+    }
+    if ($name !~ m/^[0-9a-z]/o) {
         return _g('must start with an alphanumeric character');
         return _g('must start with an alphanumeric character');
+    }
 
 
     return;
     return;
 }
 }

+ 5 - 1
scripts/Dpkg/Shlibs/SymbolFile.pm

@@ -385,7 +385,11 @@ sub find_matching_pattern {
 # machinery
 # machinery
 sub merge_symbols {
 sub merge_symbols {
     my ($self, $object, $minver) = @_;
     my ($self, $object, $minver) = @_;
-    my $soname = $object->{SONAME} || error(_g('cannot merge symbols from objects without SONAME'));
+
+    my $soname = $object->{SONAME};
+    error(_g('cannot merge symbols from objects without SONAME'))
+        unless $soname;
+
     my %dynsyms;
     my %dynsyms;
     foreach my $sym ($object->get_exported_dynamic_symbols()) {
     foreach my $sym ($object->get_exported_dynamic_symbols()) {
         my $name = $sym->{name} . '@' .
         my $name = $sym->{name} . '@' .

+ 4 - 2
scripts/Dpkg/Source/Package/V1.pm

@@ -81,9 +81,10 @@ sub do_extract {
     my $fields = $self->{fields};
     my $fields = $self->{fields};
 
 
     $sourcestyle =~ y/X/p/;
     $sourcestyle =~ y/X/p/;
-    $sourcestyle =~ m/[pun]/ ||
+    unless ($sourcestyle =~ m/[pun]/) {
 	usageerr(_g('source handling style -s%s not allowed with -x'),
 	usageerr(_g('source handling style -s%s not allowed with -x'),
 	         $sourcestyle);
 	         $sourcestyle);
+    }
 
 
     my $dscdir = $self->{basedir};
     my $dscdir = $self->{basedir};
 
 
@@ -236,10 +237,11 @@ sub do_build {
             }
             }
         } else {
         } else {
             $sourcestyle =~ y/aA/nn/;
             $sourcestyle =~ y/aA/nn/;
-            $sourcestyle =~ m/n/ ||
+            unless ($sourcestyle =~ m/n/) {
                 error(_g('orig argument is empty (means no orig, no diff) ' .
                 error(_g('orig argument is empty (means no orig, no diff) ' .
                          'but source handling style -s%s wants something'),
                          'but source handling style -s%s wants something'),
                       $sourcestyle);
                       $sourcestyle);
+            }
         }
         }
     } elsif ($sourcestyle =~ m/[aA]/) {
     } elsif ($sourcestyle =~ m/[aA]/) {
 	# We have no explicit <orig-dir> or <orig-targz>, try to use
 	# We have no explicit <orig-dir> or <orig-targz>, try to use

+ 1 - 1
scripts/Dpkg/Source/Package/V3/Bzr.pm

@@ -141,7 +141,7 @@ sub do_build {
     my $tardir = "$tmp/$dirname";
     my $tardir = "$tmp/$dirname";
 
 
     system('bzr', 'branch', $dir, $tardir);
     system('bzr', 'branch', $dir, $tardir);
-    $? && subprocerr("bzr branch $dir $tardir");
+    subprocerr("bzr branch $dir $tardir") if $?;
 
 
     # Remove the working tree.
     # Remove the working tree.
     system('bzr', 'remove-tree', $tardir);
     system('bzr', 'remove-tree', $tardir);

+ 5 - 5
scripts/Dpkg/Source/Package/V3/Git.pm

@@ -152,12 +152,12 @@ sub do_build {
                 $self->{options}{git_depth});
                 $self->{options}{git_depth});
         system('git', 'clone', '--depth=' . $self->{options}{git_depth},
         system('git', 'clone', '--depth=' . $self->{options}{git_depth},
                '--quiet', '--bare', 'file://' . abs_path($dir), $clone_dir);
                '--quiet', '--bare', 'file://' . abs_path($dir), $clone_dir);
-        $? && subprocerr('git clone');
+        subprocerr('git clone') if $?;
         chdir($clone_dir) ||
         chdir($clone_dir) ||
                 syserr(_g("unable to chdir to `%s'"), $clone_dir);
                 syserr(_g("unable to chdir to `%s'"), $clone_dir);
         $shallowfile = "$basenamerev.gitshallow";
         $shallowfile = "$basenamerev.gitshallow";
         system('cp', '-f', 'shallow', "$old_cwd/$shallowfile");
         system('cp', '-f', 'shallow', "$old_cwd/$shallowfile");
-        $? && subprocerr('cp shallow');
+        subprocerr('cp shallow') if $?;
     }
     }
 
 
     # Create the git bundle.
     # Create the git bundle.
@@ -170,7 +170,7 @@ sub do_build {
            'HEAD', # ensure HEAD is included no matter what
            'HEAD', # ensure HEAD is included no matter what
            '--', # avoids ambiguity error when referring to eg, a debian branch
            '--', # avoids ambiguity error when referring to eg, a debian branch
     );
     );
-    $? && subprocerr('git bundle');
+    subprocerr('git bundle') if $?;
 
 
     chdir($old_cwd) ||
     chdir($old_cwd) ||
         syserr(_g("unable to chdir to `%s'"), $old_cwd);
         syserr(_g("unable to chdir to `%s'"), $old_cwd);
@@ -221,14 +221,14 @@ sub do_extract {
     # Extract git bundle.
     # Extract git bundle.
     info(_g('cloning %s'), $bundle);
     info(_g('cloning %s'), $bundle);
     system('git', 'clone', '--quiet', $dscdir . $bundle, $newdirectory);
     system('git', 'clone', '--quiet', $dscdir . $bundle, $newdirectory);
-    $? && subprocerr('git bundle');
+    subprocerr('git bundle') if $?;
 
 
     if (defined $shallow) {
     if (defined $shallow) {
         # Move shallow info file into place, so git does not
         # Move shallow info file into place, so git does not
         # try to follow parents of shallow refs.
         # try to follow parents of shallow refs.
         info(_g('setting up shallow clone'));
         info(_g('setting up shallow clone'));
         system('cp', '-f',  $dscdir . $shallow, "$newdirectory/.git/shallow");
         system('cp', '-f',  $dscdir . $shallow, "$newdirectory/.git/shallow");
-        $? && subprocerr('cp');
+        subprocerr('cp') if $?;
     }
     }
 
 
     sanity_check($newdirectory);
     sanity_check($newdirectory);

+ 10 - 4
scripts/Dpkg/Source/Patch.pm

@@ -169,18 +169,23 @@ sub add_diff_directory {
                 $self->_fail_not_same_type("$old/$fn", "$new/$fn");
                 $self->_fail_not_same_type("$old/$fn", "$new/$fn");
                 return;
                 return;
             }
             }
-            defined(my $n = readlink("$new/$fn")) ||
+            my $n = readlink("$new/$fn");
+            unless (defined $n) {
                 syserr(_g('cannot read link %s'), "$new/$fn");
                 syserr(_g('cannot read link %s'), "$new/$fn");
-            defined(my $n2 = readlink("$old/$fn")) ||
+            }
+            my $n2 = readlink("$old/$fn");
+            unless (defined $n2) {
                 syserr(_g('cannot read link %s'), "$old/$fn");
                 syserr(_g('cannot read link %s'), "$old/$fn");
+            }
             unless ($n eq $n2) {
             unless ($n eq $n2) {
                 $self->_fail_not_same_type("$old/$fn", "$new/$fn");
                 $self->_fail_not_same_type("$old/$fn", "$new/$fn");
             }
             }
         } elsif (-f _) {
         } elsif (-f _) {
             my $old_file = "$old/$fn";
             my $old_file = "$old/$fn";
             if (not lstat("$old/$fn")) {
             if (not lstat("$old/$fn")) {
-                $! == ENOENT ||
+                if ($! != ENOENT) {
                     syserr(_g('cannot stat file %s'), "$old/$fn");
                     syserr(_g('cannot stat file %s'), "$old/$fn");
+                }
                 $old_file = '/dev/null';
                 $old_file = '/dev/null';
             } elsif (not -f _) {
             } elsif (not -f _) {
                 $self->_fail_not_same_type("$old/$fn", "$new/$fn");
                 $self->_fail_not_same_type("$old/$fn", "$new/$fn");
@@ -202,8 +207,9 @@ sub add_diff_directory {
                 _g('device or socket is not allowed'));
                 _g('device or socket is not allowed'));
         } elsif (-d _) {
         } elsif (-d _) {
             if (not lstat("$old/$fn")) {
             if (not lstat("$old/$fn")) {
-                $! == ENOENT ||
+                if ($! != ENOENT) {
                     syserr(_g('cannot stat file %s'), "$old/$fn");
                     syserr(_g('cannot stat file %s'), "$old/$fn");
+                }
             } elsif (not -d _) {
             } elsif (not -d _) {
                 $self->_fail_not_same_type("$old/$fn", "$new/$fn");
                 $self->_fail_not_same_type("$old/$fn", "$new/$fn");
             }
             }

+ 4 - 2
scripts/Dpkg/Substvars.pm

@@ -173,9 +173,10 @@ sub parse {
     while (<$fh>) {
     while (<$fh>) {
 	next if m/^\s*\#/ || !m/\S/;
 	next if m/^\s*\#/ || !m/\S/;
 	s/\s*\n$//;
 	s/\s*\n$//;
-	m/^(\w[-:0-9A-Za-z]*)\=(.*)$/ ||
+	if (! m/^(\w[-:0-9A-Za-z]*)\=(.*)$/) {
 	    error(_g('bad line in substvars file %s at line %d'),
 	    error(_g('bad line in substvars file %s at line %d'),
 		  $varlistfile, $.);
 		  $varlistfile, $.);
+	}
 	$self->{vars}{$1} = $2;
 	$self->{vars}{$1} = $2;
     }
     }
 }
 }
@@ -244,9 +245,10 @@ sub substvars {
         # reset the recursive counter.
         # reset the recursive counter.
         $count = 0 if (length($3) < length($rhs));
         $count = 0 if (length($3) < length($rhs));
 
 
-        $count < $maxsubsts ||
+        if ($count >= $maxsubsts) {
             error($opts{msg_prefix} .
             error($opts{msg_prefix} .
 	          _g("too many substitutions - recursive ? - in \`%s'"), $v);
 	          _g("too many substitutions - recursive ? - in \`%s'"), $v);
+        }
         $lhs = $1; $vn = $2; $rhs = $3;
         $lhs = $1; $vn = $2; $rhs = $3;
         if (defined($self->{vars}{$vn})) {
         if (defined($self->{vars}{$vn})) {
             $v = $lhs . $self->{vars}{$vn} . $rhs;
             $v = $lhs . $self->{vars}{$vn} . $rhs;

+ 4 - 5
scripts/Dpkg/Vars.pm

@@ -39,12 +39,11 @@ sub set_source_package {
     my $err = pkg_name_is_illegal($v);
     my $err = pkg_name_is_illegal($v);
     error(_g("source package name '%s' is illegal: %s"), $v, $err) if $err;
     error(_g("source package name '%s' is illegal: %s"), $v, $err) if $err;
 
 
-    if (defined($sourcepackage)) {
-        $v eq $sourcepackage ||
-            error(_g('source package has two conflicting values - %s and %s'),
-                  $sourcepackage, $v);
-    } else {
+    if (not defined($sourcepackage)) {
         $sourcepackage = $v;
         $sourcepackage = $v;
+    } elsif ($v ne $sourcepackage) {
+        error(_g('source package has two conflicting values - %s and %s'),
+              $sourcepackage, $v);
     }
     }
 }
 }
 
 

+ 7 - 5
scripts/dpkg-buildpackage.pl

@@ -204,33 +204,35 @@ while (@ARGV) {
     } elsif (/^-nc$/) {
     } elsif (/^-nc$/) {
 	$noclean = 1;
 	$noclean = 1;
     } elsif (/^-b$/) {
     } elsif (/^-b$/) {
-	build_sourceonly && usageerr(_g('cannot combine %s and %s'), $_, '-S');
+	usageerr(_g('cannot combine %s and %s'), $_, '-S') if build_sourceonly;
 	$include = BUILD_BINARY;
 	$include = BUILD_BINARY;
 	push @changes_opts, '-b';
 	push @changes_opts, '-b';
 	@checkbuilddep_opts = ();
 	@checkbuilddep_opts = ();
 	$buildtarget = 'build';
 	$buildtarget = 'build';
 	$binarytarget = 'binary';
 	$binarytarget = 'binary';
     } elsif (/^-B$/) {
     } elsif (/^-B$/) {
-	build_sourceonly && usageerr(_g('cannot combine %s and %s'), $_, '-S');
+	usageerr(_g('cannot combine %s and %s'), $_, '-S') if build_sourceonly;
 	$include = BUILD_ARCH_DEP;
 	$include = BUILD_ARCH_DEP;
 	push @changes_opts, '-B';
 	push @changes_opts, '-B';
 	@checkbuilddep_opts = qw(-B);
 	@checkbuilddep_opts = qw(-B);
 	$buildtarget = 'build-arch';
 	$buildtarget = 'build-arch';
 	$binarytarget = 'binary-arch';
 	$binarytarget = 'binary-arch';
     } elsif (/^-A$/) {
     } elsif (/^-A$/) {
-	build_sourceonly && usageerr(_g('cannot combine %s and %s'), $_, '-S');
+	usageerr(_g('cannot combine %s and %s'), $_, '-S') if build_sourceonly;
 	$include = BUILD_ARCH_INDEP;
 	$include = BUILD_ARCH_INDEP;
 	push @changes_opts, '-A';
 	push @changes_opts, '-A';
 	@checkbuilddep_opts = qw(-A);
 	@checkbuilddep_opts = qw(-A);
 	$buildtarget = 'build-indep';
 	$buildtarget = 'build-indep';
 	$binarytarget = 'binary-indep';
 	$binarytarget = 'binary-indep';
     } elsif (/^-S$/) {
     } elsif (/^-S$/) {
-	build_binaryonly && usageerr(_g('cannot combine %s and %s'), build_opt, '-S');
+	usageerr(_g('cannot combine %s and %s'), build_opt, '-S')
+	    if build_binaryonly;
 	$include = BUILD_SOURCE;
 	$include = BUILD_SOURCE;
 	push @changes_opts, '-S';
 	push @changes_opts, '-S';
 	@checkbuilddep_opts = qw(-A -B);
 	@checkbuilddep_opts = qw(-A -B);
     } elsif (/^-F$/) {
     } elsif (/^-F$/) {
-	!build_normal && usageerr(_g('cannot combine %s and %s'), $_, build_opt);
+	usageerr(_g('cannot combine %s and %s'), $_, build_opt)
+	    if not build_normal;
 	$include = BUILD_ALL;
 	$include = BUILD_ALL;
 	@checkbuilddep_opts = ();
 	@checkbuilddep_opts = ();
     } elsif (/^-v(.*)$/) {
     } elsif (/^-v(.*)$/) {

+ 1 - 1
scripts/dpkg-distaddfile.pl

@@ -68,8 +68,8 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
         usageerr(_g("unknown option \`%s'"), $_);
         usageerr(_g("unknown option \`%s'"), $_);
     }
     }
 }
 }
+usageerr(_g('need exactly a filename, section and priority')) if @ARGV != 3;
 
 
-@ARGV == 3 || usageerr(_g('need exactly a filename, section and priority'));
 my ($file, $section, $priority) = @ARGV;
 my ($file, $section, $priority) = @ARGV;
 
 
 ($file =~ m/\s/ || $section =~ m/\s/ || $priority =~ m/\s/) &&
 ($file =~ m/\s/ || $section =~ m/\s/ || $priority =~ m/\s/) &&

+ 28 - 26
scripts/dpkg-genchanges.pl

@@ -141,18 +141,19 @@ sub usage {
 while (@ARGV) {
 while (@ARGV) {
     $_=shift(@ARGV);
     $_=shift(@ARGV);
     if (m/^-b$/) {
     if (m/^-b$/) {
-	is_sourceonly && usageerr(_g('cannot combine %s and %s'), $_, '-S');
+	usageerr(_g('cannot combine %s and %s'), $_, '-S') if is_sourceonly;
 	$include = BIN;
 	$include = BIN;
     } elsif (m/^-B$/) {
     } elsif (m/^-B$/) {
-	is_sourceonly && usageerr(_g('cannot combine %s and %s'), $_, '-S');
+	usageerr(_g('cannot combine %s and %s'), $_, '-S') if is_sourceonly;
 	$include = ARCH_DEP;
 	$include = ARCH_DEP;
 	printf STDERR _g('%s: arch-specific upload - not including arch-independent packages') . "\n", $Dpkg::PROGNAME;
 	printf STDERR _g('%s: arch-specific upload - not including arch-independent packages') . "\n", $Dpkg::PROGNAME;
     } elsif (m/^-A$/) {
     } elsif (m/^-A$/) {
-	is_sourceonly && usageerr(_g('cannot combine %s and %s'), $_, '-S');
+	usageerr(_g('cannot combine %s and %s'), $_, '-S') if is_sourceonly;
 	$include = ARCH_INDEP;
 	$include = ARCH_INDEP;
 	printf STDERR _g('%s: arch-indep upload - not including arch-specific packages') . "\n", $Dpkg::PROGNAME;
 	printf STDERR _g('%s: arch-indep upload - not including arch-specific packages') . "\n", $Dpkg::PROGNAME;
     } elsif (m/^-S$/) {
     } elsif (m/^-S$/) {
-	is_binaryonly && usageerr(_g('cannot combine %s and %s'), binary_opt, '-S');
+	usageerr(_g('cannot combine %s and %s'), binary_opt, '-S')
+	    if is_binaryonly;
 	$include = SOURCE;
 	$include = SOURCE;
     } elsif (m/^-s([iad])$/) {
     } elsif (m/^-s([iad])$/) {
         $sourcestyle= $1;
         $sourcestyle= $1;
@@ -233,17 +234,16 @@ if (not is_sourceonly) {
         syserr(_g('cannot read files list file'));
         syserr(_g('cannot read files list file'));
     while(<$fileslist_fh>) {
     while(<$fileslist_fh>) {
 	if (m/^(([-+.0-9a-z]+)_([^_]+)_([-\w]+)\.u?deb) (\S+) (\S+)$/) {
 	if (m/^(([-+.0-9a-z]+)_([^_]+)_([-\w]+)\.u?deb) (\S+) (\S+)$/) {
-	    defined($p2f{"$2 $4"}) &&
-		warning(_g('duplicate files list entry for package %s (line %d)'),
-			$2, $.);
+	    warning(_g('duplicate files list entry for package %s (line %d)'),
+	            $2, $.) if defined $p2f{"$2 $4"};
 	    $f2p{$1}= $2;
 	    $f2p{$1}= $2;
 	    $pa2f{"$2 $4"}= $1;
 	    $pa2f{"$2 $4"}= $1;
 	    $p2f{$2} ||= [];
 	    $p2f{$2} ||= [];
 	    push @{$p2f{$2}}, $1;
 	    push @{$p2f{$2}}, $1;
 	    $p2ver{$2}= $3;
 	    $p2ver{$2}= $3;
-	    defined($f2sec{$1}) &&
-		warning(_g('duplicate files list entry for file %s (line %d)'),
-			$1, $.);
+
+	    warning(_g('duplicate files list entry for file %s (line %d)'),
+	            $1, $.) if defined $f2sec{$1};
 	    $f2sec{$1}= $5;
 	    $f2sec{$1}= $5;
 	    $f2pri{$1}= $6;
 	    $f2pri{$1}= $6;
 	    push(@archvalues, $4) if $4 and not $archadded{$4}++;
 	    push(@archvalues, $4) if $4 and not $archadded{$4}++;
@@ -255,9 +255,8 @@ if (not is_sourceonly) {
 	    push(@archvalues, $2) if $2 and not $archadded{$2}++;
 	    push(@archvalues, $2) if $2 and not $archadded{$2}++;
 	    push(@fileslistfiles,$1);
 	    push(@fileslistfiles,$1);
 	} elsif (m/^([-+.,_0-9a-zA-Z]+) (\S+) (\S+)$/) {
 	} elsif (m/^([-+.,_0-9a-zA-Z]+) (\S+) (\S+)$/) {
-	    defined($f2sec{$1}) &&
-		warning(_g('duplicate files list entry for file %s (line %d)'),
-			$1, $.);
+	    warning(_g('duplicate files list entry for file %s (line %d)'),
+	            $1, $.) if defined $f2sec{$1};
 	    $f2sec{$1}= $2;
 	    $f2sec{$1}= $2;
 	    $f2pri{$1}= $3;
 	    $f2pri{$1}= $3;
 	    push(@fileslistfiles,$1);
 	    push(@fileslistfiles,$1);
@@ -355,9 +354,9 @@ if ($changesdescription) {
 
 
 for my $pa (keys %pa2f) {
 for my $pa (keys %pa2f) {
     my ($pp, $aa) = (split / /, $pa);
     my ($pp, $aa) = (split / /, $pa);
-    defined($control->get_pkg_by_name($pp)) ||
-	warning(_g('package %s listed in files list but not in control info'),
-	        $pp);
+
+    warning(_g('package %s listed in files list but not in control info'), $pp)
+        unless defined $control->get_pkg_by_name($pp);
 }
 }
 
 
 for my $p (keys %p2f) {
 for my $p (keys %p2f) {
@@ -370,18 +369,21 @@ for my $p (keys %p2f) {
 	    $sec = '-';
 	    $sec = '-';
 	    warning(_g("missing Section for binary package %s; using '-'"), $p);
 	    warning(_g("missing Section for binary package %s; using '-'"), $p);
 	}
 	}
-	$sec eq $f2sec{$f} || error(_g('package %s has section %s in ' .
-				       'control file but %s in files list'),
-				    $p, $sec, $f2sec{$f});
+	if ($sec ne $f2sec{$f}) {
+	    error(_g('package %s has section %s in control file but %s in ' .
+	             'files list'), $p, $sec, $f2sec{$f});
+	}
+
 	my $pri = $f2pricf{$f};
 	my $pri = $f2pricf{$f};
 	$pri ||= $sourcedefault{'Priority'};
 	$pri ||= $sourcedefault{'Priority'};
 	if (!defined($pri)) {
 	if (!defined($pri)) {
 	    $pri = '-';
 	    $pri = '-';
 	    warning(_g("missing Priority for binary package %s; using '-'"), $p);
 	    warning(_g("missing Priority for binary package %s; using '-'"), $p);
 	}
 	}
-	$pri eq $f2pri{$f} || error(_g('package %s has priority %s in ' .
-				       'control file but %s in files list'),
-				    $p, $pri, $f2pri{$f});
+	if ($pri ne $f2pri{$f}) {
+	    error(_g('package %s has priority %s in control file but %s in ' .
+	             'files list'), $p, $pri, $f2pri{$f});
+	}
     }
     }
 }
 }
 
 
@@ -501,13 +503,13 @@ $fields->{'Maintainer'} = $forcemaint if defined($forcemaint);
 $fields->{'Changed-By'} = $forcechangedby if defined($forcechangedby);
 $fields->{'Changed-By'} = $forcechangedby if defined($forcechangedby);
 
 
 for my $f (qw(Version Distribution Maintainer Changes)) {
 for my $f (qw(Version Distribution Maintainer Changes)) {
-    defined($fields->{$f}) ||
-        error(_g('missing information for critical output field %s'), $f);
+    error(_g('missing information for critical output field %s'), $f)
+        unless defined $fields->{$f};
 }
 }
 
 
 for my $f (qw(Urgency)) {
 for my $f (qw(Urgency)) {
-    defined($fields->{$f}) ||
-        warning(_g('missing information for output field %s'), $f);
+    warning(_g('missing information for output field %s'), $f)
+        unless defined $fields->{$f};
 }
 }
 
 
 for my $f (keys %override) {
 for my $f (keys %override) {

+ 14 - 7
scripts/dpkg-gencontrol.pl

@@ -172,7 +172,9 @@ my $pkg;
 
 
 if (defined($oppackage)) {
 if (defined($oppackage)) {
     $pkg = $control->get_pkg_by_name($oppackage);
     $pkg = $control->get_pkg_by_name($oppackage);
-    defined($pkg) || error(_g('package %s not in control info'), $oppackage);
+    if (not defined $pkg) {
+        error(_g('package %s not in control info'), $oppackage)
+    }
 } else {
 } else {
     my @packages = map { $_->{'Package'} } $control->get_packages();
     my @packages = map { $_->{'Package'} } $control->get_packages();
     if (@packages == 0) {
     if (@packages == 0) {
@@ -296,10 +298,12 @@ foreach my $field (field_list_pkg_dep()) {
 }
 }
 
 
 for my $f (qw(Package Version)) {
 for my $f (qw(Package Version)) {
-    defined($fields->{$f}) || error(_g('missing information for output field %s'), $f);
+    error(_g('missing information for output field %s'), $f)
+        unless defined $fields->{$f};
 }
 }
 for my $f (qw(Maintainer Description Architecture)) {
 for my $f (qw(Maintainer Description Architecture)) {
-    defined($fields->{$f}) || warning(_g('missing information for output field %s'), $f);
+    warning(_g('missing information for output field %s'), $f)
+        unless defined $fields->{$f};
 }
 }
 $oppackage = $fields->{'Package'};
 $oppackage = $fields->{'Package'};
 
 
@@ -324,8 +328,10 @@ if ($oppackage ne $sourcepackage || $verdiff) {
 }
 }
 
 
 if (!defined($substvars->get('Installed-Size'))) {
 if (!defined($substvars->get('Installed-Size'))) {
-    my $du_fh;
-    defined(my $c = open($du_fh, '-|')) || syserr(_g('cannot fork for %s'), 'du');
+    my $c = open(my $du_fh, '-|');
+    if (not defined $c) {
+        syserr(_g('cannot fork for %s'), 'du');
+    }
     if (!$c) {
     if (!$c) {
         chdir("$packagebuilddir") ||
         chdir("$packagebuilddir") ||
             syserr(_g("chdir for du to \`%s'"), $packagebuilddir);
             syserr(_g("chdir for du to \`%s'"), $packagebuilddir);
@@ -337,9 +343,10 @@ if (!defined($substvars->get('Installed-Size'))) {
 	$duo .= $_;
 	$duo .= $_;
     }
     }
     close($du_fh);
     close($du_fh);
-    $? && subprocerr(_g("du in \`%s'"), $packagebuilddir);
-    $duo =~ m/^(\d+)\s+\.$/ ||
+    subprocerr(_g("du in \`%s'"), $packagebuilddir) if $?;
+    if ($duo !~ m/^(\d+)\s+\.$/) {
         error(_g("du gave unexpected output \`%s'"), $duo);
         error(_g("du gave unexpected output \`%s'"), $duo);
+    }
     $substvars->set_as_used('Installed-Size', $1);
     $substvars->set_as_used('Installed-Size', $1);
 }
 }
 if (defined($substvars->get('Extra-Size'))) {
 if (defined($substvars->get('Extra-Size'))) {

+ 1 - 2
scripts/dpkg-parsechangelog.pl

@@ -121,8 +121,7 @@ while (@ARGV) {
 	usageerr(_g("unknown option \`%s'"), $_);
 	usageerr(_g("unknown option \`%s'"), $_);
     }
     }
 }
 }
-
-@ARGV && usageerr(_g('takes no non-option arguments'));
+usageerr(_g('takes no non-option arguments')) if @ARGV;
 
 
 my $count = 0;
 my $count = 0;
 my @fields = changelog_parse(%options);
 my @fields = changelog_parse(%options);

+ 6 - 3
scripts/dpkg-scanpackages.pl

@@ -175,9 +175,12 @@ else {
 
 
 my ($binarydir, $override, $pathprefix) = @ARGV;
 my ($binarydir, $override, $pathprefix) = @ARGV;
 
 
--d $binarydir or error(_g('binary dir %s not found'), $binarydir);
-defined($override) and (-e $override or
-    error(_g('override file %s not found'), $override));
+if (not -d $binarydir) {
+    error(_g('binary dir %s not found'), $binarydir);
+}
+if (defined $override and not -e $override) {
+    error(_g('override file %s not found'), $override);
+}
 
 
 $pathprefix //= '';
 $pathprefix //= '';
 
 

+ 2 - 1
scripts/dpkg-scansources.pl

@@ -301,7 +301,8 @@ sub main {
         local $SIG{__WARN__} = sub { usageerr($_[0]) };
         local $SIG{__WARN__} = sub { usageerr($_[0]) };
         GetOptions(@option_spec);
         GetOptions(@option_spec);
     }
     }
-    @ARGV >= 1 and @ARGV <= 3 or usageerr(_g('one to three arguments expected'));
+    usageerr(_g('one to three arguments expected'))
+        if @ARGV < 1 or @ARGV > 3;
 
 
     push @ARGV, undef if @ARGV < 2;
     push @ARGV, undef if @ARGV < 2;
     push @ARGV, '' if @ARGV < 3;
     push @ARGV, '' if @ARGV < 3;

+ 5 - 4
scripts/dpkg-shlibdeps.pl

@@ -101,13 +101,15 @@ foreach (@ARGV) {
 	version(); exit(0);
 	version(); exit(0);
     } elsif (m/^--admindir=(.*)$/) {
     } elsif (m/^--admindir=(.*)$/) {
 	$admindir = $1;
 	$admindir = $1;
-	-d $admindir ||
+	if (not -d $admindir) {
 	    error(_g("administrative directory '%s' does not exist"), $admindir);
 	    error(_g("administrative directory '%s' does not exist"), $admindir);
+	}
 	$ENV{DPKG_ADMINDIR} = $admindir;
 	$ENV{DPKG_ADMINDIR} = $admindir;
     } elsif (m/^-d(.*)$/) {
     } elsif (m/^-d(.*)$/) {
 	$dependencyfield = field_capitalize($1);
 	$dependencyfield = field_capitalize($1);
-	defined($depstrength{$dependencyfield}) ||
+	if (not defined $depstrength{$dependencyfield}) {
 	    warning(_g("unrecognized dependency field '%s'"), $dependencyfield);
 	    warning(_g("unrecognized dependency field '%s'"), $dependencyfield);
+	}
     } elsif (m/^-e(.*)$/) {
     } elsif (m/^-e(.*)$/) {
 	if (exists $exec{$1}) {
 	if (exists $exec{$1}) {
 	    # Affect the binary to the most important field
 	    # Affect the binary to the most important field
@@ -140,8 +142,7 @@ foreach (@ARGV) {
 	}
 	}
     }
     }
 }
 }
-
-scalar keys %exec || usageerr(_g('need at least one executable'));
+usageerr(_g('need at least one executable')) unless scalar keys %exec;
 
 
 my $control = Dpkg::Control::Info->new();
 my $control = Dpkg::Control::Info->new();
 my $fields = $control->get_source();
 my $fields = $control->get_source();