From: Panu Matilainen Date: Tue, 3 May 2011 12:02:42 +0000 (+0300) Subject: Clean up file type verification logic a bit X-Git-Tag: tznext/4.11.0.1.tizen20130304~1159 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=469b10d1d2d9819e0793fac7f84ae2cfa75135d9;p=tools%2Flibrpm-tizen.git Clean up file type verification logic a bit - 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. --- diff --git a/lib/verify.c b/lib/verify.c index 46210bc..8c8d102 100644 --- a/lib/verify.c +++ b/lib/verify.c @@ -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);