nvdimm.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Dan Williams <dan.j.williams@intel.com>
To: Vishal L Verma <vishal.l.verma@intel.com>
Cc: linux-nvdimm <linux-nvdimm@lists.01.org>
Subject: Re: [ndctl PATCH 4/5] util/json: consolidate check for the UTIL_JSON_MEDIA_ERRORS flag
Date: Tue, 2 Oct 2018 18:52:06 -0700	[thread overview]
Message-ID: <CAPcyv4jymeoY0ZVgF5OH06+ZEesnzjVJPxN=zffcBFRt+OT3yA@mail.gmail.com> (raw)
In-Reply-To: <20181002033140.21295-4-vishal.l.verma@intel.com>

On Mon, Oct 1, 2018 at 8:38 PM Vishal Verma <vishal.l.verma@intel.com> wrote:
>
> We don't need to check for the above flag for each badblock we're
> iterating over. Remove the check in the respective loops, and return
> early if it is not set.
>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> ---
>  util/json.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/util/json.c b/util/json.c
> index 30b56c3..4dd5fc3 100644
> --- a/util/json.c
> +++ b/util/json.c
> @@ -457,7 +457,8 @@ struct json_object *util_region_badblocks_to_json(struct ndctl_region *region,
>                 jbbs = json_object_new_array();
>                 if (!jbbs)
>                         return NULL;
> -       }
> +       } else
> +               return NULL;
>
>         ndctl_region_badblock_foreach(region, bb) {
>                 struct json_object *jdimms;
> @@ -465,9 +466,6 @@ struct json_object *util_region_badblocks_to_json(struct ndctl_region *region,
>
>                 bbs += bb->len;
>
> -               if (!(flags & UTIL_JSON_MEDIA_ERRORS))
> -                       continue;
> -

The reason for this awkwardness is to account for the total badblocks
count even when the individual badblocks are not emitted. See that
"bbs += bb->len" that will now be skipped. Perhaps at least a comment
is needed because that trickery is not obvious.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

  reply	other threads:[~2018-10-03  1:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-02  3:31 [ndctl PATCH 1/5] ndctl, lib: refactor badblocks retrieval routines Vishal Verma
2018-10-02  3:31 ` [ndctl PATCH 2/5] ndctl, lib: add APIs for retrieving namespace badblocks Vishal Verma
2018-10-02  3:31 ` [ndctl PATCH 3/5] util/json: fix an error check for region resource Vishal Verma
2018-10-03  1:47   ` Dan Williams
2018-10-02  3:31 ` [ndctl PATCH 4/5] util/json: consolidate check for the UTIL_JSON_MEDIA_ERRORS flag Vishal Verma
2018-10-03  1:52   ` Dan Williams [this message]
2018-10-02  3:31 ` [ndctl PATCH 5/5] util/json: add a util_namespace_badblocks_to_json() helper Vishal Verma
2018-10-03  1:58   ` Dan Williams

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='CAPcyv4jymeoY0ZVgF5OH06+ZEesnzjVJPxN=zffcBFRt+OT3yA@mail.gmail.com' \
    --to=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=vishal.l.verma@intel.com \
    /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 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).