[debsums] 05/05: Slightly refactor check() to make coding style more consistent

Axel Beckert abe at deuxchevaux.org
Sat Jan 21 19:31:09 UTC 2017


This is an automated email from the git hooks/post-receive script.

abe pushed a commit to branch master
in repository debsums.

commit ea7926bcbf980052691eb3c5517f7e2066aa6411
Author: Axel Beckert <abe at deuxchevaux.org>
Date:   Sat Jan 21 19:53:37 2017 +0100

    Slightly refactor check() to make coding style more consistent
    
    Also add some comments.
---
 debian/changelog |  3 +++
 debsums          | 36 +++++++++++++++---------------------
 2 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 181c646..dd45d7a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,9 @@ debsums (2.2) UNRELEASED; urgency=medium
   * Add a flag to report the expected and actual checksums of files
     checked. (Closes: #660051)
 
+  [ Axel Beckert ]
+  * Slightly refactor check() to make coding style more consistent.
+
  -- Axel Beckert <abe at debian.org>  Sat, 21 Jan 2017 17:59:58 +0100
 
 debsums (2.1.3) unstable; urgency=medium
diff --git a/debsums b/debsums
index 82cb1ac..faee262 100755
--- a/debsums
+++ b/debsums
@@ -489,8 +489,7 @@ sub resolve_path {
             }
         }
 
-        unless (-f F)
-        {
+        unless (-f F) {
             warn "$self: can't check $pack file $root/$path ",
                 "(not a regular file)\n";
 
@@ -507,8 +506,7 @@ sub resolve_path {
 
         close F;
 
-        if ($@)
-        {
+        if ($@) {
             $@ =~ s/ at \S+ line.*\n//;
             warn "$self: can't check $pack file $root/$path ($@)\n";
             return 2;
@@ -516,8 +514,7 @@ sub resolve_path {
 
         my $s = $digest->hexdigest;
 
-        if ($s ne $sum and $prelink and $magic eq ELF_MAGIC)
-        {
+        if ($s ne $sum and $prelink and $magic eq ELF_MAGIC) {
             if (open P, '-|', $prelink, '--verify', '--md5', "$root/$path")
             {
                 my ($prelink_s) = map /^([\da-f]{32})\s/, <P>;
@@ -526,14 +523,14 @@ sub resolve_path {
             }
         }
 
-        if ($s eq $sum)
-        {
+        # Good cases
+
+        if ($s eq $sum) {
             printf "%-*s OK\n", $width, "$root/$path" unless ($silent || $report);
             return 0;
         }
 
-        if (is_replaced $pack, $path, $s)
-        {
+        if (is_replaced $pack, $path, $s) {
             printf "%-*s REPLACED\n", $width - 6, "$root/$path" unless ($silent || $report);
             return 0;
         }
@@ -546,27 +543,24 @@ sub resolve_path {
             return 0;
         }
 
-        if ($changed)
-        {
-            print $root, "/", $path, "\n";
+        # Bad cases
+
+        if ($changed) {
+            print "$root/$path\n";
             return 2;
         }
 
-        if ($report)
-        {
+        if ($report) {
             warn "$self: changed file $root/$path (observed:$s expected:$sum) (from $pack package)\n";
             return 2;
         }
 
-        if ($silent)
-        {
+        if ($silent) {
             warn "$self: changed file $root/$path (from $pack package)\n";
-        }
-        else
-        {
-            printf "%-*s FAILED\n", $width - 4, "$root/$path";
+            return 2;
         }
 
+        printf "%-*s FAILED\n", $width - 4, "$root/$path";
         return 2;
     }
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/debsums.git



More information about the Pkg-perl-cvs-commits mailing list