Message ID | 146161381575.21779.8108705781017518591.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 57cbae0d6884 |
Headers | show |
On Mon, Apr 25, 2016 at 12:50 PM, Dan Williams <dan.j.williams@intel.com> wrote: > Static analysis tools don't like the fact that we do multiple > overwriting assignments to a variable. Use IS_ENABLED() to clean this > up. Whoops, I changed this patch to use static const lowercase(command name) intead of IS_ENABLED(). Here's the updated changelog: Static analysis tools don't like the fact that we do multiple overwriting assignments to a variable. Use aliased always defined values that to_dsm_index() can check against zero to determine if the command is supported.
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; }
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 <dan.j.williams@intel.com> --- lib/libndctl-private.h | 15 +++++++++++++++ lib/libndctl.c | 10 +++------- 2 files changed, 18 insertions(+), 7 deletions(-)