]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
drivers/block/nvme-core.c: fix build with gcc-4.4.4
authorAndrew Morton <akpm@linux-foundation.org>
Sat, 27 Jun 2015 18:20:34 +0000 (12:20 -0600)
committerChuck Anderson <chuck.anderson@oracle.com>
Wed, 6 Jul 2016 23:31:47 +0000 (16:31 -0700)
gcc-4.4.4 (and possibly other versions) fail the compile when initializers
are used with anonymous unions.  Work around this.

drivers/block/nvme-core.c: In function 'nvme_identify_ctrl':
drivers/block/nvme-core.c:1163: error: unknown field 'identify' specified in initializer
drivers/block/nvme-core.c:1163: warning: missing braces around initializer
drivers/block/nvme-core.c:1163: warning: (near initialization for 'c.<anonymous>')
drivers/block/nvme-core.c:1164: error: unknown field 'identify' specified in initializer
drivers/block/nvme-core.c:1164: warning: excess elements in struct initializer
drivers/block/nvme-core.c:1164: warning: (near initialization for 'c')
...

This patch has no effect on text size with gcc-4.8.2.

Fixes: d29ec8241c10eac ("nvme: submit internal commands through the block layer")
Cc: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@fb.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit e44ac588cd61c960226d61c379e2873a95544a51)

Orabug: 22620486
Signed-off-by: Jason Luo <zhangqing.luo@oracle.com>
drivers/block/nvme-core.c

index 2c8d41a3c843fbf9c2fa286a9925a98e8b4a86bc..e5c9321492ceffdc2d27154390e04c6f7f12bc63 100644 (file)
@@ -1175,12 +1175,13 @@ static int adapter_delete_sq(struct nvme_dev *dev, u16 sqid)
 
 int nvme_identify_ctrl(struct nvme_dev *dev, struct nvme_id_ctrl **id)
 {
-       struct nvme_command c = {
-               .identify.opcode = nvme_admin_identify,
-               .identify.cns = cpu_to_le32(1),
-       };
+       struct nvme_command c = { };
        int error;
 
+       /* gcc-4.4.4 (at least) has issues with initializers and anon unions */
+       c.identify.opcode = nvme_admin_identify;
+       c.identify.cns = cpu_to_le32(1);
+
        *id = kmalloc(sizeof(struct nvme_id_ctrl), GFP_KERNEL);
        if (!*id)
                return -ENOMEM;
@@ -1195,12 +1196,13 @@ int nvme_identify_ctrl(struct nvme_dev *dev, struct nvme_id_ctrl **id)
 int nvme_identify_ns(struct nvme_dev *dev, unsigned nsid,
                struct nvme_id_ns **id)
 {
-       struct nvme_command c = {
-               .identify.opcode = nvme_admin_identify,
-               .identify.nsid = cpu_to_le32(nsid),
-       };
+       struct nvme_command c = { };
        int error;
 
+       /* gcc-4.4.4 (at least) has issues with initializers and anon unions */
+       c.identify.opcode = nvme_admin_identify,
+       c.identify.nsid = cpu_to_le32(nsid),
+
        *id = kmalloc(sizeof(struct nvme_id_ns), GFP_KERNEL);
        if (!*id)
                return -ENOMEM;
@@ -1244,14 +1246,14 @@ int nvme_set_features(struct nvme_dev *dev, unsigned fid, unsigned dword11,
 
 int nvme_get_log_page(struct nvme_dev *dev, struct nvme_smart_log **log)
 {
-       struct nvme_command c = {
-               .common.opcode = nvme_admin_get_log_page,
-               .common.nsid = cpu_to_le32(0xFFFFFFFF),
-               .common.cdw10[0] = cpu_to_le32(
+       struct nvme_command c = { };
+       int error;
+
+       c.common.opcode = nvme_admin_get_log_page,
+       c.common.nsid = cpu_to_le32(0xFFFFFFFF),
+       c.common.cdw10[0] = cpu_to_le32(
                        (((sizeof(struct nvme_smart_log) / 4) - 1) << 16) |
                         NVME_LOG_SMART),
-       };
-       int error;
 
        *log = kmalloc(sizeof(struct nvme_smart_log), GFP_KERNEL);
        if (!*log)