Commit 3fcbb7d4 authored by Nathan Chancellor's avatar Nathan Chancellor Committed by Greg Kroah-Hartman

staging: kpc2000: Use memset to initialize resources

Clang warns:

drivers/staging/kpc2000/kpc2000/cell_probe.c:96:38: warning: suggest
braces around initialization of subobject [-Wmissing-braces]
    struct resource  resources[2] = {0};
                                     ^
                                     {}
drivers/staging/kpc2000/kpc2000/cell_probe.c:314:38: warning: suggest
braces around initialization of subobject [-Wmissing-braces]
    struct resource  resources[2] = {0};
                                     ^
                                     {}
2 warnings generated.

One way to fix these warnings is to add additional braces like Clang
suggests; however, there has been a bit of push back from some
maintainers, who just prefer memset as it is unambiguous, doesn't
depend on a particular compiler version, and properly initializes all
subobjects [1][2]. Do that here so there are no more warnings.

[1]: https://lore.kernel.org/lkml/022e41c0-8465-dc7a-a45c-64187ecd9684@amd.com/
[2]: https://lore.kernel.org/lkml/20181128.215241.702406654469517539.davem@davemloft.net/

Link: https://github.com/ClangBuiltLinux/linux/issues/455Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bf402c08
...@@ -93,8 +93,8 @@ void parse_core_table_entry(struct core_table_entry *cte, const u64 read_val, co ...@@ -93,8 +93,8 @@ void parse_core_table_entry(struct core_table_entry *cte, const u64 read_val, co
int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, char *name, const struct core_table_entry cte) int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, char *name, const struct core_table_entry cte)
{ {
struct mfd_cell cell = {0}; struct mfd_cell cell = {0};
struct resource resources[2] = {0}; struct resource resources[2];
struct kpc_core_device_platdata core_pdata = { struct kpc_core_device_platdata core_pdata = {
.card_id = pcard->card_id, .card_id = pcard->card_id,
.build_version = pcard->build_version, .build_version = pcard->build_version,
...@@ -112,6 +112,8 @@ int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, char * ...@@ -112,6 +112,8 @@ int probe_core_basic(unsigned int core_num, struct kp2000_device *pcard, char *
cell.id = core_num; cell.id = core_num;
cell.num_resources = 2; cell.num_resources = 2;
memset(&resources, 0, sizeof(resources));
resources[0].start = cte.offset; resources[0].start = cte.offset;
resources[0].end = cte.offset + (cte.length - 1); resources[0].end = cte.offset + (cte.length - 1);
resources[0].flags = IORESOURCE_MEM; resources[0].flags = IORESOURCE_MEM;
...@@ -311,8 +313,8 @@ int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, char *na ...@@ -311,8 +313,8 @@ int probe_core_uio(unsigned int core_num, struct kp2000_device *pcard, char *na
static int create_dma_engine_core(struct kp2000_device *pcard, size_t engine_regs_offset, int engine_num, int irq_num) static int create_dma_engine_core(struct kp2000_device *pcard, size_t engine_regs_offset, int engine_num, int irq_num)
{ {
struct mfd_cell cell = {0}; struct mfd_cell cell = {0};
struct resource resources[2] = {0}; struct resource resources[2];
dev_dbg(&pcard->pdev->dev, "create_dma_core(pcard = [%p], engine_regs_offset = %zx, engine_num = %d)\n", pcard, engine_regs_offset, engine_num); dev_dbg(&pcard->pdev->dev, "create_dma_core(pcard = [%p], engine_regs_offset = %zx, engine_num = %d)\n", pcard, engine_regs_offset, engine_num);
cell.platform_data = NULL; cell.platform_data = NULL;
...@@ -321,6 +323,8 @@ static int create_dma_engine_core(struct kp2000_device *pcard, size_t engine_re ...@@ -321,6 +323,8 @@ static int create_dma_engine_core(struct kp2000_device *pcard, size_t engine_re
cell.name = KP_DRIVER_NAME_DMA_CONTROLLER; cell.name = KP_DRIVER_NAME_DMA_CONTROLLER;
cell.num_resources = 2; cell.num_resources = 2;
memset(&resources, 0, sizeof(resources));
resources[0].start = engine_regs_offset; resources[0].start = engine_regs_offset;
resources[0].end = engine_regs_offset + (KPC_DMA_ENGINE_SIZE - 1); resources[0].end = engine_regs_offset + (KPC_DMA_ENGINE_SIZE - 1);
resources[0].flags = IORESOURCE_MEM; resources[0].flags = IORESOURCE_MEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment