Skip to content

Commit

Permalink
intel: avoid sprinkling ifdefs
Browse files Browse the repository at this point in the history
Use empty json functions instead without json.

Signed-off-by: Tokunori Ikegami <[email protected]>
  • Loading branch information
ikegami-t committed Dec 21, 2024
1 parent 68a8b96 commit f1bf376
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
12 changes: 0 additions & 12 deletions plugins/intel/intel-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ static int id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *pl
return __id_ctrl(argc, argv, cmd, plugin, intel_id_ctrl);
}

#ifdef CONFIG_JSONC
static void show_intel_smart_log_jsn(struct nvme_additional_smart_log *smart,
unsigned int nsid, const char *devname)
{
Expand Down Expand Up @@ -261,9 +260,6 @@ static void show_intel_smart_log_jsn(struct nvme_additional_smart_log *smart,
json_print_object(root, NULL);
json_free_object(root);
}
#else /* CONFIG_JSONC */
#define show_intel_smart_log_jsn(smart, nsid, devname)
#endif /* CONFIG_JSONC */

static char *id_to_key(__u8 id)
{
Expand Down Expand Up @@ -693,7 +689,6 @@ static int lat_stats_log_scale(int i)
* "type" : "write" or "read",
* "values" : {
*/
#ifdef CONFIG_JSONC
static void lat_stats_make_json_root(
struct json_object *root, struct json_object *bucket_list,
int write)
Expand Down Expand Up @@ -825,7 +820,6 @@ static void json_lat_stats_4_0(struct intel_lat_stats *stats,
json_print_object(root, NULL);
json_free_object(root);
}
#endif /* CONFIG_JSONC */

static void show_lat_stats_3_0(struct intel_lat_stats *stats)
{
Expand Down Expand Up @@ -856,7 +850,6 @@ static void show_lat_stats_4_0(struct intel_lat_stats *stats)
}
}

#ifdef CONFIG_JSONC
static void json_lat_stats_v1000_0(struct optane_lat_stats *stats, int write)
{
int i;
Expand Down Expand Up @@ -905,7 +898,6 @@ static void json_lat_stats_v1000_0(struct optane_lat_stats *stats, int write)
json_free_object(root);

}
#endif /* CONFIG_JSONC */

static void show_lat_stats_v1000_0(struct optane_lat_stats *stats, int write)
{
Expand Down Expand Up @@ -939,7 +931,6 @@ static void show_lat_stats_v1000_0(struct optane_lat_stats *stats, int write)

}

#ifdef CONFIG_JSONC
static void json_lat_stats(int write)
{
switch (media_version[MEDIA_MAJOR_IDX]) {
Expand Down Expand Up @@ -980,9 +971,6 @@ static void json_lat_stats(int write)
}
printf("\n");
}
#else /* CONFIG_JSONC */
#define json_lat_stats(write)
#endif /* CONFIG_JSONC */

static void print_dash_separator(int count)
{
Expand Down
5 changes: 3 additions & 2 deletions util/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/* Wrappers around json-c's API */

#define json_create_object(o) json_object_new_object(o)
#define json_create_array(a) json_object_new_array(a)
#define json_free_object(o) json_object_put(o)
#define json_free_array(a) json_object_put(a)
#define json_object_add_value_uint(o, k, v) \
Expand Down Expand Up @@ -56,7 +55,6 @@ struct json_object;

#define json_object_add_value_string(o, k, v)
#define json_create_object(o) NULL
#define json_create_array(a) NULL
#define json_free_object(o) ((void)(o))
#define json_object_add_value_uint(o, k, v) ((void)(v))
#define json_object_add_value_int(o, k, v) ((void)(v))
Expand All @@ -67,6 +65,9 @@ struct json_object;
#define json_object_add_value_object(o, k, v) ((void)(v))
#define json_array_add_value_object(o, k) ((void)(k))
#define json_print_object(o, u) ((void)(o))
#define json_object_new_array(a) NULL
#define json_object_array_add(o, k) ((void)(k))
#endif /* CONFIG_JSONC */
#define json_create_array(a) json_object_new_array(a)

#endif /* __JSON__H */

0 comments on commit f1bf376

Please sign in to comment.