From: Arnd Bergmann <arnd@arndb.de> To: "David S. Miller" <davem@davemloft.net> Cc: linux-arm-kernel@lists.infradead.org, Arnd Bergmann <arnd@arndb.de>, netdev@vger.kernel.org, "Maciej W. Rozycki" <macro@linux-mips.org>, linux-kernel@vger.kernel.org Subject: [PATCH 5/9] net: fddi/defxx: avoid warning about uninitialized variable use Date: Wed, 27 Jan 2016 15:04:55 +0100 [thread overview] Message-ID: <1453903507-3427225-6-git-send-email-arnd@arndb.de> (raw) In-Reply-To: <1453903507-3427225-1-git-send-email-arnd@arndb.de> The defxx driver can be configured for different kinds of buses, and appears to be handling this correctly, but the compiler cannot see how it always initializes the bar_start and bar_length fields it uses depending on the configured bus, so we get a warning with recent gcc versions: fddi/defxx.c: In function 'dfx_pci_unregister': fddi/defxx.c:3726:3: warning: 'bar_len' may be used uninitialized in this function [-Wmaybe-uninitialized] release_mem_region(bar_start[0], bar_len[0]); fddi/defxx.c:3701:18: note: 'bar_len' was declared here resource_size_t bar_len[3]; /* resource lengths */ fddi/defxx.c:3726:3: warning: 'bar_start' may be used uninitialized in this function [-Wmaybe-uninitialized] release_mem_region(bar_start[0], bar_len[0]); fddi/defxx.c:3700:18: note: 'bar_start' was declared here resource_size_t bar_start[3]; /* pointers to ports */ ^ fddi/defxx.c: In function 'dfx_pci_register': fddi/defxx.c:617:18: warning: 'bar_len' may be used uninitialized in this function [-Wmaybe-uninitialized] bp->base.mem = ioremap_nocache(bar_start[0], bar_len[0]); fddi/defxx.c:537:18: note: 'bar_len' was declared here resource_size_t bar_len[3]; /* resource length */ fddi/defxx.c:1125:2: warning: 'bar_start' may be used uninitialized in this function [-Wmaybe-uninitialized] pr_info("%s: %s at %s addr = 0x%llx, IRQ = %d, Hardware addr = %pMF\n", fddi/defxx.c:536:18: note: 'bar_start' was declared here resource_size_t bar_start[3]; /* pointers to ports */ This adds code to ensure that the BAR values are initialized even in the impossible case when a device gets probed that does not belong to any bus. This shuts up the warning. Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/net/fddi/defxx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/fddi/defxx.c b/drivers/net/fddi/defxx.c index 7f975a2c8990..e7cdd1226d39 100644 --- a/drivers/net/fddi/defxx.c +++ b/drivers/net/fddi/defxx.c @@ -484,6 +484,11 @@ static void dfx_get_bars(struct device *bdev, bar_start[2] = bar_start[1] = 0; bar_len[2] = bar_len[1] = 0; } + if (!(dfx_bus_pci || dfx_bus_eisa || dfx_bus_tc)) { + dev_err(bdev, "invalid bus configuration\n"); + bar_start[2] = bar_start[1] = bar_start[0] = 0; + bar_len[2] = bar_len[1] = bar_len[0] = 0; + } } static const struct net_device_ops dfx_netdev_ops = { -- 2.7.0
WARNING: multiple messages have this Message-ID (diff)
From: arnd@arndb.de (Arnd Bergmann) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 5/9] net: fddi/defxx: avoid warning about uninitialized variable use Date: Wed, 27 Jan 2016 15:04:55 +0100 [thread overview] Message-ID: <1453903507-3427225-6-git-send-email-arnd@arndb.de> (raw) In-Reply-To: <1453903507-3427225-1-git-send-email-arnd@arndb.de> The defxx driver can be configured for different kinds of buses, and appears to be handling this correctly, but the compiler cannot see how it always initializes the bar_start and bar_length fields it uses depending on the configured bus, so we get a warning with recent gcc versions: fddi/defxx.c: In function 'dfx_pci_unregister': fddi/defxx.c:3726:3: warning: 'bar_len' may be used uninitialized in this function [-Wmaybe-uninitialized] release_mem_region(bar_start[0], bar_len[0]); fddi/defxx.c:3701:18: note: 'bar_len' was declared here resource_size_t bar_len[3]; /* resource lengths */ fddi/defxx.c:3726:3: warning: 'bar_start' may be used uninitialized in this function [-Wmaybe-uninitialized] release_mem_region(bar_start[0], bar_len[0]); fddi/defxx.c:3700:18: note: 'bar_start' was declared here resource_size_t bar_start[3]; /* pointers to ports */ ^ fddi/defxx.c: In function 'dfx_pci_register': fddi/defxx.c:617:18: warning: 'bar_len' may be used uninitialized in this function [-Wmaybe-uninitialized] bp->base.mem = ioremap_nocache(bar_start[0], bar_len[0]); fddi/defxx.c:537:18: note: 'bar_len' was declared here resource_size_t bar_len[3]; /* resource length */ fddi/defxx.c:1125:2: warning: 'bar_start' may be used uninitialized in this function [-Wmaybe-uninitialized] pr_info("%s: %s at %s addr = 0x%llx, IRQ = %d, Hardware addr = %pMF\n", fddi/defxx.c:536:18: note: 'bar_start' was declared here resource_size_t bar_start[3]; /* pointers to ports */ This adds code to ensure that the BAR values are initialized even in the impossible case when a device gets probed that does not belong to any bus. This shuts up the warning. Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- drivers/net/fddi/defxx.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/fddi/defxx.c b/drivers/net/fddi/defxx.c index 7f975a2c8990..e7cdd1226d39 100644 --- a/drivers/net/fddi/defxx.c +++ b/drivers/net/fddi/defxx.c @@ -484,6 +484,11 @@ static void dfx_get_bars(struct device *bdev, bar_start[2] = bar_start[1] = 0; bar_len[2] = bar_len[1] = 0; } + if (!(dfx_bus_pci || dfx_bus_eisa || dfx_bus_tc)) { + dev_err(bdev, "invalid bus configuration\n"); + bar_start[2] = bar_start[1] = bar_start[0] = 0; + bar_len[2] = bar_len[1] = bar_len[0] = 0; + } } static const struct net_device_ops dfx_netdev_ops = { -- 2.7.0
next prev parent reply other threads:[~2016-01-27 14:09 UTC|newest] Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top 2016-01-27 14:04 [PATCH 0/9] network driver fixes Arnd Bergmann 2016-01-27 14:04 ` Arnd Bergmann 2016-01-27 14:04 ` [PATCH 1/9] net: davinci_cpdma: use dma_addr_t for DMA address Arnd Bergmann 2016-01-27 14:04 ` Arnd Bergmann 2016-01-27 14:04 ` [PATCH 2/9] net: hp100: remove unnecessary #ifdefs Arnd Bergmann 2016-01-27 14:04 ` Arnd Bergmann 2016-01-27 14:04 ` [PATCH 3/9] net: bgmac: clarify CONFIG_BCMA dependency Arnd Bergmann 2016-01-27 14:04 ` Arnd Bergmann 2016-01-27 16:11 ` Paul Gortmaker 2016-01-27 16:11 ` Paul Gortmaker 2016-01-27 16:11 ` Paul Gortmaker 2016-01-28 8:49 ` Arnd Bergmann 2016-01-28 8:49 ` Arnd Bergmann 2016-01-27 14:04 ` [PATCH 4/9] net: moxart: use correct accessors for DMA memory Arnd Bergmann 2016-01-27 14:04 ` Arnd Bergmann 2016-01-28 12:36 ` David Laight 2016-01-28 12:36 ` David Laight 2016-01-28 16:53 ` Arnd Bergmann 2016-01-28 16:53 ` Arnd Bergmann 2016-01-28 16:58 ` Arnd Bergmann 2016-01-28 16:58 ` Arnd Bergmann 2016-01-27 14:04 ` Arnd Bergmann [this message] 2016-01-27 14:04 ` [PATCH 5/9] net: fddi/defxx: avoid warning about uninitialized variable use Arnd Bergmann 2016-01-27 15:15 ` Maciej W. Rozycki 2016-01-27 15:15 ` Maciej W. Rozycki 2016-01-27 14:04 ` [PATCH 6/9] net: vxge: avoid unused function warnings Arnd Bergmann 2016-01-27 14:04 ` Arnd Bergmann 2016-01-27 14:04 ` [PATCH 7/9] net: macb: avoid uninitialized variables Arnd Bergmann 2016-01-27 14:04 ` Arnd Bergmann 2016-01-27 15:51 ` Nicolas Ferre 2016-01-27 15:51 ` Nicolas Ferre 2016-01-27 16:04 ` Nicolas Ferre 2016-01-27 16:04 ` Nicolas Ferre 2016-01-28 16:32 ` Arnd Bergmann 2016-01-28 16:32 ` Arnd Bergmann 2016-01-28 13:27 ` Sergei Shtylyov 2016-01-28 13:27 ` Sergei Shtylyov 2016-01-27 14:04 ` [PATCH 8/9] net: nb8800: avoid uninitialized variable warning Arnd Bergmann 2016-01-27 14:04 ` Arnd Bergmann 2016-01-27 14:13 ` Måns Rullgård 2016-01-27 14:13 ` Måns Rullgård 2016-01-27 15:21 ` Arnd Bergmann 2016-01-27 15:21 ` Arnd Bergmann 2016-01-27 14:04 ` [PATCH 9/9] net: tg3: " Arnd Bergmann 2016-01-27 14:04 ` Arnd Bergmann 2016-01-29 0:14 ` [PATCH 0/9] network driver fixes David Miller 2016-01-29 0:14 ` David Miller 2016-01-29 12:56 ` Arnd Bergmann 2016-01-29 12:56 ` Arnd Bergmann
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1453903507-3427225-6-git-send-email-arnd@arndb.de \ --to=arnd@arndb.de \ --cc=davem@davemloft.net \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=macro@linux-mips.org \ --cc=netdev@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.