On Mon, Oct 1, 2018 at 8:38 PM Vishal Verma <[email protected]> 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 <[email protected]> > Signed-off-by: Vishal Verma <[email protected]> > --- > 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 [email protected] https://lists.01.org/mailman/listinfo/linux-nvdimm
