coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] shred: overwrite inode storage used by some file systems


From: Paul Eggert
Subject: Re: [PATCH] shred: overwrite inode storage used by some file systems
Date: Fri, 04 Apr 2014 10:49:55 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0

+  else if (S_ISREG (st.st_mode))
+    {
+      off_t fsize = st.st_size;
+      if (fsize > 0 && fsize < ST_BLKSIZE (st) && size > fsize)
+        i_size = fsize;
+    }

This can be simplified. There's no need to worry about checking whether st.st_size == 0 since the code would do the right thing if that test were removed. (Or are you worried about st.st_size < 0? If so, that check should be hoisted out of the previous 'if' and done on all regular files.) We generally prefer "<" and "<=" for size comparisons, as it makes code easier to visualize. Something like this, perhaps:

   else if (S_ISREG (st.st_mode)
            && st.st_size < MIN (ST_BLKSIZE (st), size))
     i_size = st.st_size;

The rest looks good. I didn't quite follow the part about pass_size but I assume it's OK. Thanks.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]