]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
scaleflux: enable sfx-nvme.c build without json-c dependencies checking
authorTokunori Ikegami <ikegami.t@gmail.com>
Fri, 20 Dec 2024 17:10:28 +0000 (02:10 +0900)
committerDaniel Wagner <wagi@monom.org>
Fri, 3 Jan 2025 09:21:08 +0000 (10:21 +0100)
Only build json print codes with CONFIG_JSONC build option instead.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
plugins/meson.build
plugins/scaleflux/sfx-nvme.c
util/json.h

index c827c863149347437a7bbffdedb5d27e64e70305..3d2a56ca521cab6cdf02c81f52ebca76f94b46ea 100644 (file)
@@ -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',
index 13810b93f6ac1a863a371f0efd7e01c6b12c7d99..63e0e2e4d8bb78530cbe8d6cdeec7a3fd129651a 100644 (file)
@@ -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;
index 3dd5b528691c42a335461b85e1895debe06438f0..07dbfa44d5d11214ac17090015ff1845379523dc 100644 (file)
@@ -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 */