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
This commit is contained in:
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user