add -Wmaybe-uninitialized
Vishal Verma
maintainercover add -Wmaybe-uninitialized
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(-)
Signature · 6 lines
2.14.3 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Vishal Verma
maintainerPATCH 1/3 ndctl, inject-smart: cleanup uninitialized variable warnings
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.
--- ndctl/inject-smart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
ndctl/inject-smart.c +2 -2
@@ -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)
Signature · 6 lines
2.14.3 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Vishal Verma
maintainerPATCH 2/3 ndctl, update: fix uninitialized variable warnings
In reply to Vishal VermaIn 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.
--- ndctl/update.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ndctl/update.c +1 -1
@@ -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;
Signature · 6 lines
2.14.3 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Vishal Verma
maintainerPATCH 3/3 ndctl, update: remove the check for !cmd when dereferencing it
In reply to Vishal Vermandctl_cmd_unref() already checks for the cmd being NULL, no need to check at every call site.
--- ndctl/update.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
ndctl/update.c +2 -4
@@ -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 ; }
Signature · 6 lines
2.14.3 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
Vishal Verma
maintainer[ndctl PATCH 4/3] ndctl, configure: add -Wmaybe-uninitialized to cflags
In reply to Vishal Vermarpmbuild had the above cflag enabled, but local builds didn't, resulting in missed warnings. Add it to my_CFLAGS in configure.ac
--- configure.ac | 1 + 1 file changed, 1 insertion(+)
configure.ac +1 -0
@@ -145,6 +145,7 @@ my_CFLAGS="\ -Wsign-compare \ -Wstrict-prototypes \ -Wtype-limits \ +-Wmaybe-uninitialized " AC_SUBST([my_CFLAGS])
Signature · 6 lines
2.14.3 _______________________________________________ Linux-nvdimm mailing list [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm