Skip to content

Commit bc3e7c6

Browse files
liuzhenigaw
authored andcommitted
ocp-nvme: fix the error display of Hardware Component Log
The display of Hardware Component (Log Identifier C6h) failures to comply with protocol OCP2.5 Issue: #2566 Signed-off-by: liuzhen <[email protected]>
1 parent d81cd5e commit bc3e7c6

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

plugins/ocp/ocp-hardware-component-log.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,7 @@ static int get_hwcomp_log_data(struct nvme_dev *dev, struct hwcomp_log *log)
193193
print_info_array("guid", log->guid, ARRAY_SIZE(log->guid));
194194
print_info("size: %s\n", uint128_t_to_string(le128_to_cpu(log->size)));
195195

196-
args.len = uint128_t_to_double(le128_to_cpu(log->size)) * sizeof(__le32) -
197-
offsetof(struct __packed hwcomp_log, desc);
196+
args.len = uint128_t_to_double(le128_to_cpu(log->size)) * sizeof(__le32) - desc_offset;
198197
log->desc = calloc(1, args.len);
199198
if (!log->desc) {
200199
fprintf(stderr, "error: ocp: calloc: %s\n", strerror(errno));

plugins/ocp/ocp-print-json.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static void json_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list)
7373
obj_add_byte_array(r, "Log page GUID", log->guid, ARRAY_SIZE(log->guid));
7474
obj_add_nprix64(r, "Hardware Component Log Size", (unsigned long long)log_size);
7575
obj_add_byte_array(r, "Reserved48", log->rsvd48, ARRAY_SIZE(log->rsvd48));
76-
print_hwcomp_descs_json(log->desc, log_size, id, list,
76+
print_hwcomp_descs_json(log->desc, log_size - offsetof(struct hwcomp_log, desc), id, list,
7777
obj_create_array_obj(r, "Component Descriptions"));
7878

7979
json_print(r);

plugins/ocp/ocp-print-stdout.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ static void stdout_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list)
4141
printf("Hardware Component Log Size: 0x%"PRIx64"\n", (uint64_t)log_size);
4242
print_array("Reserved48", log->rsvd48, ARRAY_SIZE(log->rsvd48));
4343
printf("Component Descriptions\n");
44+
log_size -= offsetof(struct hwcomp_log, desc);
4445
while (log_size > 0) {
4546
e.date_lot_size = le64_to_cpu(e.desc->date_lot_size) * sizeof(__le32);
4647
e.date_lot_code = e.date_lot_size ? (__u8 *)e.desc + date_lot_code_offset : NULL;

0 commit comments

Comments
 (0)