phy: marvell: remove conflicting initializer
Subsystems (21)
PATCH 1/1 phy: marvell: remove conflicting initializer
One line was apparently pasted incorrectly during a new feature patch:
drivers/net/phy/marvell.c:2090:15: error: initialized field overwritten [-Werror=override-init]
.features = PHY_GBIT_FEATURES,
I'm removing the extraneous line here to avoid the W=1 warning and restore the previous flags value, and I'm slightly reordering the lines for consistency to make it less likely to happen again in the future. The ordering in the array is still not the same as in the structure definition, instead I picked the order that is most common in this file and that seems to make more sense here.
--- drivers/net/phy/marvell.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/net/phy/marvell.c +6 -7
@@ -1900,8 +1900,8 @@ static struct phy_driver marvell_drivers[] = { .phy_id_mask = MARVELL_PHY_ID_MASK, .name = "Marvell 88E1101", .features = PHY_GBIT_FEATURES, - .probe = marvell_probe, .flags = PHY_HAS_INTERRUPT, + .probe = marvell_probe, .config_init = &marvell_config_init, .config_aneg = &marvell_config_aneg, .read_status = &genphy_read_status,
@@ -1971,10 +1971,10 @@ static struct phy_driver marvell_drivers[] = { .phy_id = MARVELL_PHY_ID_88E1121R, .phy_id_mask = MARVELL_PHY_ID_MASK, .name = "Marvell 88E1121R", - .probe = &m88e1121_probe, - .remove = &marvell_remove, .features = PHY_GBIT_FEATURES, .flags = PHY_HAS_INTERRUPT, + .probe = &m88e1121_probe, + .remove = &marvell_remove, .config_init = &m88e1121_config_init, .config_aneg = &m88e1121_config_aneg, .read_status = &marvell_read_status,
@@ -2085,10 +2085,9 @@ static struct phy_driver marvell_drivers[] = { .phy_id_mask = MARVELL_PHY_ID_MASK, .name = "Marvell 88E1510", .features = PHY_GBIT_FEATURES | SUPPORTED_FIBRE, + .flags = PHY_HAS_INTERRUPT, .probe = &m88e1510_probe, .remove = &marvell_remove, - .features = PHY_GBIT_FEATURES, - .flags = PHY_HAS_INTERRUPT, .config_init = &m88e1510_config_init, .config_aneg = &m88e1510_config_aneg, .read_status = &marvell_read_status,
@@ -2105,10 +2104,10 @@ static struct phy_driver marvell_drivers[] = { .phy_id = MARVELL_PHY_ID_88E1540, .phy_id_mask = MARVELL_PHY_ID_MASK, .name = "Marvell 88E1540", - .probe = m88e1510_probe, - .remove = &marvell_remove, .features = PHY_GBIT_FEATURES, .flags = PHY_HAS_INTERRUPT, + .probe = m88e1510_probe, + .remove = &marvell_remove, .config_init = &marvell_config_init, .config_aneg = &m88e1510_config_aneg, .read_status = &marvell_read_status,
Signature · 1 line
2.9.0
Quoted 12 lines · Arnd Bergmann
One line was apparently pasted incorrectly during a new feature patch:
drivers/net/phy/marvell.c:2090:15: error: initialized field overwritten [-Werror=override-init]
.features =PHY_GBIT_FEATURES,I'm removing the extraneous line here to avoid the W=1 warning and restore the previous flags value, and I'm slightly reordering the lines for consistency to make it less likely to happen again in the future. The ordering in the array is still not the same as in the structure definition, instead I picked the order that is most common in this file and that seems to make more sense here.
Quoted 2 lines
Fixes 0b04680fdae4 ("phy: marvell: Add support for temperature sensor")Signed-off-by Arnd Bergmann <[email protected]>
Hi Arnd
Thanks for this. I found one bug in my code while testing due to duplicate probe initialisation. I was surprised at the time the compiler did not warn me. I didn't think to try W=1. Is there any legitimate need to allow multiple initialisation of a field? Can this warning be made always on instead of only W=1?
Andrew
Quoted 18 lines · CET Andrew Lunn
Quoted 12 lines · Arnd Bergmann
One line was apparently pasted incorrectly during a new feature patch:
drivers/net/phy/marvell.c:2090:15: error: initialized field overwritten [-Werror=override-init]
.features =PHY_GBIT_FEATURES,I'm removing the extraneous line here to avoid the W=1 warning and restore the previous flags value, and I'm slightly reordering the lines for consistency to make it less likely to happen again in the future. The ordering in the array is still not the same as in the structure definition, instead I picked the order that is most common in this file and that seems to make more sense here.
Quoted 2 lines
Fixes 0b04680fdae4 ("phy: marvell: Add support for temperature sensor")Signed-off-by Arnd Bergmann <[email protected]>Hi Arnd
Quoted 8 lines
Thanks for this. I found one bug in my code while testing due to duplicate probe initialisation. I was surprised at the time the compiler did not warn me. I didn't think to try W=1. Is there any legitimate need to allow multiple initialisation of a field? Can this warning be made always on instead of only W=1?
Reviewed-by Andrew Lunn <[email protected]>
Great question! I have sent out patches for a couple of actual bugs that came from this warning in the past few months.
I still have a couple of patches that I have not sent out so far, I think they are all false-positives, and I have not found a good workaround for most of them other than disabling the warning locally.
Once we get the patches below (or some other workaround) into the kernel, we should definitely enable the warning by default.
Arnd
arch/arm64/kernel/sys.c | 1 + arch/arm64/kernel/sys32.c | 1 + arch/arm64/kernel/traps.c | 1 + arch/x86/kernel/cpu/common.c | 1 + drivers/block/drbd/drbd_main.c | 7 +++---- drivers/gpu/drm/gma500/Makefile | 1 + drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/omapdrm/omap_fbdev.c | 3 +++ drivers/net/ethernet/qlogic/qede/qede_dcbnl.c | 1 - drivers/net/ethernet/renesas/sh_eth.c | 1 + fs/proc/task_mmu.c | 2 ++ include/linux/libata.h | 1 + include/linux/perf/arm_pmu.h | 1 + kernel/bpf/core.c | 2 ++ net/wimax/stack.c | 6 +++--- sound/usb/quirks-table.h | 3 ++- 17 files changed, 30 insertions(+), 16 deletions(-)
Quoted 1 line
From
b85020cd2c0da34c940b6a7d5d04a39e01fa3bf9Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Fri, 24 Jun 2016 15:04:14 +0200
Subject: [PATCH] arm64: turn off -Woverride-init false positives
arch/arm64/kernel/sys.c +1 -0
@@ -55,6 +55,7 @@ asmlinkage long sys_rt_sigreturn_wrapper(void);#undef __SYSCALL#define __SYSCALL (nr, sym) [nr] = sym, +#pragma GCC diagnostic ignored "-Woverride-init"/* * The sys_call_table array must be 4K aligned to be accessible from * kernel/entry.S.
arch/arm64/kernel/sys32.c +1 -0
@@ -42,6 +42,7 @@ asmlinkage long compat_sys_mmap2_wrapper(void);#undef __SYSCALL#define __SYSCALL (nr, sym) [nr] = sym, +#pragma GCC diagnostic ignored "-Woverride-init"/* * The sys_call_table array must be 4K aligned to be accessible from * kernel/entry.S.
arch/arm64/kernel/traps.c +1 -0
@@ -558,6 +558,7 @@ asmlinkage long do_ni_syscall(struct pt_regs *regs)return sys_ni_syscall (); } +#pragma GCC diagnostic ignored "-Woverride-init"static const char *esr_class_str[] = { [0 ... ESR_ELx_EC_MAX] ="UNRECOGNIZED EC" , [ESR_ELx_EC_UNKNOWN] ="Unknown/Uncategorized" ,
Quoted 1 line
From
975b03637d5362bbf99ad46d59dbf94b495cb78fMon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Tue, 3 Jan 2017 15:35:07 +0100
Subject: [PATCH] drm: fix override-init warnings
drivers/gpu/drm/gma500/Makefile +1 -0
@@ -2,6 +2,7 @@ # KMS driver for the GMA500 # ccflags-y += -I$(srctree)/include/drm +CFLAGS_framebuffer.o += $(call cc-disable-warning, override-init) gma500_gfx-y += \ accel_2d.o \
drivers/gpu/drm/i915/Makefile +1 -0
@@ -5,6 +5,7 @@ subdir-ccflags-$(CONFIG_DRM_I915_WERROR) := -Werror subdir-ccflags-y += \ $(call as-instr,movntdqa (%eax)$(comma)%xmm0,-DCONFIG_AS_MOVNTDQA) +subdir-ccflags-y += $(call cc-disable-warning, override-init) # Please keep these build lists sorted!
Quoted 1 line
From
af178eec23da3e549b7ac5360c213955059d9f16Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Tue, 15 Nov 2016 14:10:37 +0100
Subject: [PATCH] [HACK] drm: omapdrm: field override
../drivers/gpu/drm/omapdrm/omap_fbdev.c:96:20: error: initialized field overwritten [-Werror=override-init]
.fb_pan_display = omap_fbdev_pan_display,
^~~~~~~~~~~~~~~~~~~~~~
../drivers/gpu/drm/omapdrm/omap_fbdev.c:96:20: note: (near initialization for 'omap_fb_ops.fb_pan_display')
drivers/gpu/drm/omapdrm/omap_fbdev.c +3 -0
@@ -80,6 +80,8 @@ static int omap_fbdev_pan_display(struct fb_var_screeninfo *var,return drm_fb_helper_pan_display (var, fbi); } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Woverride-init"static struct fb_ops omap_fb_ops = { .owner =THIS_MODULE ,DRM_FB_HELPER_DEFAULT_OPS ,
@@ -95,6 +97,7 @@ static struct fb_ops omap_fb_ops = { .fb_pan_display = omap_fbdev_pan_display, }; +#pragma GCC diagnostic popstatic int omap_fbdev_create (struct drm_fb_helper *helper,struct drm_fb_helper_surface_size *sizes)
Quoted 1 line
From
a9c01cba0336e2907d78953226a5d985edcf1ee1Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Wed, 8 Jun 2016 13:44:51 +0200
Subject: [PATCH] procfs: disable -Woverride-init warning
This warning finds some actual bugs, but the usage in procfs is intended, so we get a false positive output many lines like:
fs/proc/task_mmu.c: In function 'show_smap_vma_flags':fs/proc/task_mmu.c:629:2403: error: initialized field overwritten [-Werror=override-init] fs/proc/task_mmu.c:629:2403: note: (near initialization for 'mnemonics[0]') fs/proc/task_mmu.c:630:2403: error: initialized field overwritten [-Werror=override-init] fs/proc/task_mmu.c:630:2403: note: (near initialization for 'mnemonics[1]') fs/proc/task_mmu.c:631:2403: error: initialized field overwritten [-Werror=override-init] fs/proc/task_mmu.c:631:2403: note: (near initialization for 'mnemonics[2]')
This uses a #pragma to turn off the warning, as a preparation for eventually enabling the gcc flag by default for the kernel.
fs/proc/task_mmu.c +2 -0
@@ -616,6 +616,7 @@ static int smaps_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end,return 0 ; } +#pragma GCC diagnostic ignored "-Woverride-init"static void show_smap_vma_flags (struct seq_file *m,struct vm_area_struct *vma) {/*
@@ -682,6 +683,7 @@ static void show_smap_vma_flags(struct seq_file *m, struct vm_area_struct *vma) }seq_putc (m,'\n' ); } +#pragma GCC diagnostic warning "-Woverride-init"#ifdef CONFIG_HUGETLB_PAGE static int smaps_hugetlb_range(pte_t *pte, unsigned long hmask,
Quoted 1 line
From
85cbf32994e826a9b3f4b0e6c481d85d77c7ad19Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Wed, 8 Jun 2016 13:08:55 +0200
Subject: [PATCH] sh_eth: disable -Woverride-init warning
-Woverride-init is part of a 'make W=1' build and it might be nice to enable it in normal builds as it catches real bugs, but it causes hundreds of identical false positive warnings in the sh_eth driver:
ethernet/renesas/sh_eth.c:63:11: error: initialized field overwritten [-Werror=override-init] ethernet/renesas/sh_eth.c:63:11: note: (near initialization for 'sh_eth_offset_gigabit[0]') ethernet/renesas/sh_eth.c:64:11: error: initialized field overwritten [-Werror=override-init] ethernet/renesas/sh_eth.c:64:11: note: (near initialization for 'sh_eth_offset_gigabit[1]') ethernet/renesas/sh_eth.c:65:12: error: initialized field overwritten [-Werror=override-init] ethernet/renesas/sh_eth.c:65:12: note: (near initialization for 'sh_eth_offset_gigabit[2]') ethernet/renesas/sh_eth.c:66:12: error: initialized field overwritten [-Werror=override-init] ethernet/renesas/sh_eth.c:66:12: note: (near initialization for 'sh_eth_offset_gigabit[3]') ethernet/renesas/sh_eth.c:67:11: error: initialized field overwritten [-Werror=override-init] ethernet/renesas/sh_eth.c:67:11: note: (near initialization for 'sh_eth_offset_gigabit[4]')
This turns off the particular warning for this file, overriding the C flags.
drivers/net/ethernet/renesas/sh_eth.c +1 -0
@@ -57,6 +57,7 @@#define SH_ETH_OFFSET_DEFAULTS \ [0 ... SH_ETH_MAX_REGISTER_OFFSET - 1] = SH_ETH_OFFSET_INVALID +#pragma GCC diagnostic ignored "-Woverride-init"static const u16 sh_eth_offset_gigabit[SH_ETH_MAX_REGISTER_OFFSET ] = {SH_ETH_OFFSET_DEFAULTS ,
Quoted 1 line
From
14e1d7313bb030decc1a7ac0618c4c95474fc116Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Wed, 8 Jun 2016 10:46:40 +0200
Subject: [PATCH] perf: arm-pmu: shut up -Woverride-init warning
gcc -Woverride-init provides useful warnings about bugs in some drivers, but it warns about an intentional duplicate inialization in the ARM pmu header:
arch/arm/kernel/perf_event_v7.c:159:31: error: initialized field overwritten [-Werror=override-init] arch/arm/kernel/perf_event_v7.c:159:31: note: (near initialization for 'armv7_a8_perf_map[0]') arch/arm/kernel/perf_event_v7.c:160:33: error: initialized field overwritten [-Werror=override-init] arch/arm/kernel/perf_event_v7.c:160:33: note: (near initialization for 'armv7_a8_perf_map[1]') arch/arm/kernel/perf_event_v7.c:161:37: error: initialized field overwritten [-Werror=override-init] arch/arm/kernel/perf_event_v7.c:161:37: note: (near initialization for 'armv7_a8_perf_map[2]') arch/arm/kernel/perf_event_v7.c:162:33: error: initialized field overwritten [-Werror=override-init] arch/arm/kernel/perf_event_v7.c:162:33: note: (near initialization for 'armv7_a8_perf_map[3]') arch/arm/kernel/perf_event_v7.c:163:40: error: initialized field overwritten [-Werror=override-init] arch/arm/kernel/perf_event_v7.c:163:40: note: (near initialization for 'armv7_a8_perf_map[4]')
...
This uses a #pragma to shut up that warning, as a preparation for enabling the warning by default in the future.
include/linux/perf/arm_pmu.h +1 -0
@@ -41,6 +41,7 @@ struct arm_pmu_platdata {#define C (_x) PERF_COUNT_HW_CACHE_##_x#define CACHE_OP_UNSUPPORTED 0xFFFF +#pragma GCC diagnostic ignored "-Woverride-init"#define PERF_MAP_ALL_UNSUPPORTED \ [0 ... PERF_COUNT_HW_MAX - 1] = HW_OP_UNSUPPORTED
Quoted 1 line
From
e2f45688890614c67fef699a8612283ad4c44b06Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Wed, 8 Jun 2016 10:46:40 +0200
Subject: [PATCH] bpf: shut up -Woverride-init warning
gcc -Woverride-init provides useful warnings about bugs in some drivers, but it warns about an intentional duplicate inialization in the bpf code:
kernel/bpf/core.c: In function '__bpf_prog_run':kernel/bpf/core.c:476:26: error: initialized field overwritten [-Werror=override-init] kernel/bpf/core.c:476:26: note: (near initialization for 'jumptable[12]') kernel/bpf/core.c:477:26: error: initialized field overwritten [-Werror=override-init] kernel/bpf/core.c:477:26: note: (near initialization for 'jumptable[4]') kernel/bpf/core.c:478:26: error: initialized field overwritten [-Werror=override-init] kernel/bpf/core.c:478:26: note: (near initialization for 'jumptable[28]') kernel/bpf/core.c:479:26: error: initialized field overwritten [-Werror=override-init] kernel/bpf/core.c:479:26: note: (near initialization for 'jumptable[20]') kernel/bpf/core.c:480:26: error: initialized field overwritten [-Werror=override-init] kernel/bpf/core.c:480:26: note: (near initialization for 'jumptable[92]') kernel/bpf/core.c:481:26: error: initialized field overwritten [-Werror=override-init]
This uses a #pragma to shut up that warning, as a preparation for enabling the warning by default in the future.
kernel/bpf/core.c +2 -0
@@ -547,6 +547,7 @@ EXPORT_SYMBOL_GPL(__bpf_call_base);* * Decode and execute eBPF instructions. */ +#pragma GCC diagnostic ignored "-Woverride-init"static unsigned int __bpf_prog_run (void *ctx,const struct bpf_insn *insn) {u64 stack[MAX_BPF_STACK /sizeof (u64)];
@@ -1003,6 +1004,7 @@ static unsigned int __bpf_prog_run(void *ctx, const struct bpf_insn *insn)WARN_RATELIMIT (1 ,"unknown opcode %02x\n" , insn->code);return 0 ; } +#pragma GCC diagnostic warning "-Woverride-init"STACK_FRAME_NON_STANDARD (__bpf_prog_run);/* jump table */ bool bpf_prog_array_compatible(struct bpf_array *array,
Quoted 1 line
From
092549ed4782679e220357a3990bb5087e7d277fMon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Wed, 8 Jun 2016 10:41:06 +0200
Subject: [PATCH] libata: shut up -Woverride-init warning
In general, the -Woverride-init is helpful to catch bugs with drivers that unintentially initialize the same field in a structure more than once. In case of libata, it conflicts with the intended use of the ATA_BASE_SHT() macro, causing warnings about code that works as designed:
drivers/ata/ahci.c:107:555: error: initialized field overwritten [-Werror=override-init] drivers/ata/ahci.c:107:685: error: initialized field overwritten [-Werror=override-init] drivers/ata/acard-ahci.c:86:567: error: initialized field overwritten [-Werror=override-init] drivers/ata/ahci_platform.c:37:555: error: initialized field overwritten [-Werror=override-init] drivers/ata/sata_sil24.c:388:15: error: initialized field overwritten [-Werror=override-init] drivers/ata/sata_highbank.c:456:573: error: initialized field overwritten [-Werror=override-init] drivers/ata/ahci_brcmstb.c:282:565: error: initialized field overwritten [-Werror=override-init] drivers/ata/ahci_ceva.c:162:565: error: initialized field overwritten [-Werror=override-init] drivers/ata/ahci_imx.c:526:563: error: initialized field overwritten [-Werror=override-init] drivers/ata/ahci_mvebu.c:98:567: error: initialized field overwritten [-Werror=override-init] drivers/ata/ahci_sunxi.c:175:567: error: initialized field overwritten [-Werror=override-init] drivers/ata/ahci_st.c:145:561: error: initialized field overwritten [-Werror=override-init] drivers/ata/ahci_tegra.c:295:567: error: initialized field overwritten [-Werror=override-init] drivers/ata/ahci_xgene.c:731:567: error: initialized field overwritten [-Werror=override-init] drivers/ata/ahci_qoriq.c:148:567: error: initialized field overwritten [-Werror=override-init] drivers/ata/sata_mv.c:683:15: error: initialized field overwritten [-Werror=override-init] drivers/ata/sata_nv.c:395:15: error: initialized field overwritten [-Werror=override-init] drivers/ata/sata_nv.c:398:21: error: initialized field overwritten [-Werror=override-init] drivers/ata/sata_nv.c:403:15: error: initialized field overwritten [-Werror=override-init] drivers/ata/sata_nv.c:406:21: error: initialized field overwritten [-Werror=override-init] drivers/ata/pata_atiixp.c:254:18: error: initialized field overwritten [-Werror=override-init] drivers/ata/pata_cs5520.c:107:18: error: initialized field overwritten [-Werror=override-init] drivers/ata/pata_sc1200.c:210:18: error: initialized field overwritten [-Werror=override-init] drivers/ata/pata_serverworks.c:256:18: error: initialized field overwritten [-Werror=override-init]
This adds a #pragma GCC diagnostic ignored "-Woverride-init" next to the definition to let gcc know that it shouldn't warn about duplicate initializers in files that include this header.
include/linux/libata.h +1 -0
@@ -1342,6 +1342,7 @@ extern struct device_attribute *ata_common_sdev_attrs[];* edge driver's module reference, otherwise the driver can be unloaded * even if the scsi_device is being accessed. */ +#pragma GCC diagnostic ignored "-Woverride-init"#define ATA_BASE_SHT (drv_name) \ .module = THIS_MODULE, \ .name = drv_name, \
Quoted 1 line
From
bafaf130a03ac21377fe7c142ad7ce7417ebcfe3Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Thu, 9 Jun 2016 23:20:58 +0200
Subject: [PATCH] qede: remove duplicate initializer
../drivers/net/ethernet/qlogic/qede/qede_dcbnl.c:327:13: error: initialized field overwritten [-Werror=override-init]
.getdcbx = qede_dcbnl_getdcbx,
^~~~~~~~~~~~~~~~~~
../drivers/net/ethernet/qlogic/qede/qede_dcbnl.c:327:13: note: (near initialization for 'qede_dcbnl_ops.getdcbx')
drivers/net/ethernet/qlogic/qede/qede_dcbnl.c +0 -1
@@ -308,7 +308,6 @@ static const struct dcbnl_rtnl_ops qede_dcbnl_ops = { .ieee_setets = qede_dcbnl_ieee_setets, .ieee_getapp = qede_dcbnl_ieee_getapp, .ieee_setapp = qede_dcbnl_ieee_setapp, - .getdcbx = qede_dcbnl_getdcbx, .ieee_peer_getpfc = qede_dcbnl_ieee_peer_getpfc, .ieee_peer_getets = qede_dcbnl_ieee_peer_getets, .getstate = qede_dcbnl_getstate,
Quoted 1 line
From
657078acc9b9e8abc17aa7eb2d93877194e085efMon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Wed, 8 Jun 2016 10:31:59 +0200
Subject: [PATCH] [RFC] wimax: remove duplicate entries in wimax_gnl_policy
gcc -Wextra warns about duplicate initializations here:
net/wimax/stack.c:408:29: error: initialized field overwritten [-Werror=override-init] net/wimax/stack.c:408:29: note: (near initialization for 'wimax_gnl_policy[1]') net/wimax/stack.c:412:28: error: initialized field overwritten [-Werror=override-init] net/wimax/stack.c:412:28: note: (near initialization for 'wimax_gnl_policy[1]') net/wimax/stack.c:413:26: error: initialized field overwritten [-Werror=override-init] net/wimax/stack.c:413:26: note: (near initialization for 'wimax_gnl_policy[1]')
This was introduced by b61a5eea5904 ("wimax: use genl_register_family_with_ops()"), which consolidated four existing genl_ops tables into one as a simplification.
I do not understand the reasoning behind that earlier patch, as it seems to apply the superset of the four policy to all commands. If it was indeed correct, we can either remove or comment out the duplicate entries as I do here.
It's also possible that we want a partial revert of the patch that introduced this, or a broader rework.
net/wimax/stack.c +3 -3
@@ -404,12 +404,12 @@ void wimax_dev_init(struct wimax_dev *wimax_dev)EXPORT_SYMBOL_GPL (wimax_dev_init);static const struct nla_policy wimax_gnl_policy[WIMAX_GNL_ATTR_MAX +1 ] = { - [WIMAX_GNL_RESET_IFIDX ] = { .type =NLA_U32 , }, - [WIMAX_GNL_RFKILL_IFIDX ] = { .type =NLA_U32 , }, +/* [WIMAX_GNL_RESET_IFIDX] = { .type = NLA_U32, }, */ +/* [WIMAX_GNL_RFKILL_IFIDX] = { .type = NLA_U32, }, */ [WIMAX_GNL_RFKILL_STATE ] = { .type =NLA_U32 /* enum wimax_rf_state */ }, - [WIMAX_GNL_STGET_IFIDX ] = { .type =NLA_U32 , }, +/* [WIMAX_GNL_STGET_IFIDX] = { .type = NLA_U32, }, */ [WIMAX_GNL_MSG_IFIDX ] = { .type =NLA_U32 , }, [WIMAX_GNL_MSG_DATA ] = { .type =NLA_UNSPEC ,/* libnl doesn't grok BINARY yet */
Quoted 1 line
From
ad1e6c0987c3e03fe9177d6f1a5aaeb9732f80f5Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Wed, 8 Jun 2016 10:23:51 +0200
Subject: [PATCH] drbd: sanitize cmdnames table
gcc -Wextra warns about a duplicate entry in cmdnames[]:
drivers/block/drbd/drbd_main.c: In function 'cmdname':drivers/block/drbd/drbd_main.c:3680:21: error: initialized field overwritten [-Werror=override-init] drivers/block/drbd/drbd_main.c:3680:21: note: (near initialization for 'cmdnames[44]')
Apparently, there are two entries for P_RETRY_WRITE, so I'm removing the one that ended up unused. I also checked the table to ensure that all other entries are there and sorted them by numeric value.
I see that there is no entry for P_TRIM, so I've added that but left it commented out. Please uncomment if that entry should be there.
drivers/block/drbd/drbd_main.c +3 -4
@@ -3719,7 +3719,6 @@ const char *cmdname(enum drbd_packet cmd)static const char *cmdnames[] = { [P_DATA ] ="Data" , [P_WSAME ] ="WriteSame" , - [P_TRIM ] ="Trim" , [P_DATA_REPLY ] ="DataReply" , [P_RS_DATA_REPLY ] ="RSDataReply" , [P_BARRIER ] ="Barrier" ,
@@ -3730,7 +3729,6 @@ const char *cmdname(enum drbd_packet cmd) [P_DATA_REQUEST] = "DataRequest", [P_RS_DATA_REQUEST] = "RSDataRequest", [P_SYNC_PARAM] = "SyncParam", - [P_SYNC_PARAM89] = "SyncParam89", [P_PROTOCOL] = "ReportProtocol", [P_UUIDS] = "ReportUUIDs", [P_SIZES] = "ReportSizes",
@@ -3738,6 +3736,7 @@ const char *cmdname(enum drbd_packet cmd) [P_SYNC_UUID] = "ReportSyncUUID", [P_AUTH_CHALLENGE] = "AuthChallenge", [P_AUTH_RESPONSE] = "AuthResponse", + [P_STATE_CHG_REQ] = "StateChgRequest", [P_PING] = "Ping", [P_PING_ACK] = "PingAck", [P_RECV_ACK] = "RecvAck",
@@ -3748,22 +3747,22 @@ const char *cmdname(enum drbd_packet cmd) [P_NEG_DREPLY] = "NegDReply", [P_NEG_RS_DREPLY] = "NegRSDReply", [P_BARRIER_ACK] = "BarrierAck", - [P_STATE_CHG_REQ] = "StateChgRequest", [P_STATE_CHG_REPLY] = "StateChgReply", [P_OV_REQUEST] = "OVRequest", [P_OV_REPLY] = "OVReply", [P_OV_RESULT] = "OVResult", [P_CSUM_RS_REQUEST] = "CsumRSRequest", [P_RS_IS_IN_SYNC] = "CsumRSIsInSync", + [P_SYNC_PARAM89] = "SyncParam89", [P_COMPRESSED_BITMAP] = "CBitmap", [P_DELAY_PROBE] = "DelayProbe", [P_OUT_OF_SYNC] = "OutOfSync", - [P_RETRY_WRITE] = "RetryWrite", [P_RS_CANCEL] = "RSCancel", [P_CONN_ST_CHG_REQ] = "conn_st_chg_req", [P_CONN_ST_CHG_REPLY] = "conn_st_chg_reply", [P_RETRY_WRITE] = "retry_write", [P_PROTOCOL_UPDATE] = "protocol_update", + [P_TRIM] = "Trim", [P_RS_THIN_REQ] = "rs_thin_req", [P_RS_DEALLOCATED] = "rs_deallocated",
Quoted 1 line
From
860d00e7a5220f9bc44bf8d6529c04dbb8856451Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Wed, 15 Jun 2016 09:10:07 +0200
Subject: [PATCH] x86: don't warn about duplicate initializion of stack sizes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
arch/x86/include/asm/page_64_types.h:18:21: error: initialized field overwritten [-Werror=override-init]
#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)
^arch/x86/kernel/cpu/common.c:1304:26: note: in expansion of macro ‘DEBUG_STKSZ’
[DEBUG_STACK - 1] = DEBUG_STKSZ
^arch/x86/include/asm/page_64_types.h:18:21: note: (near initialization for ‘exception_stack_sizes[2]’)
#define DEBUG_STKSZ (PAGE_SIZE << DEBUG_STACK_ORDER)
^arch/x86/kernel/cpu/common.c:1304:26: note: in expansion of macro ‘DEBUG_STKSZ’
[DEBUG_STACK - 1] = DEBUG_STKSZ
arch/x86/kernel/cpu/common.c +1 -0
@@ -1268,6 +1268,7 @@ EXPORT_PER_CPU_SYMBOL(__preempt_count);* limit), all of them are 4K, except the debug stack which * is 8K. */ +#pragma GCC diagnostic ignored "-Woverride-init"static const unsigned int exception_stack_sizes[N_EXCEPTION_STACKS ] = { [0 ...N_EXCEPTION_STACKS -1 ] =EXCEPTION_STKSZ , [DEBUG_STACK -1 ] =DEBUG_STKSZ
Quoted 1 line
From
01fc760fe7fbee1163f4a0c25cd722014054de70Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Wed, 8 Jun 2016 10:22:51 +0200
Subject: [PATCH] alsa: usb: avoid duplicate initializers in quirks table
sound/usb/quirks-table.h:2892:125: error: initialized field overwritten [-Werror=override-init] sound/usb/quirks-table.h:2892:125: note: (near initialization for 'usb_audio_ids[230].match_flags') sound/usb/quirks-table.h:2892:181: error: initialized field overwritten [-Werror=override-init] sound/usb/quirks-table.h:2892:181: note: (near initialization for 'usb_audio_ids[230].bInterfaceClass') sound/usb/quirks-table.h:2893:125: error: initialized field overwritten [-Werror=override-init] sound/usb/quirks-table.h:2893:125: note: (near initialization for 'usb_audio_ids[231].match_flags') sound/usb/quirks-table.h:2893:181: error: initialized field overwritten [-Werror=override-init] sound/usb/quirks-table.h:2893:181: note: (near initialization for 'usb_audio_ids[231].bInterfaceClass') sound/usb/quirks-table.h:2894:125: error: initialized field overwritten [-Werror=override-init] sound/usb/quirks-table.h:2894:125: note: (near initialization for 'usb_audio_ids[232].match_flags') sound/usb/quirks-table.h:2894:181: error: initialized field overwritten [-Werror=override-init]
sound/usb/quirks-table.h +2 -1
@@ -2875,10 +2875,11 @@ YAMAHA_DEVICE(0x7010, "UB99"),*/ #define AU0828_DEVICE (vid, pid, vname, pname) { \ - USB_DEVICE_VENDOR_SPEC(vid, pid), \ .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ USB_DEVICE_ID_MATCH_INT_CLASS | \ USB_DEVICE_ID_MATCH_INT_SUBCLASS, \ + .idVendor = vid, \ + .idProduct = pid, \ .bInterfaceClass = USB_CLASS_AUDIO, \ .bInterfaceSubClass = USB_SUBCLASS_AUDIOCONTROL, \ .driver_info = (unsigned long) &(const struct snd_usb_audio_quirk) { \
Andrew Lunn
maintainerQuoted 9 lines
Great question! I have sent out patches for a couple of actual bugs that came from this warning in the past few months.
I still have a couple of patches that I have not sent out so far, I think they are all false-positives, and I have not found a good workaround for most of them other than disabling the warning locally.
Once we get the patches below (or some other workaround) into the kernel, we should definitely enable the warning by default.
So it looks like some are from initialising a range of values with a default value:
[0 ... SH_ETH_MAX_REGISTER_OFFSET - 1] = SH_ETH_OFFSET_INVALID
and then some entries specific values. Maybe the compiler can help out here? A different warning in this case? And have that at W=1? Could you ask the gcc folks about this?
Others causes seem like
226 #define DRM_FB_HELPER_DEFAULT_OPS \
227 .fb_check_var = drm_fb_helper_check_var, \ 228 .fb_set_par = drm_fb_helper_set_par, \ 229 .fb_setcmap = drm_fb_helper_setcmap, \ 230 .fb_blank = drm_fb_helper_blank, \ 231 .fb_pan_display = drm_fb_helper_pan_display
static struct fb_ops omap_fb_ops = {
.owner = THIS_MODULE,
DRM_FB_HELPER_DEFAULT_OPS,
...
.fb_pan_display = omap_fbdev_pan_display,
There are at least three drivers which need to replace the default fb_pan_display. So maybe a different macro?
Andrew
From: Arnd Bergmann <[email protected]>
Date: Mon, 23 Jan 2017 13:18:41 +0100
Quoted 12 lines
One line was apparently pasted incorrectly during a new feature patch:
drivers/net/phy/marvell.c:2090:15: error: initialized field overwritten [-Werror=override-init]
.features =PHY_GBIT_FEATURES,I'm removing the extraneous line here to avoid the W=1 warning and restore the previous flags value, and I'm slightly reordering the lines for consistency to make it less likely to happen again in the future. The ordering in the array is still not the same as in the structure definition, instead I picked the order that is most common in this file and that seems to make more sense here.
Quoted 2 lines
Fixes 0b04680fdae4 ("phy: marvell: Add support for temperature sensor")Signed-off-by Arnd Bergmann <[email protected]>
Applied, thanks Arnd.
Please start putting appropriate "net" and "net-next" strings in your PATCH subject lines, it will save me a lot of time.