Content-Type: multipart/mixed; boundary="===============3224161754315127482==" MIME-Version: 1.0 From: ramesh.thomas at intel.com Subject: [Accel-config] [PATCH v1 6/8] accel-config: Skip negative fields in listings Date: Wed, 05 May 2021 13:44:20 -0400 Message-ID: <20210505174422.837248-7-ramesh.thomas@intel.com> In-Reply-To: 20210505174422.837248-1-ramesh.thomas@intel.com To: accel-config@lists.01.org List-ID: --===============3224161754315127482== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Ramesh Thomas Skip printing cdev_minor and group_id if they have negative values indicating they are invalid or are not initialized. Signed-off-by: Ramesh Thomas --- util/json.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/util/json.c b/util/json.c index b02e336..25514af 100644 --- a/util/json.c +++ b/util/json.c @@ -429,9 +429,11 @@ struct json_object *util_wq_to_json(struct accfg_wq *w= q, json_object_object_add(jaccfg, "size", jobj); } = - jobj =3D json_object_new_int(accfg_wq_get_group_id(wq)); - if (jobj) - json_object_object_add(jaccfg, "group_id", jobj); + if (accfg_wq_get_group_id(wq) >=3D 0) { + jobj =3D json_object_new_int(accfg_wq_get_group_id(wq)); + if (jobj) + json_object_object_add(jaccfg, "group_id", jobj); + } = int_val =3D accfg_wq_get_priority(wq); if (int_val >=3D 0) { @@ -452,7 +454,7 @@ struct json_object *util_wq_to_json(struct accfg_wq *wq, if (jobj) json_object_object_add(jaccfg, "max_transfer_size", jobj); = - if (!(flags & UTIL_JSON_SAVE)) { + if (!(flags & UTIL_JSON_SAVE) && accfg_wq_get_cdev_minor(wq) >=3D 0) { jobj =3D json_object_new_int(accfg_wq_get_cdev_minor(wq)); if (jobj) json_object_object_add(jaccfg, "cdev_minor", jobj); @@ -517,10 +519,12 @@ struct json_object *util_engine_to_json(struct accfg_= engine *engine, goto err; json_object_object_add(jaccfg, "dev", jobj); = - jobj =3D json_object_new_int(accfg_engine_get_group_id(engine)); - if (!jobj) - goto err; - json_object_object_add(jaccfg, "group_id", jobj); + if (accfg_engine_get_group_id(engine) >=3D 0) { + jobj =3D json_object_new_int(accfg_engine_get_group_id(engine)); + if (!jobj) + goto err; + json_object_object_add(jaccfg, "group_id", jobj); + } = return jaccfg; err: -- = 2.26.3 --===============3224161754315127482==--