From: Tokunori Ikegami Date: Fri, 20 Dec 2024 17:10:28 +0000 (+0900) Subject: scaleflux: enable sfx-nvme.c build without json-c dependencies checking X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=91c080770c3511e2f6f66bc18637ba60e7103434;p=users%2Fsagi%2Fnvme-cli.git scaleflux: enable sfx-nvme.c build without json-c dependencies checking Only build json print codes with CONFIG_JSONC build option instead. Signed-off-by: Tokunori Ikegami --- diff --git a/plugins/meson.build b/plugins/meson.build index c827c863..3d2a56ca 100644 --- a/plugins/meson.build +++ b/plugins/meson.build @@ -2,7 +2,6 @@ if json_c_dep.found() sources += [ - 'plugins/scaleflux/sfx-nvme.c', 'plugins/seagate/seagate-nvme.c', 'plugins/solidigm/solidigm-nvme.c', 'plugins/ssstc/ssstc-nvme.c', @@ -27,6 +26,7 @@ sources += [ 'plugins/nbft/nbft-plugin.c', 'plugins/netapp/netapp-nvme.c', 'plugins/nvidia/nvidia-nvme.c', + 'plugins/scaleflux/sfx-nvme.c', 'plugins/shannon/shannon-nvme.c', 'plugins/toshiba/toshiba-nvme.c', 'plugins/transcend/transcend-nvme.c', diff --git a/plugins/scaleflux/sfx-nvme.c b/plugins/scaleflux/sfx-nvme.c index 13810b93..63e0e2e4 100644 --- a/plugins/scaleflux/sfx-nvme.c +++ b/plugins/scaleflux/sfx-nvme.c @@ -101,6 +101,7 @@ int nvme_sfx_get_features(int fd, __u32 nsid, __u32 fid, __u32 *result) return err; } +#ifdef CONFIG_JSONC static void show_sfx_smart_log_jsn(struct nvme_additional_smart_log *smart, unsigned int nsid, const char *devname) { @@ -239,6 +240,9 @@ static void show_sfx_smart_log_jsn(struct nvme_additional_smart_log *smart, printf("\n"); json_free_object(root); } +#else /* CONFIG_JSONC */ +#define show_sfx_smart_log_jsn(smart, nsid, devname) +#endif /* CONFIG_JSONC */ static void show_sfx_smart_log(struct nvme_additional_smart_log *smart, unsigned int nsid, const char *devname) @@ -328,7 +332,9 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd, "Get ScaleFlux vendor specific additional smart log (optionally, for the specified namespace), and show it."; const char *namespace = "(optional) desired namespace"; const char *raw = "dump output in binary format"; +#ifdef CONFIG_JSONC const char *json = "Dump output in json format"; +#endif /* CONFIG_JSONC */ struct nvme_dev *dev; struct config { __u32 namespace_id; @@ -348,7 +354,6 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd, OPT_END() }; - err = parse_and_open(&dev, argc, argv, desc, opts); if (err) return err; diff --git a/util/json.h b/util/json.h index 3dd5b528..07dbfa44 100644 --- a/util/json.h +++ b/util/json.h @@ -51,13 +51,16 @@ struct json_object *util_json_object_new_uint128(nvme_uint128_t val); struct json_object *util_json_object_new_uint128(nvme_uint128_t val); uint64_t util_json_object_get_uint64(struct json_object *obj); - -#else /* !CONFIG_JSONC */ - +#else /* CONFIG_JSONC */ struct json_object; #define json_object_add_value_string(o, k, v) - -#endif - -#endif +#define json_create_object(o) NULL +#define json_free_object(o) ((void)(o)) +#define json_object_add_value_uint(o, k, v) +#define json_object_add_value_int(o, k, v) +#define json_print_object(o, u) +#define json_object_add_value_double(o, k, v) +#define json_object_add_value_object(o, k, v) ((void)(v)) +#endif /* CONFIG_JSONC */ +#endif /* __JSON__H */