All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: linux-nvdimm@lists.01.org
Subject: [ndctl PATCH 4/4] ndctl, list: hide badblock_count by default
Date: Thu, 11 May 2017 15:01:46 -0700	[thread overview]
Message-ID: <149454010604.30857.15214297566335127724.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <149454009049.30857.6643219237076670086.stgit@dwillia2-desk3.amr.corp.intel.com>

In order to keep the default listing as compact as possible, hide
badblock_count when it is zero.

Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Toshi Kani <toshi.kani@hpe.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 ndctl/list.c |   12 +++++++-----
 util/json.c  |   14 ++++++++------
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/ndctl/list.c b/ndctl/list.c
index cf26d8c08183..befb3cfc6ffd 100644
--- a/ndctl/list.c
+++ b/ndctl/list.c
@@ -209,12 +209,14 @@ static struct json_object *region_to_json(struct ndctl_region *region,
 
 	jbbs = util_region_badblocks_to_json(region, include_media_errors,
 			&bb_count);
-	jobj = json_object_new_int(bb_count);
-	if (!jobj) {
-		json_object_put(jbbs);
-		goto err;
+	if (bb_count) {
+		jobj = json_object_new_int(bb_count);
+		if (!jobj) {
+			json_object_put(jbbs);
+			goto err;
+		}
+		json_object_object_add(jregion, "badblock_count", jobj);
 	}
-	json_object_object_add(jregion, "badblock_count", jobj);
 	if (include_media_errors && jbbs)
 		json_object_object_add(jregion, "badblocks", jbbs);
 
diff --git a/util/json.c b/util/json.c
index 17595267c34c..4ca33a628381 100644
--- a/util/json.c
+++ b/util/json.c
@@ -568,15 +568,17 @@ struct json_object *util_namespace_to_json(struct ndctl_namespace *ndns,
 				ndctl_namespace_get_region(ndns),
 				include_media_errors, &bb_count);
 
-	jobj = json_object_new_int(bb_count);
-	if (!jobj) {
-		json_object_put(jbbs);
-		goto err;
+	if (bb_count) {
+		jobj = json_object_new_int(bb_count);
+		if (!jobj) {
+			json_object_put(jbbs);
+			goto err;
+		}
+		json_object_object_add(jndns, "badblock_count", jobj);
 	}
 
-	json_object_object_add(jndns, "badblock_count", jobj);
 	if (include_media_errors && jbbs)
-			json_object_object_add(jndns, "badblocks", jbbs);
+		json_object_object_add(jndns, "badblocks", jbbs);
 
 	return jndns;
  err:

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

  parent reply	other threads:[~2017-05-11 22:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-11 22:01 [ndctl PATCH 1/4] util: mark badblocks helpers static Dan Williams
2017-05-11 22:01 ` [ndctl PATCH 2/4] ndctl, list: clarify dev_badblocks_to_json() usage with btt and documentation Dan Williams
2017-05-11 22:01 ` [ndctl PATCH 3/4] ndctl, list: fix span for btt badblocks check Dan Williams
2017-05-11 22:01 ` Dan Williams [this message]
2017-05-11 22:33   ` [ndctl PATCH 4/4] ndctl, list: hide badblock_count by default Kani, Toshimitsu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=149454010604.30857.15214297566335127724.stgit@dwillia2-desk3.amr.corp.intel.com \
    --to=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.