From 81dbfa26513355e8d17414b90601c7dcc2f64f2a Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Wed, 5 Sep 2012 11:50:30 +0300 Subject: [PATCH] Use helper variable to eliminate multiple identical conditionals --- lib/fprint.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/fprint.c b/lib/fprint.c index a018d70..3aa9989 100644 --- a/lib/fprint.c +++ b/lib/fprint.c @@ -131,18 +131,19 @@ fingerPrint fpLookup(fingerPrintCache cache, } while (1) { + const char *fpDir = (*buf != '\0') ? buf : "/"; /* as we're stating paths here, we want to follow symlinks */ - cacheHit = cacheContainsDirectory(cache, (*buf != '\0' ? buf : "/")); + cacheHit = cacheContainsDirectory(cache, fpDir); if (cacheHit != NULL) { fp.entry = cacheHit; - } else if (!stat((*buf != '\0' ? buf : "/"), &sb)) { + } else if (!stat(fpDir, &sb)) { struct fprintCacheEntry_s * newEntry = xmalloc(sizeof(* newEntry)); newEntry->ino = sb.st_ino; newEntry->dev = sb.st_dev; - newEntry->dirName = xstrdup((*buf != '\0' ? buf : "/")); + newEntry->dirName = xstrdup(fpDir); fp.entry = newEntry; rpmFpEntryHashAddEntry(cache->ht, newEntry->dirName, fp.entry); -- 2.7.4