Re: [PATCH] phy: marvell: remove conflicting initializer

From: Arnd Bergmann
Date: Mon Jan 23 2017 - 11:11:16 EST


On Monday, January 23, 2017 4:19:41 PM CET Andrew Lunn wrote:
> On Mon, Jan 23, 2017 at 01:18:41PM +0100, Arnd Bergmann wrote:
> > 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.
> >
> > Fixes: 0b04680fdae4 ("phy: marvell: Add support for temperature sensor")
> > Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
>
> 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?
>
> Reviewed-by: Andrew Lunn <andrew@xxxxxxx>
>

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(-)