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(-) diff --git a/dlm_controld/config.c b/dlm_controld/config.c index b15527b9..9332bd28 100644 --- a/dlm_controld/config.c +++ b/dlm_controld/config.c @@ -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; diff --git a/dlm_controld/lib.c b/dlm_controld/lib.c index a21150f2..3ff0680e 100644 --- a/dlm_controld/lib.c +++ b/dlm_controld/lib.c @@ -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++) { diff --git a/dlm_controld/member.c b/dlm_controld/member.c index d567c114..f297b457 100644 --- a/dlm_controld/member.c +++ b/dlm_controld/member.c @@ -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); -- 2.31.1