From 1da23bf0affebc8aa4401d9f2109e4d09af64712 Mon Sep 17 00:00:00 2001 From: jeff-lien-wdc Date: Mon, 23 Sep 2024 14:37:32 -0500 Subject: [PATCH] ocp: checkpatch.pl and code scanner fixes Signed-off-by: jeff-lien-wdc --- plugins/ocp/ocp-nvme.c | 2 +- plugins/ocp/ocp-telemetry-decode.c | 160 +++++++++++++++++------------ 2 files changed, 98 insertions(+), 64 deletions(-) diff --git a/plugins/ocp/ocp-nvme.c b/plugins/ocp/ocp-nvme.c index fa6af57bce..e0096744b8 100644 --- a/plugins/ocp/ocp-nvme.c +++ b/plugins/ocp/ocp-nvme.c @@ -1329,7 +1329,7 @@ static int get_telemetry_dump(struct nvme_dev *dev, char *filename, char *sn, char *da1_fifo = calloc(da1_sz, sizeof(char)); - printf("Get DA 1 FIFO addr: %p, offset 0x%llx \n", + printf("Get DA 1 FIFO addr: %p, offset 0x%llx\n", da1_fifo, da1_off); err = get_telemetry_data(dev, nsid, tele_type, (da1->event_fifos[i].size) * 4, diff --git a/plugins/ocp/ocp-telemetry-decode.c b/plugins/ocp/ocp-telemetry-decode.c index 1480391c8b..e29bf45aa1 100644 --- a/plugins/ocp/ocp-telemetry-decode.c +++ b/plugins/ocp/ocp-telemetry-decode.c @@ -656,16 +656,18 @@ void parse_time_stamp_event(struct nvme_ocp_telemetry_event_descriptor *pevent_d vu_data = true; vu_data_size = ((pevent_descriptor->event_data_size * SIZE_OF_DWORD) - - (sizeof(struct nvme_ocp_time_stamp_dbg_evt_class_format) + SIZE_OF_VU_EVENT_ID)); + (sizeof(struct nvme_ocp_time_stamp_dbg_evt_class_format) + + SIZE_OF_VU_EVENT_ID)); - ptime_stamp_event_vu_data = (struct nvme_ocp_common_dbg_evt_class_vu_data *) - (ptime_stamp_event + sizeof(struct nvme_ocp_time_stamp_dbg_evt_class_format)); + ptime_stamp_event_vu_data = + (struct nvme_ocp_common_dbg_evt_class_vu_data *)ptime_stamp_event + + sizeof(struct nvme_ocp_time_stamp_dbg_evt_class_format); vu_event_id = ptime_stamp_event_vu_data->vu_event_identifier; pdata = (__u8 *)&(ptime_stamp_event_vu_data->data); parse_ocp_telemetry_string_log(0, vu_event_id, - pevent_descriptor->debug_event_class_type, - VU_EVENT_STRING, description_str); + pevent_descriptor->debug_event_class_type, + VU_EVENT_STRING, description_str); } if (pevent_fifos_object != NULL) { @@ -718,15 +720,18 @@ void parse_pcie_event(struct nvme_ocp_telemetry_event_descriptor *pevent_descrip vu_data = true; vu_data_size = ((pevent_descriptor->event_data_size * SIZE_OF_DWORD) - - (sizeof(struct nvme_ocp_pcie_dbg_evt_class_format) + SIZE_OF_VU_EVENT_ID)); + (sizeof(struct nvme_ocp_pcie_dbg_evt_class_format) + + SIZE_OF_VU_EVENT_ID)); - ppcie_event_vu_data = (struct nvme_ocp_common_dbg_evt_class_vu_data *) - (ppcie_event + sizeof(struct nvme_ocp_pcie_dbg_evt_class_format)); + ppcie_event_vu_data = + (struct nvme_ocp_common_dbg_evt_class_vu_data *)ppcie_event + + sizeof(struct nvme_ocp_pcie_dbg_evt_class_format); vu_event_id = ppcie_event_vu_data->vu_event_identifier; pdata = (__u8 *)&(ppcie_event_vu_data->data); parse_ocp_telemetry_string_log(0, vu_event_id, - pevent_descriptor->debug_event_class_type, VU_EVENT_STRING, description_str); + pevent_descriptor->debug_event_class_type, + VU_EVENT_STRING, description_str); } if (pevent_fifos_object != NULL) { @@ -779,15 +784,19 @@ void parse_nvme_event(struct nvme_ocp_telemetry_event_descriptor *pevent_descrip vu_data = true; vu_data_size = ((pevent_descriptor->event_data_size * SIZE_OF_DWORD) - - (sizeof(struct nvme_ocp_nvme_dbg_evt_class_format) + SIZE_OF_VU_EVENT_ID)); - pnvme_event_vu_data = (struct nvme_ocp_common_dbg_evt_class_vu_data *) - (pnvme_event + sizeof(struct nvme_ocp_nvme_dbg_evt_class_format)); + (sizeof(struct nvme_ocp_nvme_dbg_evt_class_format) + + SIZE_OF_VU_EVENT_ID)); + pnvme_event_vu_data = + (struct nvme_ocp_common_dbg_evt_class_vu_data *)pnvme_event + + sizeof(struct nvme_ocp_nvme_dbg_evt_class_format); vu_event_id = pnvme_event_vu_data->vu_event_identifier; pdata = (__u8 *)&(pnvme_event_vu_data->data); parse_ocp_telemetry_string_log(0, vu_event_id, - pevent_descriptor->debug_event_class_type, VU_EVENT_STRING, description_str); + pevent_descriptor->debug_event_class_type, + VU_EVENT_STRING, + description_str); } if (pevent_fifos_object != NULL) { @@ -828,9 +837,9 @@ void parse_common_event(struct nvme_ocp_telemetry_event_descriptor *pevent_descr { if (pevent_specific_data) { struct nvme_ocp_common_dbg_evt_class_vu_data *pcommon_debug_event_vu_data = - (struct nvme_ocp_common_dbg_evt_class_vu_data *) pevent_specific_data; + (struct nvme_ocp_common_dbg_evt_class_vu_data *) pevent_specific_data; - __le16 vu_event_id = pcommon_debug_event_vu_data->vu_event_identifier;; + __le16 vu_event_id = pcommon_debug_event_vu_data->vu_event_identifier; char description_str[256] = ""; __u8 *pdata = (__u8 *)&(pcommon_debug_event_vu_data->data); @@ -838,7 +847,8 @@ void parse_common_event(struct nvme_ocp_telemetry_event_descriptor *pevent_descr SIZE_OF_DWORD) - SIZE_OF_VU_EVENT_ID); parse_ocp_telemetry_string_log(0, vu_event_id, - pevent_descriptor->debug_event_class_type, VU_EVENT_STRING, description_str); + pevent_descriptor->debug_event_class_type, + VU_EVENT_STRING, description_str); if (pevent_fifos_object != NULL) { json_add_formatted_u32_str(pevent_descriptor_obj, STR_VU_EVENT_ID_STRING, @@ -880,15 +890,19 @@ void parse_media_wear_event(struct nvme_ocp_telemetry_event_descriptor *pevent_d vu_data = true; vu_data_size = ((pevent_descriptor->event_data_size * SIZE_OF_DWORD) - - (sizeof(struct nvme_ocp_media_wear_dbg_evt_class_format) + SIZE_OF_VU_EVENT_ID)); + (sizeof(struct nvme_ocp_media_wear_dbg_evt_class_format) + + SIZE_OF_VU_EVENT_ID)); - pmedia_wear_event_vu_data = (struct nvme_ocp_common_dbg_evt_class_vu_data *) - (pmedia_wear_event + sizeof(struct nvme_ocp_media_wear_dbg_evt_class_format)); + pmedia_wear_event_vu_data = + (struct nvme_ocp_common_dbg_evt_class_vu_data *)pmedia_wear_event + + sizeof(struct nvme_ocp_media_wear_dbg_evt_class_format); vu_event_id = pmedia_wear_event_vu_data->vu_event_identifier; pdata = (__u8 *)&(pmedia_wear_event_vu_data->data); parse_ocp_telemetry_string_log(0, vu_event_id, - pevent_descriptor->debug_event_class_type, VU_EVENT_STRING, description_str); + pevent_descriptor->debug_event_class_type, + VU_EVENT_STRING, + description_str); } if (pevent_fifos_object != NULL) { @@ -983,6 +997,7 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start, SIZE_OF_DWORD; __u8 *pevent_specific_data = NULL; + if (pevent_descriptor != NULL && pevent_descriptor->event_data_size > 0) pevent_specific_data = (__u8 *)pevent_descriptor + event_des_size; @@ -1034,49 +1049,65 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start, } switch (pevent_descriptor->debug_event_class_type) { - case TIME_STAMP_CLASS_TYPE: - parse_time_stamp_event(pevent_descriptor, pevent_descriptor_obj, - pevent_specific_data, pevent_fifos_object, fp); - break; - case PCIE_CLASS_TYPE: - parse_pcie_event(pevent_descriptor, pevent_descriptor_obj, - pevent_specific_data, pevent_fifos_object, fp); - break; - case NVME_CLASS_TYPE: - parse_nvme_event(pevent_descriptor, pevent_descriptor_obj, - pevent_specific_data, pevent_fifos_object, fp); - break; - case RESET_CLASS_TYPE: - case BOOT_SEQUENCE_CLASS_TYPE: - case FIRMWARE_ASSERT_CLASS_TYPE: - case TEMPERATURE_CLASS_TYPE: - case MEDIA_CLASS_TYPE: - parse_common_event(pevent_descriptor, pevent_descriptor_obj, - pevent_specific_data, pevent_fifos_object, fp); - break; - case MEDIA_WEAR_CLASS_TYPE: - parse_media_wear_event(pevent_descriptor, pevent_descriptor_obj, - pevent_specific_data, pevent_fifos_object, fp); - break; - case STATISTIC_SNAPSHOT_CLASS_TYPE: { - struct nvme_ocp_statistic_snapshot_evt_class_format - *pStaticSnapshotEvent = - (struct nvme_ocp_statistic_snapshot_evt_class_format *) - pevent_specific_data; - struct nvme_ocp_telemetry_statistic_descriptor *pstatistic_entry = - (struct nvme_ocp_telemetry_statistic_descriptor *) - (&pStaticSnapshotEvent->statisticDescriptorData); - - parse_statistic(pstatistic_entry, pevent_descriptor_obj, fp); - break; - } - case RESERVED_CLASS_TYPE: - default: - break; + case TIME_STAMP_CLASS_TYPE: + parse_time_stamp_event(pevent_descriptor, + pevent_descriptor_obj, + pevent_specific_data, + pevent_fifos_object, + fp); + break; + case PCIE_CLASS_TYPE: + parse_pcie_event(pevent_descriptor, + pevent_descriptor_obj, + pevent_specific_data, + pevent_fifos_object, + fp); + break; + case NVME_CLASS_TYPE: + parse_nvme_event(pevent_descriptor, + pevent_descriptor_obj, + pevent_specific_data, + pevent_fifos_object, + fp); + break; + case RESET_CLASS_TYPE: + case BOOT_SEQUENCE_CLASS_TYPE: + case FIRMWARE_ASSERT_CLASS_TYPE: + case TEMPERATURE_CLASS_TYPE: + case MEDIA_CLASS_TYPE: + parse_common_event(pevent_descriptor, + pevent_descriptor_obj, + pevent_specific_data, + pevent_fifos_object, + fp); + break; + case MEDIA_WEAR_CLASS_TYPE: + parse_media_wear_event(pevent_descriptor, + pevent_descriptor_obj, + pevent_specific_data, + pevent_fifos_object, + fp); + break; + case STATISTIC_SNAPSHOT_CLASS_TYPE: { + struct nvme_ocp_statistic_snapshot_evt_class_format + *pStaticSnapshotEvent = + (struct nvme_ocp_statistic_snapshot_evt_class_format *) + pevent_specific_data; + struct nvme_ocp_telemetry_statistic_descriptor *pstatistic_entry = + (struct nvme_ocp_telemetry_statistic_descriptor *) + (&pStaticSnapshotEvent->statisticDescriptorData); + + parse_statistic(pstatistic_entry, pevent_descriptor_obj, fp); + break; + } + case RESERVED_CLASS_TYPE: + default: + break; } if (pevent_descriptor_obj != NULL && pevent_fifo_array != NULL) - json_array_add_value_object(pevent_fifo_array, pevent_descriptor_obj); + json_array_add_value_object(pevent_fifo_array, + pevent_descriptor_obj); else { if (fp) fprintf(fp, STR_LINE2); @@ -1086,7 +1117,8 @@ int parse_event_fifo(unsigned int fifo_num, unsigned char *pfifo_start, } else break; - offset_to_move += (pevent_descriptor->event_data_size * SIZE_OF_DWORD + event_des_size); + offset_to_move += (pevent_descriptor->event_data_size * SIZE_OF_DWORD + + event_des_size); } if (pevent_fifos_object != NULL && pevent_fifo_array != NULL) @@ -1330,8 +1362,10 @@ int print_ocp_telemetry_normal(struct ocp_telemetry_parse_options *options) (ARRAY_SIZE(host_log_page_header) == 0)) printf("skip generic_structure_parser\n"); else - generic_structure_parser(ptelemetry_buffer, host_log_page_header, - ARRAY_SIZE(host_log_page_header), NULL, 0, fp); + generic_structure_parser(ptelemetry_buffer, + host_log_page_header, + ARRAY_SIZE(host_log_page_header), + NULL, 0, fp); } else if (!strcmp(options->telemetry_type, "controller")) generic_structure_parser(ptelemetry_buffer,