diff mbox series

[ndctl,v3,3/3] cxl/json.c: Fix the error checking logic when listing device's health info

Message ID 20230810082354.5992-4-jehoon.park@samsung.com (mailing list archive)
State New, archived
Delegated to: Vishal Verma
Headers show
Series Fix accessors for negative fields and error checking for health info | expand

Commit Message

Jehoon Park Aug. 10, 2023, 8:23 a.m. UTC
Change the variable type for storing result of life used field accessor
: u32 to int.
Fix the value for checking device's life used field is implemented.

Signed-off-by: Jehoon Park <jehoon.park@samsung.com>
---
 cxl/json.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/cxl/json.c b/cxl/json.c
index 89e5fd0..102bfaf 100644
--- a/cxl/json.c
+++ b/cxl/json.c
@@ -1,5 +1,6 @@ 
 // SPDX-License-Identifier: GPL-2.0
 // Copyright (C) 2015-2021 Intel Corporation. All rights reserved.
+#include <errno.h>
 #include <limits.h>
 #include <util/json.h>
 #include <uuid/uuid.h>
@@ -238,9 +239,9 @@  static struct json_object *util_cxl_memdev_health_to_json(
 		json_object_object_add(jhealth, "ext_corrected_persistent", jobj);
 
 	/* other fields */
-	field = cxl_cmd_health_info_get_life_used(cmd);
-	if (field != 0xff) {
-		jobj = json_object_new_int(field);
+	rc = cxl_cmd_health_info_get_life_used(cmd);
+	if (rc != -EOPNOTSUPP) {
+		jobj = json_object_new_int(rc);
 		if (jobj)
 			json_object_object_add(jhealth, "life_used_percent", jobj);
 	}