From c5e7f1f932ef147c43355fba610bba339055406e Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Sun, 29 Dec 2024 21:02:32 +0900 Subject: [PATCH] ocp: change hwcomp log size variable name to log_bytes Since the size value calculated to bytes from dwords for version 1. Signed-off-by: Tokunori Ikegami --- plugins/ocp/ocp-print-binary.c | 7 ++++--- plugins/ocp/ocp-print-json.c | 8 ++++---- plugins/ocp/ocp-print-stdout.c | 12 ++++++------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/plugins/ocp/ocp-print-binary.c b/plugins/ocp/ocp-print-binary.c index b9cd31567b..c966b4737f 100644 --- a/plugins/ocp/ocp-print-binary.c +++ b/plugins/ocp/ocp-print-binary.c @@ -7,11 +7,12 @@ static void binary_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list) { - long double desc_len = uint128_t_to_double(le128_to_cpu(log->size)); + long double log_bytes = uint128_t_to_double(le128_to_cpu(log->size)); + if (log->ver == 1) - desc_len *= sizeof(__le32); + log_bytes *= sizeof(__le32); - d_raw((unsigned char *)log, desc_len); + d_raw((unsigned char *)log, log_bytes); } static void binary_c5_log(struct nvme_dev *dev, struct unsupported_requirement_log *log_data) diff --git a/plugins/ocp/ocp-print-json.c b/plugins/ocp/ocp-print-json.c index fe752e414c..5f0902716c 100644 --- a/plugins/ocp/ocp-print-json.c +++ b/plugins/ocp/ocp-print-json.c @@ -63,19 +63,19 @@ static void print_hwcomp_descs_json(struct hwcomp_desc *desc, long double log_si static void json_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list) { + long double log_bytes = uint128_t_to_double(le128_to_cpu(log->size)); struct json_object *r = json_create_object(); - long double log_size = uint128_t_to_double(le128_to_cpu(log->size)); if (log->ver == 1) - log_size *= sizeof(__le32); + log_bytes *= sizeof(__le32); obj_add_uint_02x(r, "Log Identifier", OCP_LID_HWCOMP); obj_add_uint_0x(r, "Log Page Version", le16_to_cpu(log->ver)); obj_add_byte_array(r, "Reserved2", log->rsvd2, ARRAY_SIZE(log->rsvd2)); obj_add_byte_array(r, "Log page GUID", log->guid, ARRAY_SIZE(log->guid)); - obj_add_nprix64(r, "Hardware Component Log Size", (unsigned long long)log_size); + obj_add_nprix64(r, "Hardware Component Log Size", (unsigned long long)log_bytes); obj_add_byte_array(r, "Reserved48", log->rsvd48, ARRAY_SIZE(log->rsvd48)); - print_hwcomp_descs_json(log->desc, log_size - offsetof(struct hwcomp_log, desc), id, list, + print_hwcomp_descs_json(log->desc, log_bytes - offsetof(struct hwcomp_log, desc), id, list, obj_create_array_obj(r, "Component Descriptions")); json_print(r); diff --git a/plugins/ocp/ocp-print-stdout.c b/plugins/ocp/ocp-print-stdout.c index 336d761552..6a16c53863 100644 --- a/plugins/ocp/ocp-print-stdout.c +++ b/plugins/ocp/ocp-print-stdout.c @@ -30,21 +30,21 @@ static void stdout_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list) { size_t date_lot_code_offset = sizeof(struct hwcomp_desc); int num = 1; + long double log_bytes = uint128_t_to_double(le128_to_cpu(log->size)); struct hwcomp_desc_entry e = { log->desc }; - long double log_size = uint128_t_to_double(le128_to_cpu(log->size)); if (log->ver == 1) - log_size *= sizeof(__le32); + log_bytes *= sizeof(__le32); printf("Log Identifier: 0x%02xh\n", OCP_LID_HWCOMP); printf("Log Page Version: 0x%x\n", le16_to_cpu(log->ver)); print_array("Reserved2", log->rsvd2, ARRAY_SIZE(log->rsvd2)); print_array("Log page GUID", log->guid, ARRAY_SIZE(log->guid)); - printf("Hardware Component Log Size: 0x%"PRIx64"\n", (uint64_t)log_size); + printf("Hardware Component Log Size: 0x%"PRIx64"\n", (uint64_t)log_bytes); print_array("Reserved48", log->rsvd48, ARRAY_SIZE(log->rsvd48)); printf("Component Descriptions\n"); - log_size -= offsetof(struct hwcomp_log, desc); - while (log_size > 0) { + log_bytes -= offsetof(struct hwcomp_log, desc); + while (log_bytes > 0) { e.date_lot_size = le64_to_cpu(e.desc->date_lot_size) * sizeof(__le32); e.date_lot_code = e.date_lot_size ? (__u8 *)e.desc + date_lot_code_offset : NULL; e.add_info_size = le64_to_cpu(e.desc->add_info_size) * sizeof(__le32); @@ -54,7 +54,7 @@ static void stdout_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list) print_hwcomp_desc(&e, list, num++); e.desc_size = date_lot_code_offset + e.date_lot_size + e.add_info_size; e.desc = (struct hwcomp_desc *)((__u8 *)e.desc + e.desc_size); - log_size -= e.desc_size; + log_bytes -= e.desc_size; } }