summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2016-12-02 10:46:51 (GMT)
committerThomas Haller <thaller@redhat.com>2016-12-02 12:37:35 (GMT)
commit7e88d00c095dba3513e15f9ca387df47cfcb0ab0 (patch)
tree1b2ed4fed6f6ebfa4519c94c6b16e16aa6a69389 /lib
parent66d032ad443a9d67bd26ed3e801cddf9f0e71ae7 (diff)
downloadlibnl-7e88d00c095dba3513e15f9ca387df47cfcb0ab0.zip
libnl-7e88d00c095dba3513e15f9ca387df47cfcb0ab0.tar.gz
libnl-7e88d00c095dba3513e15f9ca387df47cfcb0ab0.tar.bz2
cache: fix GCC warning and avoid variable shadowing
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@distanz.ch> Signed-off-by: Thomas Haller <thaller@redhat.com> Fixes: 66d032ad443a9d67bd26ed3e801cddf9f0e71ae7 http://lists.infradead.org/pipermail/libnl/2016-December/002258.html
Diffstat (limited to 'lib')
-rw-r--r--lib/cache.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/cache.c b/lib/cache.c
index d9742b6..427f5df 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) {