@@ -442,7 +442,7 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder,
const char *devname = cxl_decoder_get_devname(decoder);
struct cxl_port *port = cxl_decoder_get_port(decoder);
struct json_object *jdecoder, *jobj;
- u64 val;
+ u64 val, size;
jdecoder = json_object_new_object();
if (!jdecoder)
@@ -452,21 +452,21 @@ struct json_object *util_cxl_decoder_to_json(struct cxl_decoder *decoder,
if (jobj)
json_object_object_add(jdecoder, "decoder", jobj);
+ size = cxl_decoder_get_size(decoder);
val = cxl_decoder_get_resource(decoder);
- if (val < ULLONG_MAX) {
+ if (size && val < ULLONG_MAX) {
jobj = util_json_object_hex(val, flags);
if (jobj)
json_object_object_add(jdecoder, "resource", jobj);
}
- val = cxl_decoder_get_size(decoder);
- if (val < ULLONG_MAX) {
- jobj = util_json_object_size(val, flags);
+ if (size && size < ULLONG_MAX) {
+ jobj = util_json_object_size(size, flags);
if (jobj)
json_object_object_add(jdecoder, "size", jobj);
}
- if (val == 0) {
+ if (size == 0) {
jobj = json_object_new_string("disabled");
if (jobj)
json_object_object_add(jdecoder, "state", jobj);