summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-04-02 20:49:27 +0200
committerThomas Haller <thaller@redhat.com>2019-04-04 09:54:44 +0200
commitc50ef0df3bd2ce109e31b964ad23e2eafc44e2c8 (patch)
treebe838ece4be18aa3caeb1793b6c726967ab88303
parent645b195f9c764a4641390af26f1a29f5a1d852f2 (diff)
downloadNetworkManager-c50ef0df3bd2ce109e31b964ad23e2eafc44e2c8.tar.gz
shared: workaround -Wunused-but-set-variable warning with assertions
Usually, we don't want to build with NDEBUG (because disabling regular assertions is an untested configuration). Still, when we do, we get compiler warnings. Non-debug builds break with a compiler warning: $ ccache cc -Ishared/a4d2686@@n-acd@sta -Ishared -I../shared -I../shared/c-siphash/src -I../shared/c-list/src -I../shared/c-rbtree/src -fdiagnostics-color=always -DNDEBUG -pipe -D_FILE_OFFSET_BITS=64 -Werror -std=gnu11 -fdata-sections -ffunction-sections -O2 -g -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -D_GNU_SOURCE -DSO_ATTACH_BPF=50 -std=c11 -Wno-pointer-arith -Wno-vla -MD -MQ 'shared/a4d2686@@n-acd@sta/n-acd_src_n-acd-probe.c.o' -MF 'shared/a4d2686@@n-acd@sta/n-acd_src_n-acd-probe.c.o.d' -o 'shared/a4d2686@@n-acd@sta/n-acd_src_n-acd-probe.c.o' -c ../shared/n-acd/src/n-acd-probe.c ../shared/n-acd/src/n-acd-probe.c: In function 'n_acd_probe_unlink': ../shared/n-acd/src/n-acd-probe.c:209:13: error: variable 'r' set but not used [-Werror=unused-but-set-variable] int r; ^ $ cache cc -Ishared/a4d2686@@c-rbtree@sta -Ishared -I../shared -fdiagnostics-color=always -DNDEBUG -pipe -D_FILE_OFFSET_BITS=64 -Werror -std=gnu11 -fdata-sections -ffunction-sections -O2 -g -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fPIC -std=c11 -MD -MQ 'shared/a4d2686@@c-rbtree@sta/c-rbtree_src_c-rbtree.c.o' -MF 'shared/a4d2686@@c-rbtree@sta/c-rbtree_src_c-rbtree.c.o.d' -o 'shared/a4d2686@@c-rbtree@sta/c-rbtree_src_c-rbtree.c.o' -c ../shared/c-rbtree/src/c-rbtree.c ../shared/c-rbtree/src/c-rbtree.c: In function 'c_rbtree_move': ../shared/c-rbtree/src/c-rbtree.c:456:18: error: variable 't' set but not used [-Werror=unused-but-set-variable] CRBTree *t; ^ https://github.com/nettools/n-acd/pull/6 https://github.com/c-util/c-rbtree/pull/3
-rw-r--r--shared/c-rbtree/src/c-rbtree.c1
-rw-r--r--shared/n-acd/src/n-acd-probe.c1
-rw-r--r--shared/n-acd/src/util/timer.c2
3 files changed, 4 insertions, 0 deletions
diff --git a/shared/c-rbtree/src/c-rbtree.c b/shared/c-rbtree/src/c-rbtree.c
index f58db849b6..31d743002b 100644
--- a/shared/c-rbtree/src/c-rbtree.c
+++ b/shared/c-rbtree/src/c-rbtree.c
@@ -460,6 +460,7 @@ _public_ void c_rbtree_move(CRBTree *to, CRBTree *from) {
if (from->root) {
t = c_rbnode_pop_root(from->root);
assert(t == from);
+ (void)t;
to->root = from->root;
from->root = NULL;
diff --git a/shared/n-acd/src/n-acd-probe.c b/shared/n-acd/src/n-acd-probe.c
index 8c233b56a7..d4da0fd5c7 100644
--- a/shared/n-acd/src/n-acd-probe.c
+++ b/shared/n-acd/src/n-acd-probe.c
@@ -215,6 +215,7 @@ static void n_acd_probe_unlink(NAcdProbe *probe) {
if (n_acd_probe_is_unique(probe)) {
r = n_acd_bpf_map_remove(probe->acd->fd_bpf_map, &probe->ip);
assert(r >= 0);
+ (void)r;
--probe->acd->n_bpf_map;
}
c_rbnode_unlink(&probe->ip_node);
diff --git a/shared/n-acd/src/util/timer.c b/shared/n-acd/src/util/timer.c
index 29627af776..07dbf34eb8 100644
--- a/shared/n-acd/src/util/timer.c
+++ b/shared/n-acd/src/util/timer.c
@@ -44,6 +44,7 @@ void timer_now(Timer *timer, uint64_t *nowp) {
r = clock_gettime(timer->clock, &ts);
assert(r >= 0);
+ (void)r;
*nowp = ts.tv_sec * UINT64_C(1000000000) + ts.tv_nsec;
}
@@ -74,6 +75,7 @@ void timer_rearm(Timer *timer) {
},
NULL);
assert(r >= 0);
+ (void)r;
timer->scheduled_timeout = time;
}