[ndctl,02/16] ndctl/dimm: Fix chatty status messages
diff mbox series

Message ID 159408962923.2386154.3504999903908710322.stgit@dwillia2-desk3.amr.corp.intel.com
State Superseded
Headers show
Series
  • Firmware Activation and Test Updates
Related show

Commit Message

Dan Williams July 7, 2020, 2:40 a.m. UTC
Firmware update and overwrite violate the general design principle of ndctl
that all stdout messages are json formatted. Move the raw status messages
to stderr. Some of the messages are obviously debug and should be moved
under a verbose option, while others confuse use of error() vs
fprintf(stderr, ...). The error() helper is preferred for messages
indicating command failures vs notices.

Cc: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/dimm.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Patch
diff mbox series

diff --git a/ndctl/dimm.c b/ndctl/dimm.c
index 3db01431d618..8523ead36eb5 100644
--- a/ndctl/dimm.c
+++ b/ndctl/dimm.c
@@ -795,15 +795,16 @@  static int update_firmware(struct ndctl_dimm *dimm,
 	if (rc < 0)
 		return rc;
 
-	printf("Uploading firmware to DIMM %s.\n",
-			ndctl_dimm_get_devname(dimm));
+	if (param.verbose)
+		fprintf(stderr, "Uploading firmware to DIMM %s.\n",
+				ndctl_dimm_get_devname(dimm));
 
 	rc = send_firmware(dimm, actx);
 	if (rc < 0) {
-		fprintf(stderr, "Firmware send failed. Aborting!\n");
+		error("Firmware send failed. Aborting!\n");
 		rc = submit_abort_firmware(dimm, actx);
 		if (rc < 0)
-			fprintf(stderr, "Aborting update sequence failed.\n");
+			error("Aborting update sequence failed.\n");
 		return rc;
 	}
 
@@ -945,7 +946,8 @@  static int action_sanitize_dimm(struct ndctl_dimm *dimm,
 	 */
 	if (!param.crypto_erase && !param.overwrite) {
 		param.crypto_erase = true;
-		printf("No santize method passed in, default to crypto-erase\n");
+		if (param.verbose)
+			fprintf(stderr, "No santize method passed in, default to crypto-erase\n");
 	}
 
 	if (param.crypto_erase) {
@@ -982,8 +984,8 @@  static int action_wait_overwrite(struct ndctl_dimm *dimm,
 	}
 
 	rc = ndctl_dimm_wait_overwrite(dimm);
-	if (rc == 1)
-		printf("%s: overwrite completed.\n",
+	if (rc == 1 && param.verbose)
+		fprintf(stderr, "%s: overwrite completed.\n",
 				ndctl_dimm_get_devname(dimm));
 	return rc;
 }