]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
amzn: avoid sprinkling ifdefs and use flags
authorTokunori Ikegami <ikegami.t@gmail.com>
Fri, 20 Dec 2024 14:51:11 +0000 (23:51 +0900)
committerDaniel Wagner <wagi@monom.org>
Fri, 20 Dec 2024 16:52:06 +0000 (17:52 +0100)
Use flags instead of cfg.output_format.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
plugins/amzn/amzn-nvme.c

index bba1cda130ffb1781d3365928737d30e1c8c2350..983c31bcbef7f3587f2878397c38cea9d84afa8e 100644 (file)
 #define AMZN_NVME_STATS_LOGPAGE_ID 0xD0
 #define AMZN_NVME_STATS_MAGIC 0x3C23B510
 
-#ifdef CONFIG_JSONC
 #define array_add_obj json_array_add_value_object
 #define obj_add_array json_object_add_value_array
 #define obj_add_obj json_object_add_value_object
 #define obj_add_uint json_object_add_value_uint
 #define obj_add_uint64 json_object_add_value_uint64
-#endif /* CONFIG_JSONC */
 
 struct nvme_vu_id_ctrl_field {
        __u8                    bdev[32];
@@ -169,6 +167,8 @@ static void amzn_print_json_stats(struct amzn_latency_log_page *log)
 
        json_free_object(root);
 }
+#else /* CONFIG_JSONC */
+#define amzn_print_json_stats(log)
 #endif /* CONFIG_JSONC */
 
 static void amzn_print_normal_stats(struct amzn_latency_log_page *log)
@@ -266,11 +266,9 @@ static int get_stats(int argc, char **argv, struct command *cmd,
                return err;
        }
 
-#ifdef CONFIG_JSONC
-       if (!strcmp(cfg.output_format, "json"))
+       if (flags & JSON)
                amzn_print_json_stats(&log);
        else
-#endif /* CONFIG_JSONC */
                amzn_print_normal_stats(&log);
 
        return 0;