Message ID | 20240403080702.3509288-1-arnd@kernel.org |
---|---|
Headers | show |
Series | address all -Wunused-const warnings | expand |
On 4/3/24 17:06, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > Building with W=1 shows a warning for an unused variable when CONFIG_PCI > is diabled: s/diabled/disabled > drivers/ata/sata_mv.c:790:35: error: unused variable 'mv_pci_tbl' [-Werror,-Wunused-const-variable] > static const struct pci_device_id mv_pci_tbl[] = { > > Move the table into the same block that containsn the pci_driver > definition. s/containsn/contains But no need to resend, I will fix that when applying. Thanks ! > > Fixes: 7bb3c5290ca0 ("sata_mv: Remove PCI dependency") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > drivers/ata/sata_mv.c | 64 +++++++++++++++++++++---------------------- > 1 file changed, 32 insertions(+), 32 deletions(-) > > diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c > index e82786c63fbd..697063890f5d 100644 > --- a/drivers/ata/sata_mv.c > +++ b/drivers/ata/sata_mv.c > @@ -787,37 +787,6 @@ static const struct ata_port_info mv_port_info[] = { > }, > }; > > -static const struct pci_device_id mv_pci_tbl[] = { > - { PCI_VDEVICE(MARVELL, 0x5040), chip_504x }, > - { PCI_VDEVICE(MARVELL, 0x5041), chip_504x }, > - { PCI_VDEVICE(MARVELL, 0x5080), chip_5080 }, > - { PCI_VDEVICE(MARVELL, 0x5081), chip_508x }, > - /* RocketRAID 1720/174x have different identifiers */ > - { PCI_VDEVICE(TTI, 0x1720), chip_6042 }, > - { PCI_VDEVICE(TTI, 0x1740), chip_6042 }, > - { PCI_VDEVICE(TTI, 0x1742), chip_6042 }, > - > - { PCI_VDEVICE(MARVELL, 0x6040), chip_604x }, > - { PCI_VDEVICE(MARVELL, 0x6041), chip_604x }, > - { PCI_VDEVICE(MARVELL, 0x6042), chip_6042 }, > - { PCI_VDEVICE(MARVELL, 0x6080), chip_608x }, > - { PCI_VDEVICE(MARVELL, 0x6081), chip_608x }, > - > - { PCI_VDEVICE(ADAPTEC2, 0x0241), chip_604x }, > - > - /* Adaptec 1430SA */ > - { PCI_VDEVICE(ADAPTEC2, 0x0243), chip_7042 }, > - > - /* Marvell 7042 support */ > - { PCI_VDEVICE(MARVELL, 0x7042), chip_7042 }, > - > - /* Highpoint RocketRAID PCIe series */ > - { PCI_VDEVICE(TTI, 0x2300), chip_7042 }, > - { PCI_VDEVICE(TTI, 0x2310), chip_7042 }, > - > - { } /* terminate list */ > -}; > - > static const struct mv_hw_ops mv5xxx_ops = { > .phy_errata = mv5_phy_errata, > .enable_leds = mv5_enable_leds, > @@ -4303,6 +4272,37 @@ static int mv_pci_init_one(struct pci_dev *pdev, > static int mv_pci_device_resume(struct pci_dev *pdev); > #endif > > +static const struct pci_device_id mv_pci_tbl[] = { > + { PCI_VDEVICE(MARVELL, 0x5040), chip_504x }, > + { PCI_VDEVICE(MARVELL, 0x5041), chip_504x }, > + { PCI_VDEVICE(MARVELL, 0x5080), chip_5080 }, > + { PCI_VDEVICE(MARVELL, 0x5081), chip_508x }, > + /* RocketRAID 1720/174x have different identifiers */ > + { PCI_VDEVICE(TTI, 0x1720), chip_6042 }, > + { PCI_VDEVICE(TTI, 0x1740), chip_6042 }, > + { PCI_VDEVICE(TTI, 0x1742), chip_6042 }, > + > + { PCI_VDEVICE(MARVELL, 0x6040), chip_604x }, > + { PCI_VDEVICE(MARVELL, 0x6041), chip_604x }, > + { PCI_VDEVICE(MARVELL, 0x6042), chip_6042 }, > + { PCI_VDEVICE(MARVELL, 0x6080), chip_608x }, > + { PCI_VDEVICE(MARVELL, 0x6081), chip_608x }, > + > + { PCI_VDEVICE(ADAPTEC2, 0x0241), chip_604x }, > + > + /* Adaptec 1430SA */ > + { PCI_VDEVICE(ADAPTEC2, 0x0243), chip_7042 }, > + > + /* Marvell 7042 support */ > + { PCI_VDEVICE(MARVELL, 0x7042), chip_7042 }, > + > + /* Highpoint RocketRAID PCIe series */ > + { PCI_VDEVICE(TTI, 0x2300), chip_7042 }, > + { PCI_VDEVICE(TTI, 0x2310), chip_7042 }, > + > + { } /* terminate list */ > +}; > + > > static struct pci_driver mv_pci_driver = { > .name = DRV_NAME, > @@ -4315,6 +4315,7 @@ static struct pci_driver mv_pci_driver = { > #endif > > }; > +MODULE_DEVICE_TABLE(pci, mv_pci_tbl); > > /** > * mv_print_info - Dump key info to kernel log for perusal. > @@ -4487,7 +4488,6 @@ static void __exit mv_exit(void) > MODULE_AUTHOR("Brett Russ"); > MODULE_DESCRIPTION("SCSI low-level driver for Marvell SATA controllers"); > MODULE_LICENSE("GPL v2"); > -MODULE_DEVICE_TABLE(pci, mv_pci_tbl); > MODULE_VERSION(DRV_VERSION); > MODULE_ALIAS("platform:" DRV_NAME); >
On 4/3/24 17:06, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > Building with W=1 shows a warning for an unused variable when CONFIG_PCI > is diabled: > > drivers/ata/sata_mv.c:790:35: error: unused variable 'mv_pci_tbl' [-Werror,-Wunused-const-variable] > static const struct pci_device_id mv_pci_tbl[] = { > > Move the table into the same block that containsn the pci_driver > definition. > > Fixes: 7bb3c5290ca0 ("sata_mv: Remove PCI dependency") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> The patch title is also not describing what the patch does. Are you OK with changing that to: ata: sata_mv: Fix PCI device ID table declaration warning ? > --- > drivers/ata/sata_mv.c | 64 +++++++++++++++++++++---------------------- > 1 file changed, 32 insertions(+), 32 deletions(-) > > diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c > index e82786c63fbd..697063890f5d 100644 > --- a/drivers/ata/sata_mv.c > +++ b/drivers/ata/sata_mv.c > @@ -787,37 +787,6 @@ static const struct ata_port_info mv_port_info[] = { > }, > }; > > -static const struct pci_device_id mv_pci_tbl[] = { > - { PCI_VDEVICE(MARVELL, 0x5040), chip_504x }, > - { PCI_VDEVICE(MARVELL, 0x5041), chip_504x }, > - { PCI_VDEVICE(MARVELL, 0x5080), chip_5080 }, > - { PCI_VDEVICE(MARVELL, 0x5081), chip_508x }, > - /* RocketRAID 1720/174x have different identifiers */ > - { PCI_VDEVICE(TTI, 0x1720), chip_6042 }, > - { PCI_VDEVICE(TTI, 0x1740), chip_6042 }, > - { PCI_VDEVICE(TTI, 0x1742), chip_6042 }, > - > - { PCI_VDEVICE(MARVELL, 0x6040), chip_604x }, > - { PCI_VDEVICE(MARVELL, 0x6041), chip_604x }, > - { PCI_VDEVICE(MARVELL, 0x6042), chip_6042 }, > - { PCI_VDEVICE(MARVELL, 0x6080), chip_608x }, > - { PCI_VDEVICE(MARVELL, 0x6081), chip_608x }, > - > - { PCI_VDEVICE(ADAPTEC2, 0x0241), chip_604x }, > - > - /* Adaptec 1430SA */ > - { PCI_VDEVICE(ADAPTEC2, 0x0243), chip_7042 }, > - > - /* Marvell 7042 support */ > - { PCI_VDEVICE(MARVELL, 0x7042), chip_7042 }, > - > - /* Highpoint RocketRAID PCIe series */ > - { PCI_VDEVICE(TTI, 0x2300), chip_7042 }, > - { PCI_VDEVICE(TTI, 0x2310), chip_7042 }, > - > - { } /* terminate list */ > -}; > - > static const struct mv_hw_ops mv5xxx_ops = { > .phy_errata = mv5_phy_errata, > .enable_leds = mv5_enable_leds, > @@ -4303,6 +4272,37 @@ static int mv_pci_init_one(struct pci_dev *pdev, > static int mv_pci_device_resume(struct pci_dev *pdev); > #endif > > +static const struct pci_device_id mv_pci_tbl[] = { > + { PCI_VDEVICE(MARVELL, 0x5040), chip_504x }, > + { PCI_VDEVICE(MARVELL, 0x5041), chip_504x }, > + { PCI_VDEVICE(MARVELL, 0x5080), chip_5080 }, > + { PCI_VDEVICE(MARVELL, 0x5081), chip_508x }, > + /* RocketRAID 1720/174x have different identifiers */ > + { PCI_VDEVICE(TTI, 0x1720), chip_6042 }, > + { PCI_VDEVICE(TTI, 0x1740), chip_6042 }, > + { PCI_VDEVICE(TTI, 0x1742), chip_6042 }, > + > + { PCI_VDEVICE(MARVELL, 0x6040), chip_604x }, > + { PCI_VDEVICE(MARVELL, 0x6041), chip_604x }, > + { PCI_VDEVICE(MARVELL, 0x6042), chip_6042 }, > + { PCI_VDEVICE(MARVELL, 0x6080), chip_608x }, > + { PCI_VDEVICE(MARVELL, 0x6081), chip_608x }, > + > + { PCI_VDEVICE(ADAPTEC2, 0x0241), chip_604x }, > + > + /* Adaptec 1430SA */ > + { PCI_VDEVICE(ADAPTEC2, 0x0243), chip_7042 }, > + > + /* Marvell 7042 support */ > + { PCI_VDEVICE(MARVELL, 0x7042), chip_7042 }, > + > + /* Highpoint RocketRAID PCIe series */ > + { PCI_VDEVICE(TTI, 0x2300), chip_7042 }, > + { PCI_VDEVICE(TTI, 0x2310), chip_7042 }, > + > + { } /* terminate list */ > +}; > + > > static struct pci_driver mv_pci_driver = { > .name = DRV_NAME, > @@ -4315,6 +4315,7 @@ static struct pci_driver mv_pci_driver = { > #endif > > }; > +MODULE_DEVICE_TABLE(pci, mv_pci_tbl); > > /** > * mv_print_info - Dump key info to kernel log for perusal. > @@ -4487,7 +4488,6 @@ static void __exit mv_exit(void) > MODULE_AUTHOR("Brett Russ"); > MODULE_DESCRIPTION("SCSI low-level driver for Marvell SATA controllers"); > MODULE_LICENSE("GPL v2"); > -MODULE_DEVICE_TABLE(pci, mv_pci_tbl); > MODULE_VERSION(DRV_VERSION); > MODULE_ALIAS("platform:" DRV_NAME); >
On Wed, Apr 3, 2024, at 10:32, Damien Le Moal wrote: > On 4/3/24 17:06, Arnd Bergmann wrote: >> From: Arnd Bergmann <arnd@arndb.de> >> >> Building with W=1 shows a warning for an unused variable when CONFIG_PCI >> is diabled: >> >> drivers/ata/sata_mv.c:790:35: error: unused variable 'mv_pci_tbl' [-Werror,-Wunused-const-variable] >> static const struct pci_device_id mv_pci_tbl[] = { >> >> Move the table into the same block that containsn the pci_driver >> definition. >> >> Fixes: 7bb3c5290ca0 ("sata_mv: Remove PCI dependency") >> Signed-off-by: Arnd Bergmann <arnd@arndb.de> > > The patch title is also not describing what the patch does. > Are you OK with changing that to: > > ata: sata_mv: Fix PCI device ID table declaration warning > > ? Yes, please do, thanks! I had first tried to remove all the #ifdef checks and just rely on dead-code-elimination doing the same when pci_register_driver() is stubbed out and IS_ENABLED(CONFIG_OF) checks turn off the rest. Unfortunately, the include/linux/pci.h interfaces are not all stubbed out here and cause compile-time failures without CONFIG_PCI, so that didn't work out. Arnd
On 4/3/24 17:50, Arnd Bergmann wrote: > On Wed, Apr 3, 2024, at 10:32, Damien Le Moal wrote: >> On 4/3/24 17:06, Arnd Bergmann wrote: >>> From: Arnd Bergmann <arnd@arndb.de> >>> >>> Building with W=1 shows a warning for an unused variable when CONFIG_PCI >>> is diabled: >>> >>> drivers/ata/sata_mv.c:790:35: error: unused variable 'mv_pci_tbl' [-Werror,-Wunused-const-variable] >>> static const struct pci_device_id mv_pci_tbl[] = { >>> >>> Move the table into the same block that containsn the pci_driver >>> definition. >>> >>> Fixes: 7bb3c5290ca0 ("sata_mv: Remove PCI dependency") >>> Signed-off-by: Arnd Bergmann <arnd@arndb.de> >> >> The patch title is also not describing what the patch does. >> Are you OK with changing that to: >> >> ata: sata_mv: Fix PCI device ID table declaration warning >> >> ? > > Yes, please do, thanks! Applied to for-6.9-fixes with discussed tweaks and removal of extra blanklines pointed out by Andy. Thanks ! > > I had first tried to remove all the #ifdef checks and just > rely on dead-code-elimination doing the same when > pci_register_driver() is stubbed out and IS_ENABLED(CONFIG_OF) > checks turn off the rest. Unfortunately, the include/linux/pci.h > interfaces are not all stubbed out here and cause compile-time > failures without CONFIG_PCI, so that didn't work out. > > Arnd
Hello: This series was applied to netdev/net-next.git (main) by Jakub Kicinski <kuba@kernel.org>: On Wed, 3 Apr 2024 10:06:18 +0200 you wrote: > From: Arnd Bergmann <arnd@arndb.de> > > Compilers traditionally warn for unused 'static' variables, but not > if they are constant. The reason here is a custom for C++ programmers > to define named constants as 'static const' variables in header files > instead of using macros or enums. > > [...] Here is the summary with links: - [05/34] 3c515: remove unused 'mtu' variable https://git.kernel.org/netdev/net-next/c/17b35355c2c6 - [19/34] sunrpc: suppress warnings for unused procfs functions (no matching commit) - [26/34] isdn: kcapi: don't build unused procfs code https://git.kernel.org/netdev/net-next/c/91188544af06 - [28/34] net: xgbe: remove extraneous #ifdef checks https://git.kernel.org/netdev/net-next/c/0ef416e045ad - [33/34] drivers: remove incorrect of_match_ptr/ACPI_PTR annotations (no matching commit) You are awesome, thank you!
On Wed, 03 Apr 2024 10:06:18 +0200, Arnd Bergmann wrote: > From: Arnd Bergmann <arnd@arndb.de> > > Compilers traditionally warn for unused 'static' variables, but not > if they are constant. The reason here is a custom for C++ programmers > to define named constants as 'static const' variables in header files > instead of using macros or enums. > > [...] Applied, thanks! [09/34] power: rt9455: hide unused rt9455_boost_voltage_values commit: 452d8950db3e839aba1bb13bc5378f4bac11fa04 Best regards,
On Wed, 03 Apr 2024 10:06:18 +0200, Arnd Bergmann wrote: > Compilers traditionally warn for unused 'static' variables, but not > if they are constant. The reason here is a custom for C++ programmers > to define named constants as 'static const' variables in header files > instead of using macros or enums. > > In W=1 builds, we get warnings only static const variables in C > files, but not in headers, which is a good compromise, but this still > produces warning output in at least 30 files. These warnings are > almost all harmless, but also trivial to fix, and there is no > good reason to warn only about the non-const variables being unused. > > [...] Applied to powerpc/next. [01/34] powerpc/fsl-soc: hide unused const variable https://git.kernel.org/powerpc/c/01acaf3aa75e1641442cc23d8fe0a7bb4226efb1 cheers
From: Arnd Bergmann <arnd@arndb.de> Compilers traditionally warn for unused 'static' variables, but not if they are constant. The reason here is a custom for C++ programmers to define named constants as 'static const' variables in header files instead of using macros or enums. In W=1 builds, we get warnings only static const variables in C files, but not in headers, which is a good compromise, but this still produces warning output in at least 30 files. These warnings are almost all harmless, but also trivial to fix, and there is no good reason to warn only about the non-const variables being unused. I've gone through all the files that I found using randconfig and allmodconfig builds and created patches to avoid these warnings, with the goal of retaining a clean build once the option is enabled by default. Unfortunately, there is one fairly large patch ("drivers: remove incorrect of_match_ptr/ACPI_PTR annotations") that touches 34 individual drivers that all need the same one-line change. If necessary, I can split it up by driver or by subsystem, but at least for reviewing I would keep it as one piece for the moment. Please merge the individual patches through subsystem trees. I expect that some of these will have to go through multiple revisions before they are picked up, so anything that gets applied early saves me from resending. Arnd Arnd Bergmann (31): powerpc/fsl-soc: hide unused const variable ubsan: fix unused variable warning in test module platform: goldfish: remove ACPI_PTR() annotations i2c: pxa: hide unused icr_bits[] variable 3c515: remove unused 'mtu' variable tracing: hide unused ftrace_event_id_fops Input: synaptics: hide unused smbus_pnp_ids[] array power: rt9455: hide unused rt9455_boost_voltage_values efi: sysfb: don't build when EFI is disabled clk: ti: dpll: fix incorrect #ifdef checks apm-emulation: hide an unused variable sisfb: hide unused variables dma/congiguous: avoid warning about unused size_bytes leds: apu: remove duplicate DMI lookup data iio: ad5755: hook up of_device_id lookup to platform driver greybus: arche-ctrl: move device table to its right location lib: checksum: hide unused expected_csum_ipv6_magic[] sunrpc: suppress warnings for unused procfs functions comedi: ni_atmio: avoid warning for unused device_ids[] table iwlegacy: don't warn for unused variables with DEBUG_FS=n drm/komeda: don't warn for unused debugfs files firmware: qcom_scm: mark qcom_scm_qseecom_allowlist as __maybe_unused crypto: ccp - drop platform ifdef checks usb: gadget: omap_udc: remove unused variable isdn: kcapi: don't build unused procfs code cpufreq: intel_pstate: hide unused intel_pstate_cpu_oob_ids[] net: xgbe: remove extraneous #ifdef checks Input: imagis - remove incorrect ifdef checks sata: mv: drop unnecessary #ifdef checks ASoC: remove incorrect of_match_ptr/ACPI_PTR annotations spi: remove incorrect of_match_ptr annotations drivers: remove incorrect of_match_ptr/ACPI_PTR annotations kbuild: always enable -Wunused-const-variable Krzysztof Kozlowski (1): Input: stmpe-ts - mark OF related data as maybe unused arch/powerpc/sysdev/fsl_msi.c | 2 + drivers/ata/sata_mv.c | 64 +++++++++---------- drivers/char/apm-emulation.c | 5 +- drivers/char/ipmi/ipmb_dev_int.c | 2 +- drivers/char/tpm/tpm_ftpm_tee.c | 2 +- drivers/clk/ti/dpll.c | 10 ++- drivers/comedi/drivers/ni_atmio.c | 2 +- drivers/cpufreq/intel_pstate.c | 2 + drivers/crypto/ccp/sp-platform.c | 14 +--- drivers/dma/img-mdc-dma.c | 2 +- drivers/firmware/efi/Makefile | 3 +- drivers/firmware/efi/sysfb_efi.c | 2 - drivers/firmware/qcom/qcom_scm.c | 2 +- drivers/fpga/versal-fpga.c | 2 +- .../gpu/drm/arm/display/komeda/komeda_dev.c | 8 --- drivers/hid/hid-google-hammer.c | 6 +- drivers/i2c/busses/i2c-pxa.c | 2 +- drivers/i2c/muxes/i2c-mux-ltc4306.c | 2 +- drivers/i2c/muxes/i2c-mux-reg.c | 2 +- drivers/iio/dac/ad5755.c | 1 + drivers/input/mouse/synaptics.c | 2 + drivers/input/touchscreen/imagis.c | 4 +- drivers/input/touchscreen/stmpe-ts.c | 2 +- drivers/input/touchscreen/wdt87xx_i2c.c | 2 +- drivers/isdn/capi/Makefile | 3 +- drivers/isdn/capi/kcapi.c | 7 +- drivers/leds/leds-apu.c | 3 +- drivers/mux/adg792a.c | 2 +- drivers/net/ethernet/3com/3c515.c | 3 - drivers/net/ethernet/amd/xgbe/xgbe-platform.c | 8 --- drivers/net/ethernet/apm/xgene-v2/main.c | 2 +- drivers/net/ethernet/hisilicon/hns_mdio.c | 2 +- drivers/net/wireless/intel/iwlegacy/4965-rs.c | 15 +---- drivers/net/wireless/intel/iwlegacy/common.h | 2 - drivers/platform/goldfish/goldfish_pipe.c | 2 +- drivers/power/supply/rt9455_charger.c | 2 + drivers/regulator/pbias-regulator.c | 2 +- drivers/regulator/twl-regulator.c | 2 +- drivers/regulator/twl6030-regulator.c | 2 +- drivers/rtc/rtc-fsl-ftm-alarm.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_v1_hw.c | 2 +- drivers/scsi/hisi_sas/hisi_sas_v2_hw.c | 2 +- drivers/spi/spi-armada-3700.c | 2 +- drivers/spi/spi-img-spfi.c | 2 +- drivers/spi/spi-meson-spicc.c | 2 +- drivers/spi/spi-meson-spifc.c | 2 +- drivers/spi/spi-orion.c | 2 +- drivers/spi/spi-pic32-sqi.c | 2 +- drivers/spi/spi-pic32.c | 2 +- drivers/spi/spi-rockchip.c | 2 +- drivers/spi/spi-s3c64xx.c | 2 +- drivers/spi/spi-st-ssc4.c | 2 +- drivers/staging/greybus/arche-apb-ctrl.c | 1 + drivers/staging/greybus/arche-platform.c | 9 +-- drivers/staging/pi433/pi433_if.c | 2 +- drivers/tty/serial/amba-pl011.c | 6 +- drivers/tty/serial/ma35d1_serial.c | 2 +- drivers/usb/gadget/udc/omap_udc.c | 10 +-- drivers/video/fbdev/sis/init301.c | 3 +- kernel/dma/contiguous.c | 2 +- kernel/trace/trace_events.c | 4 ++ lib/checksum_kunit.c | 2 + lib/test_ubsan.c | 2 +- net/sunrpc/cache.c | 10 +-- scripts/Makefile.extrawarn | 1 - sound/soc/atmel/sam9x5_wm8731.c | 2 +- sound/soc/codecs/rt5514-spi.c | 2 +- sound/soc/qcom/lpass-sc7280.c | 2 +- sound/soc/samsung/aries_wm8994.c | 2 +- 69 files changed, 121 insertions(+), 169 deletions(-)