Skip to content

Commit

Permalink
seagate: enable seagate-nvme.c build without json-c dependencies chec…
Browse files Browse the repository at this point in the history
…king

Only build json print codes with CONFIG_JSONC build option instead.

Signed-off-by: Tokunori Ikegami <[email protected]>
  • Loading branch information
ikegami-t committed Dec 21, 2024
1 parent e8c68ca commit 8e00484
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plugins/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

if json_c_dep.found()
sources += [
'plugins/seagate/seagate-nvme.c',
'plugins/solidigm/solidigm-nvme.c',
'plugins/ssstc/ssstc-nvme.c',
'plugins/wdc/wdc-nvme.c',
Expand All @@ -27,6 +26,7 @@ sources += [
'plugins/netapp/netapp-nvme.c',
'plugins/nvidia/nvidia-nvme.c',
'plugins/scaleflux/sfx-nvme.c',
'plugins/seagate/seagate-nvme.c',
'plugins/shannon/shannon-nvme.c',
'plugins/toshiba/toshiba-nvme.c',
'plugins/transcend/transcend-nvme.c',
Expand Down
12 changes: 9 additions & 3 deletions plugins/seagate/seagate-nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -1386,6 +1386,7 @@ static int stx_vs_fw_activate_history(int argc, char **argv, struct command *cmd
const char *desc = "Retrieve FW Activate History for Seagate device ";
const char *output_format = "output in binary format";
int err;
nvme_print_flags_t flags;
struct config {
char *output_format;
};
Expand All @@ -1405,16 +1406,21 @@ static int stx_vs_fw_activate_history(int argc, char **argv, struct command *cmd
return -1;
}

if (strcmp(cfg.output_format, "json"))
err = validate_output_format(cfg.output_format, &flags);
if (err < 0) {
nvme_show_error("Invalid output format");
return err;
}

if (flags & NORMAL)
printf("Seagate FW Activation History Information :\n");

err = nvme_get_log_simple(dev_fd(dev), 0xC2, sizeof(fwActivHis), &fwActivHis);
if (!err) {
if (strcmp(cfg.output_format, "json"))
if (flags & NORMAL)
print_stx_vs_fw_activate_history(fwActivHis);
else
json_stx_vs_fw_activate_history(fwActivHis);

} else if (err > 0) {
nvme_show_status(err);
}
Expand Down
7 changes: 5 additions & 2 deletions util/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@ 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)
#define json_object_add_value_int(o, k, v)
#define json_print_object(o, u)
#define json_object_add_value_int(o, k, v) ((void)(v))
#define json_object_add_value_double(o, k, v)
#define json_object_add_value_array(o, k, v) ((void)(v))
#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))
#endif /* CONFIG_JSONC */
#endif /* __JSON__H */

0 comments on commit 8e00484

Please sign in to comment.