[PATCH] cache: fix GCC warning and avoid variable shadowing
Tobias Klauser
tklauser at distanz.ch
Fri Dec 2 02:46:51 PST 2016
Fix the following GCC warning, introduced in commit 66d032ad443a
("cache_mngr: add include callback v2"):
cache.c: In function ‘cache_include.isra.3’:
cache.c:810:6: warning: ‘diff’ may be used uninitialized in this function [-Wmaybe-uninitialized]
cb_v2(cache, clone, obj, diff,
^
Also don't redeclare the uint64_t diff variable, to avoid shadowing.
Signed-off-by: Tobias Klauser <tklauser at distanz.ch>
---
lib/cache.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/cache.c b/lib/cache.c
index d9742b6ddacd..427f5dfbd025 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -789,7 +789,7 @@ static int cache_include(struct nl_cache *cache, struct nl_object *obj,
{
struct nl_object *old;
struct nl_object *clone = NULL;
- uint64_t diff;
+ uint64_t diff = 0;
switch (type->mt_act) {
case NL_ACT_NEW:
@@ -837,7 +837,7 @@ static int cache_include(struct nl_cache *cache, struct nl_object *obj,
} else if (cb)
cb(cache, obj, NL_ACT_NEW, data);
} else if (old) {
- uint64_t diff = 0;
+ diff = 0;
if (cb || cb_v2)
diff = nl_object_diff64(old, obj);
if (diff && cb_v2) {
--
2.11.0
More information about the libnl
mailing list