[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[lintian] 01/05: checks: Check is_regular_file before using size



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

nthykier pushed a commit to branch master
in repository lintian.

commit 8042e3940581a34dba2f0a5305a9a65deac858e5
Author: Niels Thykier <niels@thykier.net>
Date:   Thu Jul 16 21:45:44 2015 +0200

    checks: Check is_regular_file before using size
    
    The "official" documentation says that "size" is only "well defined"
    for files.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 checks/files.pm          | 4 ++--
 checks/huge-usr-share.pm | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/checks/files.pm b/checks/files.pm
index 8b0c571..4aca7d7 100644
--- a/checks/files.pm
+++ b/checks/files.pm
@@ -567,7 +567,7 @@ sub run {
                     }
 
                     # zero byte file in /usr/share/doc/
-                    if ($file->size == 0 and $file->is_regular_file) {
+                    if ($file->is_regular_file and $file->size == 0) {
                      # Exceptions: examples may contain empty files for various
                      # reasons, Doxygen generates empty *.map files, and Python
                      # uses __init__.py to mark module directories.
@@ -584,8 +584,8 @@ sub run {
                     # 276 is 255 bytes (maximal length for a filename)
                     # + gzip overhead
                     if (    $fname =~ m,.gz$,
+                        and $file->is_regular_file
                         and $file->size <= 276
-                        and $file->is_file
                         and $file->file_info =~ m/gzip compressed/) {
                         my $fd = $file->open_gz;
                         my $f = <$fd>;
diff --git a/checks/huge-usr-share.pm b/checks/huge-usr-share.pm
index 3c763ed..78225fd 100644
--- a/checks/huge-usr-share.pm
+++ b/checks/huge-usr-share.pm
@@ -40,7 +40,7 @@ sub run {
     # Add up the space taken by the package and the space taken by
     # just the files in /usr/share.  Convert the totals to kilobytes.
     my ($size, $size_usrshare) = (0, 0);
-    for my $file ($info->sorted_index) {
+    for my $file (grep { $_->is_regular_file } $info->sorted_index) {
         $size += $file->size;
         if ($file =~ m,usr/share/,) {
             $size_usrshare += $file->size;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: