Skip to content

Commit

Permalink
plugins/ocp: Align ocp_smart_extended_log struct.
Browse files Browse the repository at this point in the history
If the dssd point, minor version are declared as __le16, the alignment
will be broken. Remove __packed keyword.
Change data parameter void to struct ocp_smart_extended_log

Reported-by: Steven Seungcheol Lee <[email protected]>
Signed-off-by: Minsik Jeon <[email protected]>
  • Loading branch information
hmi-jeon committed Dec 23, 2024
1 parent 65d7e7d commit 66b3b6b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions plugins/ocp/ocp-print-json.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ static void json_smart_extended_log_v1(struct ocp_smart_extended_log *log)
json_object_add_value_uint(root, "Errata Version Field",
log->dssd_errata_version);
json_object_add_value_uint(root, "Point Version Field",
le16_to_cpu(log->dssd_point_version));
le16_to_cpu(*(uint16_t *)&log->dssd_point_version));
json_object_add_value_uint(root, "Minor Version Field",
le16_to_cpu(log->dssd_minor_version));
le16_to_cpu(*(uint16_t *)&log->dssd_minor_version));
json_object_add_value_uint(root, "Major Version Field",
log->dssd_major_version);
json_object_add_value_uint(root, "NVMe Base Errata Version",
Expand Down Expand Up @@ -341,9 +341,9 @@ static void json_smart_extended_log_v2(struct ocp_smart_extended_log *log)
json_object_add_value_uint(root, "errata_version_field",
log->dssd_errata_version);
json_object_add_value_uint(root, "point_version_field",
le16_to_cpu(log->dssd_point_version));
le16_to_cpu(*(uint16_t *)&log->dssd_point_version));
json_object_add_value_uint(root, "minor_version_field",
le16_to_cpu(log->dssd_minor_version));
le16_to_cpu(*(uint16_t *)&log->dssd_minor_version));
json_object_add_value_uint(root, "major_version_field",
log->dssd_major_version);
json_object_add_value_uint(root, "nvme_base_errata_version",
Expand Down
4 changes: 2 additions & 2 deletions plugins/ocp/ocp-print-stdout.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ static void stdout_smart_extended_log(struct ocp_smart_extended_log *log, unsign
printf(" Errata Version Field %d\n",
log->dssd_errata_version);
printf(" Point Version Field %"PRIu16"\n",
le16_to_cpu(log->dssd_point_version));
le16_to_cpu(*(uint16_t *)&log->dssd_point_version));
printf(" Minor Version Field %"PRIu16"\n",
le16_to_cpu(log->dssd_minor_version));
le16_to_cpu(*(uint16_t *)&log->dssd_minor_version));
printf(" Major Version Field %d\n",
log->dssd_major_version);
printf(" NVMe Base Errata Version %d\n",
Expand Down
2 changes: 1 addition & 1 deletion plugins/ocp/ocp-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void ocp_fw_act_history(const struct fw_activation_history *fw_history, nvme_pri
ocp_print(fw_act_history, flags, fw_history);
}

void ocp_smart_extended_log(void *data, unsigned int version, nvme_print_flags_t flags)
void ocp_smart_extended_log(struct ocp_smart_extended_log *data, unsigned int version, nvme_print_flags_t flags)

Check failure on line 39 in plugins/ocp/ocp-print.c

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 112 exceeds 100 columns
{
ocp_print(smart_extended_log, flags, data, version);
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/ocp/ocp-print.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static inline struct ocp_print_ops *ocp_get_json_print_ops(nvme_print_flags_t fl

void ocp_show_hwcomp_log(struct hwcomp_log *log, __u32 id, bool list, nvme_print_flags_t flags);
void ocp_fw_act_history(const struct fw_activation_history *fw_history, nvme_print_flags_t flags);
void ocp_smart_extended_log(void *data, unsigned int version, nvme_print_flags_t flags);
void ocp_smart_extended_log(struct ocp_smart_extended_log *data, unsigned int version, nvme_print_flags_t flags);

Check failure on line 40 in plugins/ocp/ocp-print.h

View workflow job for this annotation

GitHub Actions / checkpatch review

WARNING: line length of 113 exceeds 100 columns
void ocp_show_telemetry_log(struct ocp_telemetry_parse_options *options, nvme_print_flags_t flags);
void ocp_c3_log(struct nvme_dev *dev, struct ssd_latency_monitor_log *log_data,
nvme_print_flags_t flags);
Expand Down
6 changes: 3 additions & 3 deletions plugins/ocp/ocp-smart-extended-log.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct plugin;
* @log_page_version: Log page version
* @log_page_guid: Log page GUID
*/
struct __packed ocp_smart_extended_log {
struct ocp_smart_extended_log {
__u8 physical_media_units_written[16]; /* [15:0] */
__u8 physical_media_units_read[16]; /* [31:16] */
__u8 bad_user_nand_blocks_raw[6]; /* [37:32] */
Expand All @@ -77,8 +77,8 @@ struct __packed ocp_smart_extended_log {
__u8 thermal_throttling_event_count; /* [96] */
__u8 thermal_throttling_current_status; /* [97] */
__u8 dssd_errata_version; /* [98] */
__le16 dssd_point_version; /* [100:99] */
__le16 dssd_minor_version; /* [102:101] */
__u8 dssd_point_version[2]; /* [100:99] */
__u8 dssd_minor_version[2]; /* [102:101] */
__u8 dssd_major_version; /* [103] */
__le64 pcie_correctable_err_count; /* [111:104] */
__le32 incomplete_shoutdowns; /* [115:112] */
Expand Down

0 comments on commit 66b3b6b

Please sign in to comment.