[PATCH 2/2] nvme-cli: support to set the property for NVMe over Fabric

Minwoo Im minwoo.im.dev at gmail.com
Mon Dec 4 07:27:34 PST 2017


Hello Guan,

> +int nvme_set_property(int fd, int offset, int value)
> +{
> +       __le64 val = cpu_to_le64(value);
> +       __le32 off = cpu_to_le32(offset);
> +       bool is64bit = false;
                               ^^^^^^^
Local variable __is64bit__ will be set a bit later in a switch statement.
Initialization seems unnecessary for this local variable.

> +static int set_property(int argc, char **argv, struct command *cmd, struct plugin *plugin)
> +{
> +       const char *desc = "Writes and shows the defined NVMe controller property "\
> +                          "for NVMe ove Fabric";
> +       const char *offset = "the offset of the property";
> +       const char *value = "the value of the property to be set";
> +       int fd, err;
> +
> +       struct config {
> +               int offset;
> +               int value;
> +       };
> +
> +       struct config cfg = {
> +               .offset = -1,
> +               .value = -1,
> +       };
> +
> +       const struct argconfig_commandline_options command_line_options[] = {
> +               {"offset", 'o', "NUM", CFG_POSITIVE, &cfg.offset, required_argument, offset},
> +               {"value", 'v', "NUM", CFG_POSITIVE, &cfg.value, required_argument, value},
> +               {NULL}
> +       };
> +
> +       fd = parse_and_open(argc, argv, desc, command_line_options, &cfg, sizeof(cfg));
> +       if (fd < 0)
> +               return fd;
> +
> +       if (cfg.offset == -1) {
> +               fprintf(stderr, "offset required param");
> +               return EINVAL;
> +       }
> +       if (cfg.value == -1) {
> +               fprintf(stderr, "value required param");
> +               return EINVAL;
> +       }
> +
> +       err = nvme_set_property(fd, cfg.offset, cfg.value);
> +       if (err < 0) {
> +               perror("set-property");
> +               return errno;
                               ^^^^^
__errno__ can be found nowhere in this scope. __err__?

Thanks,



More information about the Linux-nvme mailing list