Clean up file type verification logic a bit
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 3 May 2011 12:02:42 +0000 (15:02 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 3 May 2011 12:02:42 +0000 (15:02 +0300)
- Non-regular files mostly share the same unverifiable properties,
  no point in listing all the cases separately. Links are a notable
  exception in that they're different from everything else, handle
  that separately.
- Also clean up other formatting: wrap lines at a better point +
  avoid multiline-comments when single line suffices.

lib/verify.c

index 46210bc..8c8d102 100644 (file)
@@ -95,38 +95,23 @@ int rpmVerifyFile(const rpmts ts, const rpmfi fi,
        return 1;
     }
 
-    /*
-     * Not all attributes of non-regular files can be verified.
-     */
-    if (S_ISDIR(sb.st_mode))
-       flags &= ~(RPMVERIFY_FILEDIGEST | RPMVERIFY_FILESIZE | RPMVERIFY_MTIME |
-                       RPMVERIFY_LINKTO | RPMVERIFY_CAPS);
-    else if (S_ISLNK(sb.st_mode)) {
-       flags &= ~(RPMVERIFY_FILEDIGEST | RPMVERIFY_FILESIZE | RPMVERIFY_MTIME |
-                       RPMVERIFY_MODE | RPMVERIFY_CAPS);
-    }
-    else if (S_ISFIFO(sb.st_mode))
-       flags &= ~(RPMVERIFY_FILEDIGEST | RPMVERIFY_FILESIZE | RPMVERIFY_MTIME |
-                       RPMVERIFY_LINKTO | RPMVERIFY_CAPS);
-    else if (S_ISCHR(sb.st_mode))
-       flags &= ~(RPMVERIFY_FILEDIGEST | RPMVERIFY_FILESIZE | RPMVERIFY_MTIME |
-                       RPMVERIFY_LINKTO | RPMVERIFY_CAPS);
-    else if (S_ISBLK(sb.st_mode))
-       flags &= ~(RPMVERIFY_FILEDIGEST | RPMVERIFY_FILESIZE | RPMVERIFY_MTIME |
-                       RPMVERIFY_LINKTO | RPMVERIFY_CAPS);
-    else 
+    /* Links have no mode, other types have no linkto */
+    if (S_ISLNK(sb.st_mode))
+       flags &= ~(RPMVERIFY_MODE);
+    else
        flags &= ~(RPMVERIFY_LINKTO);
 
-    /*
-     * Content checks of %ghost files are meaningless.
-     */
+    /* Not all attributes of non-regular files can be verified */
+    if (!S_ISREG(sb.st_mode))
+       flags &= ~(RPMVERIFY_FILEDIGEST | RPMVERIFY_FILESIZE |
+                  RPMVERIFY_MTIME | RPMVERIFY_CAPS);
+
+    /* Content checks of %ghost files are meaningless. */
     if (fileAttrs & RPMFILE_GHOST)
-       flags &= ~(RPMVERIFY_FILEDIGEST | RPMVERIFY_FILESIZE | RPMVERIFY_MTIME |
-                       RPMVERIFY_LINKTO);
+       flags &= ~(RPMVERIFY_FILEDIGEST | RPMVERIFY_FILESIZE |
+                  RPMVERIFY_MTIME | RPMVERIFY_LINKTO);
 
-    /*
-     * Don't verify any features in omitMask.
-     */
+    /* Don't verify any features in omitMask. */
     flags &= ~(omitMask | RPMVERIFY_FAILURES);