nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [ndctl PATCH 0/3] add -Wmaybe-uninitialized
@ 2018-02-21 23:02 Vishal Verma
  2018-02-21 23:02 ` [ndctl PATCH 1/3] ndctl, inject-smart: cleanup uninitialized variable warnings Vishal Verma
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Vishal Verma @ 2018-02-21 23:02 UTC (permalink / raw)
  To: linux-nvdimm

A few misc updates. Add the -Wmaybe-uninitialized flag to configure, and
fix the warnings it results in.
Also in update.c, remove a new unnecessary if (cmd) - unref checks as
unref already handles the NULL case.

Vishal Verma (3):
  ndctl, inject-smart: cleanup uninitialized variable warnings
  ndctl, update: fix uninitialized variable warnings
  ndctl, update: remove the check for !cmd when dereferencing it

 ndctl/inject-smart.c | 4 ++--
 ndctl/update.c       | 8 +++-----
 2 files changed, 5 insertions(+), 7 deletions(-)

-- 
2.14.3

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ndctl PATCH 1/3] ndctl, inject-smart: cleanup uninitialized variable warnings
  2018-02-21 23:02 [ndctl PATCH 0/3] add -Wmaybe-uninitialized Vishal Verma
@ 2018-02-21 23:02 ` Vishal Verma
  2018-02-21 23:02 ` [ndctl PATCH 2/3] ndctl, update: fix " Vishal Verma
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Vishal Verma @ 2018-02-21 23:02 UTC (permalink / raw)
  To: linux-nvdimm

There were a couple of cases where we could try to unref a command that
had never been initialized. Fix those by always initializing the cmd
pointers to NULL.

Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 ndctl/inject-smart.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ndctl/inject-smart.c b/ndctl/inject-smart.c
index 02f8b0e..45dbc8d 100644
--- a/ndctl/inject-smart.c
+++ b/ndctl/inject-smart.c
@@ -221,7 +221,7 @@ static int smart_init(void)
 static int smart_set_thresh(struct ndctl_dimm *dimm)
 {
 	const char *name = ndctl_dimm_get_devname(dimm);
-	struct ndctl_cmd *st_cmd, *sst_cmd;
+	struct ndctl_cmd *st_cmd = NULL, *sst_cmd = NULL;
 	int rc = -EOPNOTSUPP;
 
 	st_cmd = ndctl_dimm_cmd_new_smart_threshold(dimm);
@@ -332,7 +332,7 @@ out:
 static int smart_inject(struct ndctl_dimm *dimm)
 {
 	const char *name = ndctl_dimm_get_devname(dimm);
-	struct ndctl_cmd *si_cmd;
+	struct ndctl_cmd *si_cmd = NULL;
 	int rc = -EOPNOTSUPP;
 
 	send_inject_val(media_temperature)
-- 
2.14.3

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [ndctl PATCH 2/3] ndctl, update: fix uninitialized variable warnings
  2018-02-21 23:02 [ndctl PATCH 0/3] add -Wmaybe-uninitialized Vishal Verma
  2018-02-21 23:02 ` [ndctl PATCH 1/3] ndctl, inject-smart: cleanup uninitialized variable warnings Vishal Verma
@ 2018-02-21 23:02 ` Vishal Verma
  2018-02-21 23:02 ` [ndctl PATCH 3/3] ndctl, update: remove the check for !cmd when dereferencing it Vishal Verma
  2018-02-21 23:06 ` [ndctl PATCH 4/3] ndctl, configure: add -Wmaybe-uninitialized to cflags Vishal Verma
  3 siblings, 0 replies; 5+ messages in thread
From: Vishal Verma @ 2018-02-21 23:02 UTC (permalink / raw)
  To: linux-nvdimm

In send_firmware, if the file size ('remain') were to be zero, 'rc'
would never get assigned. While this conditon would never be reached
because we have already checked the file size to be greater than zero,
initialize 'rc' anyway to silence the compiler warning.

Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 ndctl/update.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ndctl/update.c b/ndctl/update.c
index 877d37f..71d95eb 100644
--- a/ndctl/update.c
+++ b/ndctl/update.c
@@ -208,7 +208,7 @@ static int send_firmware(struct update_context *uctx)
 {
 	struct ndctl_cmd *cmd = NULL;
 	ssize_t read;
-	int rc;
+	int rc = -ENXIO;
 	enum ND_FW_STATUS status;
 	struct fw_info *fw = &uctx->dimm_fw;
 	uint32_t copied = 0, len, remain;
-- 
2.14.3

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [ndctl PATCH 3/3] ndctl, update: remove the check for !cmd when dereferencing it
  2018-02-21 23:02 [ndctl PATCH 0/3] add -Wmaybe-uninitialized Vishal Verma
  2018-02-21 23:02 ` [ndctl PATCH 1/3] ndctl, inject-smart: cleanup uninitialized variable warnings Vishal Verma
  2018-02-21 23:02 ` [ndctl PATCH 2/3] ndctl, update: fix " Vishal Verma
@ 2018-02-21 23:02 ` Vishal Verma
  2018-02-21 23:06 ` [ndctl PATCH 4/3] ndctl, configure: add -Wmaybe-uninitialized to cflags Vishal Verma
  3 siblings, 0 replies; 5+ messages in thread
From: Vishal Verma @ 2018-02-21 23:02 UTC (permalink / raw)
  To: linux-nvdimm

ndctl_cmd_unref() already checks for the cmd being NULL, no need to
check at every call site.

Cc: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 ndctl/update.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/ndctl/update.c b/ndctl/update.c
index 71d95eb..4ca6a0d 100644
--- a/ndctl/update.c
+++ b/ndctl/update.c
@@ -254,8 +254,7 @@ static int send_firmware(struct update_context *uctx)
 	}
 
 cleanup:
-	if (cmd)
-		ndctl_cmd_unref(cmd);
+	ndctl_cmd_unref(cmd);
 	free(buf);
 	return rc;
 }
@@ -546,8 +545,7 @@ int cmd_update_firmware(int argc, const char **argv, void *ctx)
 	if (rc < 0)
 		return rc;
 
-	if (uctx.start)
-		ndctl_cmd_unref(uctx.start);
+	ndctl_cmd_unref(uctx.start);
 
 	return 0;
 }
-- 
2.14.3

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [ndctl PATCH 4/3] ndctl, configure: add -Wmaybe-uninitialized to cflags
  2018-02-21 23:02 [ndctl PATCH 0/3] add -Wmaybe-uninitialized Vishal Verma
                   ` (2 preceding siblings ...)
  2018-02-21 23:02 ` [ndctl PATCH 3/3] ndctl, update: remove the check for !cmd when dereferencing it Vishal Verma
@ 2018-02-21 23:06 ` Vishal Verma
  3 siblings, 0 replies; 5+ messages in thread
From: Vishal Verma @ 2018-02-21 23:06 UTC (permalink / raw)
  To: linux-nvdimm

rpmbuild had the above cflag enabled, but local builds didn't, resulting
in missed warnings. Add it to my_CFLAGS in configure.ac

Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
 configure.ac | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure.ac b/configure.ac
index 70ba360..9067b41 100644
--- a/configure.ac
+++ b/configure.ac
@@ -145,6 +145,7 @@ my_CFLAGS="\
 -Wsign-compare \
 -Wstrict-prototypes \
 -Wtype-limits \
+-Wmaybe-uninitialized
 "
 AC_SUBST([my_CFLAGS])
 
-- 
2.14.3

_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-02-21 23:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-21 23:02 [ndctl PATCH 0/3] add -Wmaybe-uninitialized Vishal Verma
2018-02-21 23:02 ` [ndctl PATCH 1/3] ndctl, inject-smart: cleanup uninitialized variable warnings Vishal Verma
2018-02-21 23:02 ` [ndctl PATCH 2/3] ndctl, update: fix " Vishal Verma
2018-02-21 23:02 ` [ndctl PATCH 3/3] ndctl, update: remove the check for !cmd when dereferencing it Vishal Verma
2018-02-21 23:06 ` [ndctl PATCH 4/3] ndctl, configure: add -Wmaybe-uninitialized to cflags Vishal Verma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).