From patchwork Mon Apr 25 19:50:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 8931921 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9ACEABF29F for ; Mon, 25 Apr 2016 19:51:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C0BB92015A for ; Mon, 25 Apr 2016 19:51:06 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E827C2011E for ; Mon, 25 Apr 2016 19:51:05 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DD3731A1ED1; Mon, 25 Apr 2016 12:51:05 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by ml01.01.org (Postfix) with ESMTP id A6DE61A1ED1 for ; Mon, 25 Apr 2016 12:51:04 -0700 (PDT) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP; 25 Apr 2016 12:51:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,534,1455004800"; d="scan'208";a="939920893" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.14]) by orsmga001.jf.intel.com with ESMTP; 25 Apr 2016 12:51:04 -0700 Subject: [ndctl PATCH 5/7] ndctl: fix to_dsm_index() static analysis warning From: Dan Williams To: linux-nvdimm@lists.01.org Date: Mon, 25 Apr 2016 12:50:15 -0700 Message-ID: <146161381575.21779.8108705781017518591.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <146161378966.21779.1219526957524644729.stgit@dwillia2-desk3.amr.corp.intel.com> References: <146161378966.21779.1219526957524644729.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Static analysis tools don't like the fact that we do multiple overwriting assignments to a variable. Use IS_ENABLED() to clean this up. Signed-off-by: Dan Williams --- lib/libndctl-private.h | 15 +++++++++++++++ lib/libndctl.c | 10 +++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/libndctl-private.h b/lib/libndctl-private.h index cbb0ed9f76b5..a0a36885b160 100644 --- a/lib/libndctl-private.h +++ b/lib/libndctl-private.h @@ -177,6 +177,21 @@ struct ndctl_cmd { }; }; +/* internal library helpers for conditionally defined command numbers */ +#ifdef HAVE_NDCTL_ARS +static const int nd_cmd_ars_status = ND_CMD_ARS_STATUS; +static const int nd_cmd_ars_cap = ND_CMD_ARS_CAP; +#else +static const int nd_cmd_ars_status; +static const int nd_cmd_ars_cap; +#endif + +#ifdef HAVE_NDCTL_CLEAR_ERROR +static const int nd_cmd_clear_error = ND_CMD_CLEAR_ERROR; +#else +static const int nd_cmd_clear_error; +#endif + static inline struct ndctl_bus *cmd_to_bus(struct ndctl_cmd *cmd) { if (cmd->dimm) diff --git a/lib/libndctl.c b/lib/libndctl.c index 1014da2aa8a9..5c2894d6b82e 100644 --- a/lib/libndctl.c +++ b/lib/libndctl.c @@ -813,13 +813,9 @@ static int to_dsm_index(const char *name, int dimm) end_cmd = ND_CMD_VENDOR; cmd_name_fn = nvdimm_cmd_name; } else { - end_cmd = 0; -#ifdef HAVE_NDCTL_ARS - end_cmd = ND_CMD_ARS_STATUS; -#endif -#ifdef HAVE_NDCTL_CLEAR_ERROR - end_cmd = ND_CMD_CLEAR_ERROR; -#endif + end_cmd = nd_cmd_clear_error; + if (!end_cmd) + end_cmd = nd_cmd_ars_status; cmd_name_fn = nvdimm_bus_cmd_name; }