Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1BAAEC3DA61 for ; Thu, 17 Aug 2023 17:07:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1692292042; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=AVxUIdd3NK9gRtDAKQX45jAh6hQdBYP4mJZR6FxeRbo=; b=MsdKx/EWYTfu7q43guYFyVWUoRAxyFEXQcZOp6iMJZ3VpCDZN/oe93OHd7SgUPYhL3ZCB8 mZGK6JaMpqcG74cA4aFETfvELGjZNARu0P8MztrF+F4H2SkxMaDao37COdjxuCMl4TnxsH f/DQ3/NKSWxQENrmlAxo8fwszNf1Cnc= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-584-EFv8vPDsM4yHrw6aXO--3w-1; Thu, 17 Aug 2023 13:07:21 -0400 X-MC-Unique: EFv8vPDsM4yHrw6aXO--3w-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B2191C07566; Thu, 17 Aug 2023 17:07:20 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD824492C13; Thu, 17 Aug 2023 17:07:19 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6AAC41946589; Thu, 17 Aug 2023 17:07:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id BA8B21946588 for ; Thu, 17 Aug 2023 17:07:12 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 9358040D283A; Thu, 17 Aug 2023 17:07:07 +0000 (UTC) Received: from fs-i40c-03.fs.lab.eng.bos.redhat.com (fs-i40c-03.fs.lab.eng.bos.redhat.com [10.16.224.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DB6D40D2839; Thu, 17 Aug 2023 17:07:07 +0000 (UTC) From: Alexander Aring To: teigland@redhat.com Date: Thu, 17 Aug 2023 13:07:06 -0400 Message-Id: <20230817170706.3977893-1-aahringo@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 Subject: [Cluster-devel] [PATCH dlm-tool] dlm_controld: fix various deadcode issues X-BeenThere: cluster-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: "\[Cluster devel\]" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cluster-devel@redhat.com Errors-To: cluster-devel-bounces@redhat.com Sender: "Cluster-devel" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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