]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
plugins/ocp: Fix ocp-nvme.c linux kernel check patch warnings
authorTokunori Ikegami <ikegami.t@gmail.com>
Sun, 28 May 2023 10:00:25 +0000 (19:00 +0900)
committerDaniel Wagner <wagi@monom.org>
Thu, 1 Jun 2023 17:45:53 +0000 (19:45 +0200)
Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
common.h
plugins/ocp/ocp-nvme.c

index 6a904e101309a82069992ff4530ca3ce27a4e247..b5594e9f892efe284a876601176c488576700747 100644 (file)
--- a/common.h
+++ b/common.h
 #define min(x, y) ((x) > (y) ? (y) : (x))
 #define max(x, y) ((x) > (y) ? (x) : (y))
 
+#ifdef __packed
+#else /* __packed */
+#define __packed __attribute__((__packed__))
+#endif /* __packed */
+
 static inline uint32_t mmio_read32(void *addr)
 {
        leint32_t *p = addr;
index f6036969b31d010b2feef9a3ec18061d3718e241..ad2cf847d6202f2bd0d27077b60376e848bc68f8 100644 (file)
@@ -61,7 +61,7 @@ static __u8 lat_mon_guid[C3_GUID_LENGTH] = {
 #define TRIM           1
 #define RESERVED       0
 
-struct __attribute__((__packed__)) ssd_latency_monitor_log {
+struct __packed ssd_latency_monitor_log {
        __u8    feature_status;                 /* 0x00 */
        __u8    rsvd1;                          /* 0x01 */
        __le16  active_bucket_timer;            /* 0x02 */
@@ -98,7 +98,7 @@ struct __attribute__((__packed__)) ssd_latency_monitor_log {
        __u8    log_page_guid[0x10];            /* 0x1F0 */
 };
 
-struct __attribute__((__packed__)) feature_latency_monitor {
+struct __packed feature_latency_monitor {
        __u16 active_bucket_timer_threshold;
        __u8  active_threshold_a;
        __u8  active_threshold_b;
@@ -167,32 +167,33 @@ static int ocp_print_C3_log_normal(struct nvme_dev *dev,
               le16_to_cpu(log_data->static_latency_stamp_units));
        printf("  Debug Log Trigger Enable           %d\n",
               le16_to_cpu(log_data->debug_log_trigger_enable));
-       printf("  Debug Log Measured Latency         %d \n",
+       printf("  Debug Log Measured Latency         %d\n",
               le16_to_cpu(log_data->debug_log_measured_latency));
        if (le64_to_cpu(log_data->debug_log_latency_stamp) == -1) {
-              printf("  Debug Log Latency Time Stamp       N/A \n");
+               printf("  Debug Log Latency Time Stamp       N/A\n");
        } else {
-              convert_ts(le64_to_cpu(log_data->debug_log_latency_stamp), ts_buf);
-              printf("  Debug Log Latency Time Stamp       %s \n", ts_buf);
+               convert_ts(le64_to_cpu(log_data->debug_log_latency_stamp), ts_buf);
+               printf("  Debug Log Latency Time Stamp       %s\n", ts_buf);
        }
-       printf("  Debug Log Pointer                  %d \n",
+       printf("  Debug Log Pointer                  %d\n",
               le16_to_cpu(log_data->debug_log_ptr));
-       printf("  Debug Counter Trigger Source       %d \n",
+       printf("  Debug Counter Trigger Source       %d\n",
               le16_to_cpu(log_data->debug_log_counter_trigger));
-       printf("  Debug Log Stamp Units              %d \n",
+       printf("  Debug Log Stamp Units              %d\n",
               le16_to_cpu(log_data->debug_log_stamp_units));
-       printf("  Log Page Version                   %d \n",
+       printf("  Log Page Version                   %d\n",
               le16_to_cpu(log_data->log_page_version));
 
        char guid[(C3_GUID_LENGTH * 2) + 1];
        char *ptr = &guid[0];
-       for (i = C3_GUID_LENGTH - 1; i >= 0; i--) {
+
+       for (i = C3_GUID_LENGTH - 1; i >= 0; i--)
                ptr += sprintf(ptr, "%02X", log_data->log_page_guid[i]);
-       }
-       printf("  Log Page GUID                      %s \n", guid);
+
+       printf("  Log Page GUID                      %s\n", guid);
        printf("\n");
 
-       printf("                                                            Read                           Write                 Deallocate/Trim \n");
+       printf("                                                            Read                           Write                 Deallocate/Trim\n");
        for (i = 0; i < C3_BUCKET_NUM; i++) {
                printf("  Active Latency Mode: Bucket %d      %27d     %27d     %27d\n",
                       i,
@@ -202,7 +203,7 @@ static int ocp_print_C3_log_normal(struct nvme_dev *dev,
        }
 
        for (i = 0; i < C3_BUCKET_NUM; i++) {
-               printf("  Active Bucket Counter: Bucket %d    %27d     %27d     %27d \n",
+               printf("  Active Bucket Counter: Bucket %d    %27d     %27d     %27d\n",
                       i,
                       le32_to_cpu(log_data->active_bucket_counter[i][READ]),
                       le32_to_cpu(log_data->active_bucket_counter[i][WRITE]),
@@ -253,7 +254,7 @@ static int ocp_print_C3_log_normal(struct nvme_dev *dev,
        }
 
        for (i = 0; i < C3_BUCKET_NUM; i++) {
-               printf("  Static Measured Latency: Bucket %d  %27d ms  %27d ms  %27d ms \n",
+               printf("  Static Measured Latency: Bucket %d  %27d ms  %27d ms  %27d ms\n",
                       i,
                       le16_to_cpu(log_data->static_measured_latency[i][READ-1]),
                       le16_to_cpu(log_data->static_measured_latency[i][WRITE-1]),
@@ -414,10 +415,13 @@ static void ocp_print_C3_log_json(struct ssd_latency_monitor_log *log_data)
                le16_to_cpu(log_data->debug_log_stamp_units));
        json_object_add_value_uint(root, "Log Page Version",
                le16_to_cpu(log_data->log_page_version));
+
        char guid[(C3_GUID_LENGTH * 2) + 1];
        char *ptr = &guid[0];
+
        for (i = C3_GUID_LENGTH - 1; i >= 0; i--)
                ptr += sprintf(ptr, "%02X", log_data->log_page_guid[i]);
+
        json_object_add_value_string(root, "Log Page GUID", guid);
 
        json_print_object(root, NULL);
@@ -451,12 +455,9 @@ static int get_c3_log_page(struct nvme_dev *dev, char *format)
                C3_LATENCY_MON_LOG_BUF_LEN, data);
 
        if (strcmp(format, "json"))
-               fprintf(stderr,
-                       "NVMe Status:%s(%x)\n",
-                       nvme_status_to_string(ret, false),
-                       ret);
+               fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(ret, false), ret);
 
-       if (ret == 0) {
+       if (!ret) {
                log_data = (struct ssd_latency_monitor_log *)data;
 
                /* check log page version */
@@ -477,14 +478,12 @@ static int get_c3_log_page(struct nvme_dev *dev, char *format)
 
                                fprintf(stderr, "ERROR : OCP : Unknown GUID in C3 Log Page data\n");
                                fprintf(stderr, "ERROR : OCP : Expected GUID: 0x");
-                               for (j = 0; j < 16; j++) {
+                               for (j = 0; j < 16; j++)
                                        fprintf(stderr, "%x", lat_mon_guid[j]);
-                               }
 
                                fprintf(stderr, "\nERROR : OCP : Actual GUID: 0x");
-                               for (j = 0; j < 16; j++) {
+                               for (j = 0; j < 16; j++)
                                        fprintf(stderr, "%x", log_data->log_page_guid[j]);
-                               }
                                fprintf(stderr, "\n");
 
                                ret = -1;
@@ -658,17 +657,17 @@ int ocp_set_latency_monitor_feature(int argc, char **argv, struct command *cmd,
        if (err < 0) {
                perror("set-feature");
        } else if (!err) {
-               printf("NVME_FEAT_OCP_LATENCY_MONITOR: 0x%02x \n", NVME_FEAT_OCP_LATENCY_MONITOR);
-               printf("active bucket timer threshold: 0x%x \n", buf.active_bucket_timer_threshold);
-               printf("active threshold a: 0x%x \n", buf.active_threshold_a);
-               printf("active threshold b: 0x%x \n", buf.active_threshold_b);
-               printf("active threshold c: 0x%x \n", buf.active_threshold_c);
-               printf("active threshold d: 0x%x \n", buf.active_threshold_d);
-               printf("active latency config: 0x%x \n", buf.active_latency_config);
-               printf("active latency minimum window: 0x%x \n", buf.active_latency_minimum_window);
-               printf("debug log trigger enable: 0x%x \n", buf.debug_log_trigger_enable);
-               printf("discard debug log: 0x%x \n", buf.discard_debug_log);
-               printf("latency monitor feature enable: 0x%x \n", buf.latency_monitor_feature_enable);
+               printf("NVME_FEAT_OCP_LATENCY_MONITOR: 0x%02x\n", NVME_FEAT_OCP_LATENCY_MONITOR);
+               printf("active bucket timer threshold: 0x%x\n", buf.active_bucket_timer_threshold);
+               printf("active threshold a: 0x%x\n", buf.active_threshold_a);
+               printf("active threshold b: 0x%x\n", buf.active_threshold_b);
+               printf("active threshold c: 0x%x\n", buf.active_threshold_c);
+               printf("active threshold d: 0x%x\n", buf.active_threshold_d);
+               printf("active latency config: 0x%x\n", buf.active_latency_config);
+               printf("active latency minimum window: 0x%x\n", buf.active_latency_minimum_window);
+               printf("debug log trigger enable: 0x%x\n", buf.debug_log_trigger_enable);
+               printf("discard debug log: 0x%x\n", buf.discard_debug_log);
+               printf("latency monitor feature enable: 0x%x\n", buf.latency_monitor_feature_enable);
        } else if (err > 0) {
                fprintf(stderr, "NVMe Status:%s(%x)\n", nvme_status_to_string(err, false), err);
        }
@@ -786,7 +785,7 @@ static int eol_plp_failure_mode_set(struct nvme_dev *dev, const __u32 nsid,
 static int eol_plp_failure_mode(int argc, char **argv, struct command *cmd,
                                struct plugin *plugin)
 {
-       const char *desc = "Define EOL or PLP circuitry failure mode.\n"\
+       const char *desc = "Define EOL or PLP circuitry failure mode.\n"
                           "No argument prints current mode.";
        const char *mode = "[0-3]: default/rom/wtm/normal";
        const char *save = "Specifies that the controller shall save the attribute";
@@ -902,7 +901,7 @@ static int get_telemetry_header(struct nvme_dev *dev, __u32 ns, __u8 tele_type,
 static void print_telemetry_header(struct telemetry_initiated_log *logheader,
                int tele_type)
 {
-       if (logheader != NULL) {
+       if (logheader) {
                unsigned int i = 0, j = 0;
 
                if (tele_type == TELEMETRY_TYPE_HOST)
@@ -944,7 +943,7 @@ static int extract_dump_get_log(struct nvme_dev *dev, char *featurename, char *f
        int total_loop_cnt = dumpsize / transfersize;
        int last_xfer_size = dumpsize % transfersize;
 
-       if (last_xfer_size != 0)
+       if (last_xfer_size)
                total_loop_cnt++;
        else
                last_xfer_size = transfersize;
@@ -983,7 +982,7 @@ static int extract_dump_get_log(struct nvme_dev *dev, char *featurename, char *f
                }
 
                if (i != total_loop_cnt - 1) {
-                       if (i == 0) {
+                       if (!i) {
                                output = open(filepath, O_WRONLY | O_CREAT | O_TRUNC, 0666);
                                if (output < 0) {
                                        err = -13;
@@ -1014,13 +1013,15 @@ end:
 }
 
 static int get_telemetry_dump(struct nvme_dev *dev, char *filename, char *sn,
-                               enum TELEMETRY_TYPE tele_type, int data_area, bool header_print)
+                             enum TELEMETRY_TYPE tele_type, int data_area, bool header_print)
 {
        __u32 err = 0, nsid = 0;
        __u8 lsp = 0, rae = 0;
-
-       char data[TELEMETRY_TRANSFER_SIZE] = {0,};
+       char data[TELEMETRY_TRANSFER_SIZE] = { 0 };
        char *featurename = 0;
+       struct telemetry_initiated_log *logheader = (struct telemetry_initiated_log *)data;
+       __u64 offset = 0, size = 0;
+       char dumpname[FILE_NAME_SIZE] = { 0 };
 
        if (tele_type == TELEMETRY_TYPE_HOST_0) {
                featurename = "Host(0)";
@@ -1043,13 +1044,9 @@ static int get_telemetry_dump(struct nvme_dev *dev, char *filename, char *sn,
        if (err)
                return err;
 
-       struct telemetry_initiated_log *logheader = (struct telemetry_initiated_log *)data;
-
        if (header_print)
                print_telemetry_header(logheader, tele_type);
 
-       __u64 offset = 0, size = 0;
-
        switch (data_area) {
        case 1:
                offset  = TELEMETRY_HEADER_SIZE;
@@ -1071,13 +1068,11 @@ static int get_telemetry_dump(struct nvme_dev *dev, char *filename, char *sn,
                break;
        }
 
-       if (size == 0) {
+       if (!size) {
                printf("Telemetry %s Area %d is empty.\n", featurename, data_area);
                return err;
        }
 
-       char dumpname[FILE_NAME_SIZE] = {0,};
-
        snprintf(dumpname, FILE_NAME_SIZE,
                                        "Telemetry_%s_Area_%d", featurename, data_area);
        err = extract_dump_get_log(dev, dumpname, filename, sn, size * TELEMETRY_BYTE_PER_BLOCK,
@@ -1142,9 +1137,8 @@ static int ocp_telemetry_log(int argc, char **argv, struct command *cmd,
        }
 
        err = nvme_identify_ctrl(dev_fd(dev), &ctrl);
-       if (err != 0) {
+       if (err)
                return err;
-       }
 
        get_serial_number(&ctrl, sn);
 
@@ -1166,13 +1160,11 @@ static int ocp_telemetry_log(int argc, char **argv, struct command *cmd,
                if ((tele_area != 1 && tele_area != 3) ||
                        (tele_type == TELEMETRY_TYPE_CONTROLLER && tele_area != 3)) {
                        printf("\nUnsupported parameters entered.\n");
-                       printf("Possible combinations; {'host0',1}, {'host0',3}, "
-                                       "{'host1',1}, {'host1',3}, {'controller',3}\n");
+                       printf("Possible combinations; {'host0',1}, {'host0',3}, {'host1',1}, {'host1',3}, {'controller',3}\n");
                        return err;
                }
        } else {
-               printf("\nShould provide these all; 'telemetry_type' "
-                               "and 'telemetry_data_area'\n");
+               printf("\nShould provide these all; 'telemetry_type' and 'telemetry_data_area'\n");
                return err;
        }
 
@@ -1183,7 +1175,7 @@ static int ocp_telemetry_log(int argc, char **argv, struct command *cmd,
 
                err = get_telemetry_dump(dev, cfg.file, sn,
                                TELEMETRY_TYPE_HOST_0, 1, true);
-               if (err != 0)
+               if (err)
                        fprintf(stderr, "NVMe Status: %s(%x)\n", nvme_status_to_string(err, false), err);
 
                printf("\n-------------------------------------------------------------\n");
@@ -1192,7 +1184,7 @@ static int ocp_telemetry_log(int argc, char **argv, struct command *cmd,
 
                err = get_telemetry_dump(dev, cfg.file, sn,
                                TELEMETRY_TYPE_HOST_0, 3, false);
-               if (err != 0)
+               if (err)
                        fprintf(stderr, "NVMe Status: %s(%x)\n", nvme_status_to_string(err, false), err);
 
                printf("\n-------------------------------------------------------------\n");
@@ -1201,7 +1193,7 @@ static int ocp_telemetry_log(int argc, char **argv, struct command *cmd,
 
                err = get_telemetry_dump(dev, cfg.file, sn,
                                TELEMETRY_TYPE_HOST_1, 1, true);
-               if (err != 0)
+               if (err)
                        fprintf(stderr, "NVMe Status: %s(%x)\n", nvme_status_to_string(err, false), err);
 
                printf("\n-------------------------------------------------------------\n");
@@ -1210,7 +1202,7 @@ static int ocp_telemetry_log(int argc, char **argv, struct command *cmd,
 
                err = get_telemetry_dump(dev, cfg.file, sn,
                                TELEMETRY_TYPE_HOST_1, 3, false);
-               if (err != 0)
+               if (err)
                        fprintf(stderr, "NVMe Status: %s(%x)\n", nvme_status_to_string(err, false), err);
 
                printf("\n-------------------------------------------------------------\n");
@@ -1220,7 +1212,7 @@ static int ocp_telemetry_log(int argc, char **argv, struct command *cmd,
                if (is_support_telemetry_controller == true) {
                        err = get_telemetry_dump(dev, cfg.file, sn,
                                        TELEMETRY_TYPE_CONTROLLER, 3, true);
-                       if (err != 0)
+                       if (err)
                                fprintf(stderr, "NVMe Status: %s(%x)\n", nvme_status_to_string(err, false), err);
                }
 
@@ -1230,7 +1222,7 @@ static int ocp_telemetry_log(int argc, char **argv, struct command *cmd,
 
                if (is_support_telemetry_controller == true) {
                        err = get_telemetry_dump(dev, cfg.file, sn, tele_type, tele_area, true);
-                       if (err != 0)
+                       if (err)
                                fprintf(stderr, "NVMe Status: %s(%x)\n", nvme_status_to_string(err, false), err);
                }
        } else {
@@ -1238,7 +1230,7 @@ static int ocp_telemetry_log(int argc, char **argv, struct command *cmd,
                                (tele_type == TELEMETRY_TYPE_HOST_0) ? 0 : 1, tele_area);
 
                err = get_telemetry_dump(dev, cfg.file, sn, tele_type, tele_area, true);
-               if (err != 0)
+               if (err)
                        fprintf(stderr, "NVMe Status: %s(%x)\n", nvme_status_to_string(err, false), err);
        }
 
@@ -1276,8 +1268,8 @@ static __u8 unsupported_req_guid[C5_GUID_LENGTH] = {
  * @log_page_version:         indicates the version of the mapping this log page uses.
  *                            Shall be set to 0001h
  * @log_page_guid:            Shall be set to C7BB98B7D0324863BB2C23990E9C722Fh.
-*/
-struct __attribute__((__packed__)) unsupported_requirement_log {
+ */
+struct __packed unsupported_requirement_log {
        __le16  unsupported_count;
        __u8    rsvd1[14];
        __u8    unsupported_req_list[C5_NUM_UNSUPPORTED_REQ_ENTRIES][16];
@@ -1286,7 +1278,7 @@ struct __attribute__((__packed__)) unsupported_requirement_log {
        __u8    log_page_guid[C5_GUID_LENGTH];
 };
 
-/*Function declaration for unsupported requirement log page(LID:C5h)*/
+/* Function declaration for unsupported requirement log page (LID:C5h) */
 static int ocp_unsupported_requirements_log(int argc, char **argv, struct command *cmd,
                                            struct plugin *plugin);
 
@@ -1294,19 +1286,18 @@ static int ocp_print_C5_log_normal(struct nvme_dev *dev,
                                   struct unsupported_requirement_log *log_data)
 {
        int j;
-       printf("Unsupported Requirement-C5 Log Page Data- \n");
 
-       printf("  Number Unsupported Req IDs            : 0x%x \n", le16_to_cpu(log_data->unsupported_count));
+       printf("Unsupported Requirement-C5 Log Page Data-\n");
 
-       for (j = 0; j < le16_to_cpu(log_data->unsupported_count); j++) {
-               printf("  Unsupported Requirement List %d       : %s \n", j, log_data->unsupported_req_list[j]);
-       }
+       printf("  Number Unsupported Req IDs            : 0x%x\n", le16_to_cpu(log_data->unsupported_count));
+
+       for (j = 0; j < le16_to_cpu(log_data->unsupported_count); j++)
+               printf("  Unsupported Requirement List %d       : %s\n", j, log_data->unsupported_req_list[j]);
 
-       printf("  Log Page Version                      : 0x%x \n", le16_to_cpu(log_data->log_page_version));
+       printf("  Log Page Version                      : 0x%x\n", le16_to_cpu(log_data->log_page_version));
        printf("  Log page GUID                         : 0x");
-       for (j = C5_GUID_LENGTH - 1; j >= 0; j--) {
+       for (j = C5_GUID_LENGTH - 1; j >= 0; j--)
                printf("%x", log_data->log_page_guid[j]);
-       }
        printf("\n");
 
        return 0;
@@ -1316,11 +1307,14 @@ static void ocp_print_C5_log_json(struct unsupported_requirement_log *log_data)
 {
        int j;
        struct json_object *root;
+       char unsup_req_list_str[40];
+       char guid_buf[C5_GUID_LENGTH];
+       char *guid = guid_buf;
+
        root = json_create_object();
 
        json_object_add_value_int(root, "Number Unsupported Req IDs", le16_to_cpu(log_data->unsupported_count));
 
-       char unsup_req_list_str[40];
        memset((void *)unsup_req_list_str, 0, 40);
        for (j = 0; j < le16_to_cpu(log_data->unsupported_count); j++) {
                sprintf((char *)unsup_req_list_str, "Unsupported Requirement List %d", j);
@@ -1328,8 +1322,7 @@ static void ocp_print_C5_log_json(struct unsupported_requirement_log *log_data)
        }
 
        json_object_add_value_int(root, "Log Page Version", le16_to_cpu(log_data->log_page_version));
-       char guid_buf[C5_GUID_LENGTH];
-       char *guid = guid_buf;
+
        memset((void *)guid, 0, C5_GUID_LENGTH);
        for (j = C5_GUID_LENGTH - 1; j >= 0; j--)
                guid += sprintf(guid, "%02x", log_data->log_page_guid[j]);
@@ -1353,6 +1346,7 @@ static int get_c5_log_page(struct nvme_dev *dev, char *format)
        __u8 *data;
        int i;
        struct unsupported_requirement_log *log_data;
+       int j;
 
        fmt = validate_output_format(format);
        if (fmt < 0) {
@@ -1386,7 +1380,6 @@ static int get_c5_log_page(struct nvme_dev *dev, char *format)
                for (i = 0; i < 16; i++) {
                        if (unsupported_req_guid[i] != log_data->log_page_guid[i]) {
                                fprintf(stderr, "ERROR : OCP : Unknown GUID in C5 Log Page data\n");
-                               int j;
                                fprintf(stderr, "ERROR : OCP : Expected GUID: 0x");
                                for (j = 0; j < 16; j++)
                                        fprintf(stderr, "%x", unsupported_req_guid[j]);
@@ -1472,23 +1465,23 @@ static __u8 error_recovery_guid[C1_GUID_LENGTH] = {
 
 /**
  * struct ocp_error_recovery_log_page -        Error Recovery Log Page
- * @panic_reset_wait_time:                             Panic Reset Wait Time
- * @panic_reset_action:                        Panic Reset Action
- * @device_recover_action_1:                   Device Recovery Action 1
- * @panic_id:                                  Panic ID
- * @device_capabilities:                               Device Capabilities
- * @vendor_specific_recovery_opcode:           Vendor Specific Recovery Opcode
- * @reserved:                                  Reserved
- * @vendor_specific_command_cdw12:             Vendor Specific Command CDW12
- * @vendor_specific_command_cdw13:             Vendor Specific Command CDW13
+ * @panic_reset_wait_time:             Panic Reset Wait Time
+ * @panic_reset_action:                        Panic Reset Action
+ * @device_recover_action_1:           Device Recovery Action 1
+ * @panic_id:                          Panic ID
+ * @device_capabilities:               Device Capabilities
+ * @vendor_specific_recovery_opcode:   Vendor Specific Recovery Opcode
+ * @reserved:                          Reserved
+ * @vendor_specific_command_cdw12:     Vendor Specific Command CDW12
+ * @vendor_specific_command_cdw13:     Vendor Specific Command CDW13
  * @vendor_specific_command_timeout:   Vendor Specific Command Timeout
- * @device_recover_action_2:                   Device Recovery Action 2
+ * @device_recover_action_2:           Device Recovery Action 2
  * @device_recover_action_2_timeout:   Device Recovery Action 2 Timeout
- * @reserved2:                                 Reserved
- * @log_page_version:                          Log Page Version
- * @log_page_guid:                                     Log Page GUID
+ * @reserved2:                         Reserved
+ * @log_page_version:                  Log Page Version
+ * @log_page_guid:                     Log Page GUID
  */
-struct __attribute__((__packed__)) ocp_error_recovery_log_page {
+struct __packed ocp_error_recovery_log_page {
        __le16  panic_reset_wait_time;                   /* 2 bytes      - 0x00 - 0x01 */
        __u8    panic_reset_action;                      /* 1 byte       - 0x02 */
        __u8    device_recover_action_1;                 /* 1 byte       - 0x03 */
@@ -1515,29 +1508,30 @@ static int ocp_error_recovery_log(int argc, char **argv, struct command *cmd, st
 static void ocp_print_c1_log_normal(struct ocp_error_recovery_log_page *log_data)
 {
        int i;
-       printf("  Error Recovery/C1 Log Page Data \n");
-       printf("  Panic Reset Wait Time             : 0x%x \n", le16_to_cpu(log_data->panic_reset_wait_time));
-       printf("  Panic Reset Action                : 0x%x \n", log_data->panic_reset_action);
-       printf("  Device Recovery Action 1          : 0x%x \n", log_data->device_recover_action_1);
-       printf("  Panic ID                          : 0x%x \n", le32_to_cpu(log_data->panic_id));
-       printf("  Device Capabilities               : 0x%x \n", le32_to_cpu(log_data->device_capabilities));
-       printf("  Vendor Specific Recovery Opcode   : 0x%x \n", log_data->vendor_specific_recovery_opcode);
-       printf("  Vendor Specific Command CDW12     : 0x%x \n", le32_to_cpu(log_data->vendor_specific_command_cdw12));
-       printf("  Vendor Specific Command CDW13     : 0x%x \n", le32_to_cpu(log_data->vendor_specific_command_cdw13));
-       printf("  Vendor Specific Command Timeout   : 0x%x \n", log_data->vendor_specific_command_timeout);
-       printf("  Device Recovery Action 2          : 0x%x \n", log_data->device_recover_action_2);
-       printf("  Device Recovery Action 2 Timeout  : 0x%x \n", log_data->device_recover_action_2_timeout);
-       printf("  Log Page Version                  : 0x%x \n", le16_to_cpu(log_data->log_page_version));
+
+       printf("  Error Recovery/C1 Log Page Data\n");
+       printf("  Panic Reset Wait Time             : 0x%x\n", le16_to_cpu(log_data->panic_reset_wait_time));
+       printf("  Panic Reset Action                : 0x%x\n", log_data->panic_reset_action);
+       printf("  Device Recovery Action 1          : 0x%x\n", log_data->device_recover_action_1);
+       printf("  Panic ID                          : 0x%x\n", le32_to_cpu(log_data->panic_id));
+       printf("  Device Capabilities               : 0x%x\n", le32_to_cpu(log_data->device_capabilities));
+       printf("  Vendor Specific Recovery Opcode   : 0x%x\n", log_data->vendor_specific_recovery_opcode);
+       printf("  Vendor Specific Command CDW12     : 0x%x\n", le32_to_cpu(log_data->vendor_specific_command_cdw12));
+       printf("  Vendor Specific Command CDW13     : 0x%x\n", le32_to_cpu(log_data->vendor_specific_command_cdw13));
+       printf("  Vendor Specific Command Timeout   : 0x%x\n", log_data->vendor_specific_command_timeout);
+       printf("  Device Recovery Action 2          : 0x%x\n", log_data->device_recover_action_2);
+       printf("  Device Recovery Action 2 Timeout  : 0x%x\n", log_data->device_recover_action_2_timeout);
+       printf("  Log Page Version                  : 0x%x\n", le16_to_cpu(log_data->log_page_version));
        printf("  Log page GUID                     : 0x");
-       for (i = C1_GUID_LENGTH - 1; i >= 0; i--) {
-                       printf("%x", log_data->log_page_guid[i]);
-       }
+       for (i = C1_GUID_LENGTH - 1; i >= 0; i--)
+               printf("%x", log_data->log_page_guid[i]);
        printf("\n");
 }
 
 static void ocp_print_c1_log_json(struct ocp_error_recovery_log_page *log_data)
 {
        struct json_object *root;
+
        root = json_create_object();
        char guid[64];
 
@@ -1566,7 +1560,7 @@ static void ocp_print_c1_log_json(struct ocp_error_recovery_log_page *log_data)
 
 static void ocp_print_c1_log_binary(struct ocp_error_recovery_log_page *log_data)
 {
-    return d_raw((unsigned char *)log_data, sizeof(*log_data));
+       return d_raw((unsigned char *)log_data, sizeof(*log_data));
 }
 
 static int get_c1_log_page(struct nvme_dev *dev, char *format)
@@ -1644,7 +1638,7 @@ out:
 
 static int ocp_error_recovery_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
 {
-    const char *desc = "Retrieve C1h Error Recovery Log data.";
+       const char *desc = "Retrieve C1h Error Recovery Log data.";
        struct nvme_dev *dev;
        int ret = 0;
 
@@ -1705,7 +1699,7 @@ static __u8 dev_cap_req_guid[C4_GUID_LENGTH] = {
  * @log_page_version:                                  Log Page Version
  * @log_page_guid:                                             Log Page GUID
  */
-struct __attribute__((__packed__)) ocp_device_capabilities_log_page {
+struct __packed ocp_device_capabilities_log_page {
        __le16  pcie_exp_port;
        __le16  oob_management_support;
        __le16  wz_cmd_support;
@@ -1729,32 +1723,30 @@ static int ocp_device_capabilities_log(int argc, char **argv, struct command *cm
 static void ocp_print_c4_log_normal(struct ocp_device_capabilities_log_page *log_data)
 {
        int i;
-       printf("  Device Capability/C4 Log Page Data \n");
-       printf("  PCI Express Ports                                             : 0x%x \n", le16_to_cpu(log_data->pcie_exp_port));
-       printf("  OOB Management Support                                : 0x%x \n", le16_to_cpu(log_data->oob_management_support));
-       printf("  Write Zeroes Command Support                  : 0x%x \n", le16_to_cpu(log_data->wz_cmd_support));
-       printf("  Sanitize Command Support                              : 0x%x \n", le16_to_cpu(log_data->sanitize_cmd_support));
-       printf("  Dataset Management Command Support    : 0x%x \n", le16_to_cpu(log_data->dsm_cmd_support));
-       printf("  Write Uncorrectable Command Support   : 0x%x \n", le16_to_cpu(log_data->wu_cmd_support));
-       printf("  Fused Operation Support                               : 0x%x \n", le16_to_cpu(log_data->fused_operation_support));
-       printf("  Minimum Valid DSSD Power State                : 0x%x \n", le16_to_cpu(log_data->min_valid_dssd_pwr_state));
+
+       printf("  Device Capability/C4 Log Page Data\n");
+       printf("  PCI Express Ports                                             : 0x%x\n", le16_to_cpu(log_data->pcie_exp_port));
+       printf("  OOB Management Support                                : 0x%x\n", le16_to_cpu(log_data->oob_management_support));
+       printf("  Write Zeroes Command Support                  : 0x%x\n", le16_to_cpu(log_data->wz_cmd_support));
+       printf("  Sanitize Command Support                              : 0x%x\n", le16_to_cpu(log_data->sanitize_cmd_support));
+       printf("  Dataset Management Command Support    : 0x%x\n", le16_to_cpu(log_data->dsm_cmd_support));
+       printf("  Write Uncorrectable Command Support   : 0x%x\n", le16_to_cpu(log_data->wu_cmd_support));
+       printf("  Fused Operation Support                               : 0x%x\n", le16_to_cpu(log_data->fused_operation_support));
+       printf("  Minimum Valid DSSD Power State                : 0x%x\n", le16_to_cpu(log_data->min_valid_dssd_pwr_state));
        printf("  DSSD Power State Descriptors                                  : 0x");
-       for (i = 0; i <= 127; i++) {
+       for (i = 0; i <= 127; i++)
                printf("%x", log_data->dssd_pwr_state_desc[i]);
-       }
        printf("\n");
-       printf("  Log Page Version                                              : 0x%x \n", le16_to_cpu(log_data->log_page_version));
+       printf("  Log Page Version                                              : 0x%x\n", le16_to_cpu(log_data->log_page_version));
        printf("  Log page GUID                                                 : 0x");
-       for (i = C4_GUID_LENGTH - 1; i >= 0; i--) {
+       for (i = C4_GUID_LENGTH - 1; i >= 0; i--)
                printf("%x", log_data->log_page_guid[i]);
-       }
        printf("\n");
 }
 
 static void ocp_print_c4_log_json(struct ocp_device_capabilities_log_page *log_data)
 {
-       struct json_object *root;
-       root = json_create_object();
+       struct json_object *root = json_create_object();
        char guid[64];
        int i;
 
@@ -1766,9 +1758,8 @@ static void ocp_print_c4_log_json(struct ocp_device_capabilities_log_page *log_d
        json_object_add_value_int(root, "Write Uncorrectable Command Support", le16_to_cpu(log_data->wu_cmd_support));
        json_object_add_value_int(root, "Fused Operation Support", le16_to_cpu(log_data->fused_operation_support));
        json_object_add_value_int(root, "Minimum Valid DSSD Power State", le16_to_cpu(log_data->min_valid_dssd_pwr_state));
-       for (i = 0; i <= 127; i++) {
+       for (i = 0; i <= 127; i++)
                json_object_add_value_int(root, "DSSD Power State Descriptors", log_data->dssd_pwr_state_desc[i]);
-       }
        json_object_add_value_int(root, "Log Page Version", le16_to_cpu(log_data->log_page_version));
 
        memset((void *)guid, 0, 64);
@@ -1783,7 +1774,7 @@ static void ocp_print_c4_log_json(struct ocp_device_capabilities_log_page *log_d
 
 static void ocp_print_c4_log_binary(struct ocp_device_capabilities_log_page *log_data)
 {
-    return d_raw((unsigned char *)log_data, sizeof(*log_data));
+       return d_raw((unsigned char *)log_data, sizeof(*log_data));
 }
 
 static int get_c4_log_page(struct nvme_dev *dev, char *format)
@@ -1805,7 +1796,7 @@ static int get_c4_log_page(struct nvme_dev *dev, char *format)
                fprintf(stderr, "ERROR : OCP : malloc : %s\n", strerror(errno));
                return -1;
        }
-       memset(data, 0, sizeof (__u8) * C4_DEV_CAP_REQ_LEN);
+       memset(data, 0, sizeof(__u8) * C4_DEV_CAP_REQ_LEN);
 
        ret = nvme_get_log_simple(dev_fd(dev), C4_DEV_CAP_REQ_OPCODE, C4_DEV_CAP_REQ_LEN, data);
 
@@ -1861,7 +1852,7 @@ out:
 
 static int ocp_device_capabilities_log(int argc, char **argv, struct command *cmd, struct plugin *plugin)
 {
-    const char *desc = "Retrieve C4h Device Capabilities Log data.";
+       const char *desc = "Retrieve C4h Device Capabilities Log data.";
        struct nvme_dev *dev;
        int ret = 0;