From 2a57c129228ecd4a4a286e9db269b1f8a8d3b8f7 Mon Sep 17 00:00:00 2001 From: Aram Sargsyan Date: Wed, 6 Sep 2023 10:26:36 +0000 Subject: [PATCH] Remove an unnecessary NULL-check In the ns__client_put_cb() callback function the 'client->manager' pointer is guaranteed to be non-NULL, because in ns__client_request(), before setting up the callback, the ns__client_setup() function is called for the 'client', which makes sure that 'client->manager' is set. Removing the NULL-check resolves the following static analyzer warning: /lib/ns/client.c: 1675 in ns__client_put_cb() 1669 dns_message_puttemprdataset(client->message, &client->opt); 1670 } 1671 client_extendederror_reset(client); 1672 1673 dns_message_detach(&client->message); 1674 >>> CID 465168: Null pointer dereferences (REVERSE_INULL) >>> Null-checking "client->manager" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 1675 if (client->manager != NULL) { 1676 ns_clientmgr_detach(&client->manager); 1677 } 1678 1679 /* 1680 * Detaching the task must be done after unlinking from --- lib/ns/client.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/ns/client.c b/lib/ns/client.c index 5ed64fd73b..1d26b336b3 100644 --- a/lib/ns/client.c +++ b/lib/ns/client.c @@ -1672,9 +1672,7 @@ ns__client_put_cb(void *client0) { dns_message_detach(&client->message); - if (client->manager != NULL) { - ns_clientmgr_detach(&client->manager); - } + ns_clientmgr_detach(&client->manager); /* * Detaching the task must be done after unlinking from