From 6404a00063bb3865f2332990fc88b90107d41306 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Fri, 7 Nov 2008 12:03:54 +0200 Subject: [PATCH] Reset return values to zero + NULL's on not found in hash GetEntry() - avoids having to separately check for return value in some cases and accidents from not resetting the values in caller - in line with headerGet() behavior --- lib/rpmhash.C | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/rpmhash.C b/lib/rpmhash.C index a32a7d4..a631074 100644 --- a/lib/rpmhash.C +++ b/lib/rpmhash.C @@ -136,18 +136,16 @@ int HASHPREFIX(GetEntry)(HASHTYPE ht, HTKEYTYPE key, HTDATATYPE** data, int * dataCount, HTKEYTYPE* tableKey) { Bucket b; - - if ((b = HASHPREFIX(findEntry)(ht, key)) == NULL) - return 0; + int rc = ((b = HASHPREFIX(findEntry)(ht, key)) != NULL); if (data) - *data = b->data; + *data = rc ? b->data : NULL; if (dataCount) - *dataCount = b->dataCount; + *dataCount = rc ? b->dataCount : 0; if (tableKey) - *tableKey = b->key; + *tableKey = rc ? b->key : NULL; - return 1; + return rc; } void HASHPREFIX(PrintStats)(HASHTYPE ht) { -- 2.7.4