From 7c75ce13299af68b73563714ca366f891f6a9eb8 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 10 Sep 2022 14:13:58 -0700 Subject: set_node_labels: move dereference of node to after the NULL check Found by cppcheck: viewres.c:815:22: warning: Either the condition '!node' is redundant or there is possible null pointer dereference: node. [nullPointerRedundantCheck] ViewresData *d = VData(node); ^ viewres.c:817:9: note: Assuming that condition '!node' is not redundant if (!node) ^ viewres.c:815:22: note: Null pointer dereference ViewresData *d = VData(node); ^ Signed-off-by: Alan Coopersmith --- viewres.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/viewres.c b/viewres.c index cb4e9e2..d53e220 100644 --- a/viewres.c +++ b/viewres.c @@ -812,10 +812,11 @@ set_node_labels(XmuWidgetNode *node, int depth) { Arg args[1]; XmuWidgetNode *child; - ViewresData *d = VData(node); + ViewresData *d; if (!node) return; + d = VData(node); XtSetArg(args[0], XtNlabel, (options.show_variable ? node->label : XmuWnClassname(node))); XtSetValues(d->instance, args, ONE); -- cgit v1.2.3