]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-cli: Restore support for older gcc versions
authorBart Van Assche <bvanassche@acm.org>
Mon, 24 Jun 2019 17:41:37 +0000 (10:41 -0700)
committerBart Van Assche <bvanassche@acm.org>
Mon, 24 Jun 2019 18:27:11 +0000 (11:27 -0700)
Older versions of gcc do not support initializing another than the first
member of a union in an initializer. Rewrite some code such that support
for older gcc versions is restored.

Fixes: 301e263c34e8 ("nvme-cli: Rework the code for getting and setting NVMf properties")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
nvme-ioctl.c

index 57fae22e1e37e8f9905999aef58d988cb9ca15a3..524502bf4bedf9214bc7d8ba71602983364d1b9c 100644 (file)
@@ -576,16 +576,16 @@ static void nvme_to_passthru_cmd(struct nvme_passthru_cmd *pcmd,
 int nvme_get_property(int fd, int offset, uint64_t *value)
 {
        struct nvme_passthru_cmd pcmd;
-       struct nvme_command gcmd = {
-               .prop_get = {
-                       .opcode = nvme_fabrics_command,
-                       .fctype = nvme_fabrics_type_property_get,
-                       .offset = cpu_to_le32(offset),
-                       .attrib = is_64bit_reg(offset),
-               }
+       struct nvmf_property_get_command pg = {
+               .opcode = nvme_fabrics_command,
+               .fctype = nvme_fabrics_type_property_get,
+               .offset = cpu_to_le32(offset),
+               .attrib = is_64bit_reg(offset),
        };
+       struct nvme_command gcmd;
        int err;
 
+       gcmd.prop_get = pg;
        nvme_to_passthru_cmd(&pcmd, &gcmd);
        err = nvme_submit_admin_passthru(fd, &pcmd);
        if (!err) {
@@ -635,17 +635,17 @@ int nvme_get_properties(int fd, void **pbar)
 
 int nvme_set_property(int fd, int offset, uint64_t value)
 {
-       struct nvme_command scmd = {
-               .prop_set = {
-                       .opcode = nvme_fabrics_command,
-                       .fctype = nvme_fabrics_type_property_set,
-                       .offset = cpu_to_le32(offset),
-                       .value = cpu_to_le64(value),
-                       .attrib = is_64bit_reg(offset),
-               }
+       struct nvmf_property_set_command ps = {
+               .opcode = nvme_fabrics_command,
+               .fctype = nvme_fabrics_type_property_set,
+               .offset = cpu_to_le32(offset),
+               .value = cpu_to_le64(value),
+               .attrib = is_64bit_reg(offset),
        };
+       struct nvme_command scmd;
        struct nvme_passthru_cmd pcmd;
 
+       scmd.prop_set = ps;
        nvme_to_passthru_cmd(&pcmd, &scmd);
        return nvme_submit_admin_passthru(fd, &pcmd);
 }