Skip to contentSkip to conversation

dlm_controld: fix various deadcode issues

PATCH New Alexander Aring 1 participant 1 message Aug 17, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dlm_controld: fix various deadcode issues

This patch fix various deadcode issues discovered by coverity. The flags from the shutdown_callback() aren't flags, we need to use == to get the shutdown request type. The value COROSYNC_CFG_SHUTDOWN_FLAG_REQUEST is 0 and will never be true in this case.

The strstr() need to be incremented after checking on NULL.

The &dlm_options[ind] can't never be NULL, we check if name is check to indicate an entry which is not being used.

---
 dlm_controld/config.c |  2 +-
 dlm_controld/lib.c    | 10 ++++++++--
 dlm_controld/member.c |  2 +-
 3 files changed, 10 insertions(+), 4 deletions(-)
dlm_controld/config.c +1 -1
index b15527b9..9332bd28 100644
@@ -286,7 +286,7 @@ void set_opt_file(int update)
 		if (ind < 0)
 			continue;
 		o = &dlm_options[ind];
-		if (!o)
+		if (!o->name)
 			continue;
 
 		scanned_dlm_opt[ind] = 1;
dlm_controld/lib.c +8 -2
index a21150f2..3ff0680e 100644
@@ -269,10 +269,13 @@ static unsigned int kv(char *str, const char *k)
 	if (!p)
 		return 0;
 
-	p = strstr(p, "=") + 1;
+	p = strstr(p, "=");
 	if (!p)
 		return 0;
 
+	/* move pointer after '=' */
+	p++;
+
 	memset(valstr, 0, 64);
 
 	for (i = 0; i < 64; i++) {
@@ -299,10 +302,13 @@ static char *ks(char *str, const char *k)
 	if (!p)
 		return 0;
 
-	p = strstr(p, "=") + 1;
+	p = strstr(p, "=");
 	if (!p)
 		return 0;
 
+	/* move pointer after '=' */
+	p++;
+
 	memset(valstr, 0, 64);
 
 	for (i = 0; i < 64; i++) {
dlm_controld/member.c +1 -1
index d567c114..f297b457 100644
@@ -345,7 +345,7 @@ void kick_node_from_cluster(int nodeid)
 static void shutdown_callback(corosync_cfg_handle_t h,
 			      corosync_cfg_shutdown_flags_t flags)
 {
-	if (flags & COROSYNC_CFG_SHUTDOWN_FLAG_REQUEST) {
+	if (flags == COROSYNC_CFG_SHUTDOWN_FLAG_REQUEST) {
 		if (list_empty(&lockspaces)) {
 			log_debug("shutdown request yes");
 			corosync_cfg_replyto_shutdown(ch, COROSYNC_CFG_SHUTDOWN_FLAG_YES);
Signature · 1 line
2.31.1