]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
plugins/solidigm: Use struct json_object instead of typedef
authorDaniel Wagner <dwagner@suse.de>
Mon, 6 Feb 2023 17:35:46 +0000 (18:35 +0100)
committerDaniel Wagner <dwagner@suse.de>
Fri, 10 Feb 2023 15:32:16 +0000 (16:32 +0100)
It strongly preferred to use explicit types and avoid typedefs.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
plugins/solidigm/solidigm-telemetry.c
plugins/solidigm/solidigm-telemetry/cod.c
plugins/solidigm/solidigm-telemetry/config.c
plugins/solidigm/solidigm-telemetry/config.h
plugins/solidigm/solidigm-telemetry/data-area.c
plugins/solidigm/solidigm-telemetry/header.c
plugins/solidigm/solidigm-telemetry/telemetry-log.h

index 84a4e2a018a047e807c60cf85fa841030415694e..9946991d748740e686751c41aafedaac6f18261e 100644 (file)
@@ -121,7 +121,7 @@ int solidigm_get_telemetry_log(int argc, char **argv, struct command *cmd, struc
                                cfg.cfg_file, strerror(err));
                        goto close_fd;
                }
-               json_tokener * jstok = json_tokener_new();
+               struct json_tokener * jstok = json_tokener_new();
 
                tl.configuration = json_tokener_parse_ex(jstok, conf_str, length);
                if (jstok->err != json_tokener_success) {
index be5685bd481d37aedcfaf54adce1c21eacc430ea..7accc5384c6418d304b34b73580b396a250966fc 100644 (file)
@@ -110,9 +110,9 @@ void solidigm_telemetry_log_cod_parse(struct telemetry_log *tl)
 
                UNKNOWN = 0xFF,
        };
-       json_object *telemetry_header = NULL;
-       json_object *COD_offset = NULL;
-       json_object *reason_id = NULL;
+       struct json_object *telemetry_header = NULL;
+       struct json_object *COD_offset = NULL;
+       struct json_object *reason_id = NULL;
 
        if (!json_object_object_get_ex(tl->root, "telemetryHeader", &telemetry_header))
                return;
@@ -144,7 +144,7 @@ void solidigm_telemetry_log_cod_parse(struct telemetry_log *tl)
                return;
        }
 
-       json_object *cod = json_create_object();
+       struct json_object *cod = json_create_object();
        json_object_object_add(tl->root, "cod", cod);
 
        for (int i =0 ; i < data->header.EntryCount; i++) {
index 781d78692daaff220bee84bf425c17dd82ab0a13..5111703123f6861d30c6a8a51ffd21004168e3ef 100644 (file)
 // max 16 bit unsigned integer nummber 65535
 #define MAX_16BIT_NUM_AS_STRING_SIZE  6
 
-static bool config_get_by_version(const json_object *obj, int version_major,
-                                 int version_minor, json_object **value)
+static bool config_get_by_version(const struct json_object *obj, int version_major,
+                                 int version_minor, struct json_object **value)
 {
        char str_key[MAX_16BIT_NUM_AS_STRING_SIZE];
        char str_subkey[MAX_16BIT_NUM_AS_STRING_SIZE];
 
        snprintf(str_key, sizeof(str_key), "%d", version_major);
        snprintf(str_subkey, sizeof(str_subkey), "%d", version_minor);
-       json_object *major_obj = NULL;
+       struct json_object *major_obj = NULL;
 
        if (!json_object_object_get_ex(obj, str_key, &major_obj))
                return false;
@@ -28,11 +28,11 @@ static bool config_get_by_version(const json_object *obj, int version_major,
        return value != NULL;
 }
 
-bool solidigm_config_get_by_token_version(const json_object *obj, int token_id,
+bool solidigm_config_get_by_token_version(const struct json_object *obj, int token_id,
                                          int version_major, int version_minor,
-                                         json_object **value)
+                                         struct json_object **value)
 {
-       json_object *token_obj = NULL;
+       struct json_object *token_obj = NULL;
        char str_key[MAX_16BIT_NUM_AS_STRING_SIZE];
 
        snprintf(str_key, sizeof(str_key), "%d", token_id);
index bea84fb0972781a6d5bd0318dfa705c11b83833a..30e61ffb9cc8c6fb91d6c6766b3f1f1744f63722 100644 (file)
@@ -7,4 +7,7 @@
 #include <stdbool.h>
 #include "util/json.h"
 
-bool solidigm_config_get_by_token_version(const json_object *obj, int key, int subkey, int subsubkey, json_object **value);
+bool solidigm_config_get_by_token_version(const struct json_object *obj,
+                                         int key, int subkey,
+                                         int subsubkey,
+                                         struct json_object **value);
index 7233e8f10ab9478ed20d5795cb47ea626dedda3d..526b9ce555efed53af96dfea61e05dfff894beff 100644 (file)
@@ -17,7 +17,7 @@
 
 static bool telemetry_log_get_value(const struct telemetry_log *tl,
                                    uint32_t offset_bit, uint32_t size_bit,
-                                   bool is_signed, json_object **val_obj)
+                                   bool is_signed, struct json_object **val_obj)
 {
        uint32_t offset_bit_from_byte;
        uint32_t additional_size_byte;
@@ -77,16 +77,16 @@ static bool telemetry_log_get_value(const struct telemetry_log *tl,
 }
 
 static int telemetry_log_structure_parse(const struct telemetry_log *tl,
-                                        json_object *struct_def,
+                                        struct json_object *struct_def,
                                         size_t parent_offset_bit,
-                                        json_object *output,
-                                        json_object *metadata)
+                                        struct json_object *output,
+                                        struct json_object *metadata)
 {
-       json_object *obj_arraySizeArray = NULL;
-       json_object *obj = NULL;
-       json_object *obj_memberList;
-       json_object *major_dimension;
-       json_object *sub_output;
+       struct json_object *obj_arraySizeArray = NULL;
+       struct json_object *obj = NULL;
+       struct json_object *obj_memberList;
+       struct json_object *major_dimension;
+       struct json_object *sub_output;
        bool is_enumeration = false;
        bool has_member_list;
        const char *type = "";
@@ -155,7 +155,7 @@ static int telemetry_log_structure_parse(const struct telemetry_log *tl,
        uint32_t array_size_dimension[array_rank];
 
        for (size_t i = 0; i < array_rank; i++) {
-               json_object *dimension = json_object_array_get_idx(obj_arraySizeArray, i);
+               struct json_object *dimension = json_object_array_get_idx(obj_arraySizeArray, i);
 
                array_size_dimension[i] = json_object_get_uint64(dimension);
                major_dimension = dimension;
@@ -163,7 +163,7 @@ static int telemetry_log_structure_parse(const struct telemetry_log *tl,
        if (array_rank > 1) {
                uint32_t linear_pos_per_index = array_size_dimension[0];
                uint32_t prev_index_offset_bit = 0;
-               json_object *dimension_output;
+               struct json_object *dimension_output;
 
                for (int i = 1; i < (array_rank - 1); i++)
                        linear_pos_per_index *= array_size_dimension[i];
@@ -182,7 +182,7 @@ static int telemetry_log_structure_parse(const struct telemetry_log *tl,
                json_object_array_del_idx(obj_arraySizeArray, array_rank - 1, 1);
 
                for (int i = 0 ; i < array_size_dimension[0]; i++) {
-                       json_object *sub_array = json_create_array();
+                       struct json_object *sub_array = json_create_array();
                        size_t offset;
 
                        offset = parent_offset_bit + prev_index_offset_bit;
@@ -213,7 +213,7 @@ static int telemetry_log_structure_parse(const struct telemetry_log *tl,
        for (uint32_t j = 0; j < array_size_dimension[0]; j++) {
                if (is_enumeration || !has_member_list) {
                        bool is_signed = !strncmp(type, SIGNED_INT_PREFIX, sizeof(SIGNED_INT_PREFIX)-1);
-                       json_object *val_obj;
+                       struct json_object *val_obj;
                        size_t offset;
 
                        offset = parent_offset_bit + offset_bit + linear_array_pos_bit;
@@ -230,7 +230,7 @@ static int telemetry_log_structure_parse(const struct telemetry_log *tl,
                                json_free_object(val_obj);
                        }
                } else {
-                       json_object *sub_sub_output = json_object_new_object();
+                       struct json_object *sub_sub_output = json_object_new_object();
                        int num_members;
 
                        if (array_size_dimension[0] > 1)
@@ -240,7 +240,7 @@ static int telemetry_log_structure_parse(const struct telemetry_log *tl,
 
                        num_members = json_object_array_length(obj_memberList);
                        for (int k = 0; k < num_members; k++) {
-                               json_object *member = json_object_array_get_idx(obj_memberList, k);
+                               struct json_object *member = json_object_array_get_idx(obj_memberList, k);
                                size_t offset;
 
                                offset = parent_offset_bit + offset_bit + linear_array_pos_bit;
@@ -322,8 +322,8 @@ struct telemetry_object_header {
 
 static void telemetry_log_data_area_toc_parse(const struct telemetry_log *tl,
                                              enum nvme_telemetry_da da,
-                                             json_object *toc_array,
-                                             json_object *tele_obj_array)
+                                             struct json_object *toc_array,
+                                             struct json_object *tele_obj_array)
 {
 
        const struct telemetry_object_header *header;
@@ -339,8 +339,8 @@ static void telemetry_log_data_area_toc_parse(const struct telemetry_log *tl,
        payload = (char *) tl->log;
 
        for (int i = 0; i < toc->header.TableOfContentsCount; i++) {
-               json_object *structure_definition = NULL;
-               json_object *toc_item;
+               struct json_object *structure_definition = NULL;
+               struct json_object *toc_item;
                uint32_t obj_offset;
                bool has_struct;
 
@@ -379,15 +379,15 @@ static void telemetry_log_data_area_toc_parse(const struct telemetry_log *tl,
                                                                  &structure_definition);
 
                if (has_struct) {
-                       json_object *tele_obj_item = json_create_object();
+                       struct json_object *tele_obj_item = json_create_object();
 
                        json_object_array_add(tele_obj_array, tele_obj_item);
                        json_object_get(toc_item);
                        json_object_add_value_object(tele_obj_item, "metadata", toc_item);
-                       json_object *parsed_struct = json_object_new_object();
+                       struct json_object *parsed_struct = json_object_new_object();
 
                        json_object_add_value_object(tele_obj_item, "objectData", parsed_struct);
-                       json_object *obj_hasTelemObjHdr = NULL;
+                       struct json_object *obj_hasTelemObjHdr = NULL;
                        uint32_t header_offset = sizeof(const struct telemetry_object_header);
                        uint32_t file_offset;
 
@@ -411,8 +411,8 @@ static void telemetry_log_data_area_toc_parse(const struct telemetry_log *tl,
 int solidigm_telemetry_log_data_areas_parse(const struct telemetry_log *tl,
                                            enum nvme_telemetry_da last_da)
 {
-       json_object *tele_obj_array = json_create_array();
-       json_object *toc_array = json_create_array();
+       struct json_object *tele_obj_array = json_create_array();
+       struct json_object *toc_array = json_create_array();
 
        json_object_add_value_array(tl->root, "tableOfContents", toc_array);
        json_object_add_value_array(tl->root, "telemetryObjects", tele_obj_array);
index 72b2d974b6f02b9cea956530a07b969b5dc01c4c..d085c2462f17c4a3dae0bbbedd03d52f53d9cdfe 100644 (file)
@@ -63,10 +63,10 @@ static_assert(sizeof(const struct reason_indentifier_1_2) ==
 #pragma pack(pop, reason_indentifier)
 
 static void telemetry_log_reason_id_parse1_0_ext(const struct telemetry_log *tl,
-                                                json_object *reason_id)
+                                                struct json_object *reason_id)
 {
        const struct reason_indentifier_1_0 *ri;
-       json_object *reserved;
+       struct json_object *reserved;
 
        ri = (struct reason_indentifier_1_0 *) tl->log->rsnident;
        json_object_object_add(reason_id, "FirmwareVersion", json_object_new_string_len(ri->FirmwareVersion, sizeof(ri->FirmwareVersion)));
@@ -76,16 +76,16 @@ static void telemetry_log_reason_id_parse1_0_ext(const struct telemetry_log *tl,
        reserved = json_create_array();
        json_object_add_value_array(reason_id, "Reserved", reserved);
        for ( int i=0; i < sizeof(ri->Reserved); i++) {
-               json_object *val = json_object_new_int(ri->Reserved[i]);
+               struct json_object *val = json_object_new_int(ri->Reserved[i]);
                json_object_array_add(reserved, val);
        }
 }
 
 static void telemetry_log_reason_id_parse1_1_ext(const struct telemetry_log *tl,
-                                                json_object *reason_id)
+                                                struct json_object *reason_id)
 {
        const struct reason_indentifier_1_1 *ri;
-       json_object *reserved;
+       struct json_object *reserved;
 
        ri = (struct reason_indentifier_1_1 *) tl->log->rsnident;
        json_object_object_add(reason_id, "FirmwareVersion", json_object_new_string_len(ri->FirmwareVersion, sizeof(ri->FirmwareVersion)));
@@ -98,17 +98,17 @@ static void telemetry_log_reason_id_parse1_1_ext(const struct telemetry_log *tl,
        reserved = json_create_array();
        json_object_add_value_array(reason_id, "Reserved", reserved);
        for (int i = 0; i < sizeof(ri->Reserved); i++) {
-               json_object *val = json_object_new_int(ri->Reserved[i]);
+               struct json_object *val = json_object_new_int(ri->Reserved[i]);
                json_object_array_add(reserved, val);
        }
 }
 
 static void telemetry_log_reason_id_parse1_2_ext(const struct telemetry_log *tl,
-                                                json_object *reason_id)
+                                                struct json_object *reason_id)
 {
        const struct reason_indentifier_1_2 *ri;
-       json_object *dp_reserved;
-       json_object *reserved;
+       struct json_object *dp_reserved;
+       struct json_object *reserved;
 
        ri = (struct reason_indentifier_1_2 *) tl->log->rsnident;
 
@@ -121,19 +121,19 @@ static void telemetry_log_reason_id_parse1_2_ext(const struct telemetry_log *tl,
        reserved = json_create_array();
        json_object_add_value_array(reason_id, "Reserved2", reserved);
        for (int i = 0; i < sizeof(ri->Reserved2); i++) {
-               json_object *val = json_object_new_int(ri->Reserved2[i]);
+               struct json_object *val = json_object_new_int(ri->Reserved2[i]);
                json_object_array_add(reserved, val);
        }
 
        dp_reserved = json_create_array();
        json_object_add_value_array(reason_id, "DualPortReserved", dp_reserved);
        for (int i = 0; i < sizeof(ri->DualPortReserved); i++) {
-               json_object *val =  json_object_new_int(ri->DualPortReserved[i]);
+               struct json_object *val =  json_object_new_int(ri->DualPortReserved[i]);
                json_object_array_add(dp_reserved, val);
        }
 }
 
-static void solidigm_telemetry_log_reason_id_parse(const struct telemetry_log *tl, json_object *reason_id)
+static void solidigm_telemetry_log_reason_id_parse(const struct telemetry_log *tl, struct json_object *reason_id)
 {
        const struct reason_indentifier_1_0 *ri1_0 =
                (struct reason_indentifier_1_0 *) tl->log->rsnident;
@@ -161,9 +161,9 @@ static void solidigm_telemetry_log_reason_id_parse(const struct telemetry_log *t
 bool solidigm_telemetry_log_header_parse(const struct telemetry_log *tl)
 {
        const struct nvme_telemetry_log *log;
-       json_object *ieee_oui_id;
-       json_object *reason_id;
-       json_object *header;
+       struct json_object *ieee_oui_id;
+       struct json_object *reason_id;
+       struct json_object *header;
 
        if (tl->log_size < sizeof(const struct nvme_telemetry_log)) {
                SOLIDIGM_LOG_WARNING("Telemetry log too short.");
@@ -180,7 +180,7 @@ bool solidigm_telemetry_log_header_parse(const struct telemetry_log *tl)
 
        json_object_object_add(header, "ieeeOuiIdentifier", ieee_oui_id);
        for (int i = 0; i < sizeof(log->ieee); i++) {
-               json_object *val = json_object_new_int(log->ieee[i]);
+               struct json_object *val = json_object_new_int(log->ieee[i]);
 
                json_object_array_add(ieee_oui_id, val);
        }
index ef4ec5da61f1175b4a3fa46bfab6055d612799b3..e9eff7340d094e09aad84c35f3f5377a878e24b0 100644 (file)
@@ -24,8 +24,8 @@
 struct telemetry_log {
        struct nvme_telemetry_log *log;
        size_t log_size;
-       json_object *root;
-       json_object *configuration;
+       struct json_object *root;
+       struct json_object *configuration;
 };
 
-#endif /* _SOLIDIGM_TELEMETRY_LOG_H */
\ No newline at end of file
+#endif /* _SOLIDIGM_TELEMETRY_LOG_H */