2008-12-22 19:15:27

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 00/27] drivers/net: fix sparse warnings

The following series fixes about 100 sparse warnings in drivers/net.

---

Hannes Eder (27):
drivers/net/wireless/prism54: fix sparse warnings: make symbols static
drivers/net/wireless/ipw2x00: fix sparse warnings: make symbols static
drivers/net/wireless/b43: fix sparse warnings: make symbols static
drivers/net/wireless/ath9k: fix sparse warnings: make symbols static
drivers/net/wireless: fix sparse warnings: make symbols static
drivers/net/wan/z85230.c: fix sparse warnings: un-EXPORT symbols
drivers/net/wan: fix sparse warning: make symbol static
drivers/net/wan: fix sparse warnings: make do-while a compound statement
drivers/net/usb: fix sparse warnings: make symbols static
drivers/net/tulip: fix sparse warnings: make do-while a compound statement
drivers/net/tokenring: fix sparse warnings: make symbols static
drivers/net/skfp: fix sparse warnings: make symbols static
drivers/net/qlge: fix sparse warnings: make symbols static
drivers/net/netxen: fix sparse warnings: use NULL pointer instead of plain integer
drivers/net/ixgbe: fix sparse warnings: make symbols static
drivers/net/irda: fix sparse warnings: make symbols static
drivers/net/igb: remove dead code (function 'igb_read_pci_cfg')
drivers/net/enic: fix sparse warning: make symbol static
drivers/net/e1000e: fix sparse warnings: make symbols static
drivers/net/cxgb3: comment out dead code
drivers/net/bonding: fix sparse warnings: move decls to header file
drivers/net/atlx: fix sparse warnings: make symbols static
drivers/net/arcnet: fix sparse warnings: make symbols static
drivers/net: fix sparse warnings: make symbols static
drivers/net: fix sparse warning: returning void-valued expression
drivers/net: fix sparse warnings: make do-while a compound statement
drivers/net: fix sparse warning: use ANSI-style function declaration


drivers/net/3c523.c | 2 -
drivers/net/arcnet/capmode.c | 2 -
drivers/net/arcnet/com90xx.c | 2 -
drivers/net/atlx/atl1.c | 4 +-
drivers/net/atp.c | 19 ++++----
drivers/net/bonding/bond_main.c | 1
drivers/net/bonding/bond_sysfs.c | 3 -
drivers/net/bonding/bonding.h | 5 ++
drivers/net/cs89x0.c | 2 -
drivers/net/cxgb3/vsc8211.c | 2 +
drivers/net/e1000e/es2lan.c | 6 ++
drivers/net/eepro.c | 2 -
drivers/net/enic/vnic_dev.c | 2 -
drivers/net/igb/e1000_mac.c | 7 ---
drivers/net/irda/ma600-sir.c | 2 -
drivers/net/irda/smsc-ircc2.c | 6 +-
drivers/net/irda/w83977af_ir.c | 14 +++---
drivers/net/ixgbe/ixgbe_82598.c | 24 +++++-----
drivers/net/ixgbe/ixgbe_dcb_82598.c | 4 +-
drivers/net/ne.c | 2 -
drivers/net/netxen/netxen_nic_hw.c | 4 +-
drivers/net/niu.c | 2 -
drivers/net/plip.c | 20 ++++----
drivers/net/qlge/qlge_ethtool.c | 2 -
drivers/net/qlge/qlge_mpi.c | 2 -
drivers/net/s2io.c | 2 -
drivers/net/skfp/skfddi.c | 6 +-
drivers/net/smc9194.c | 2 -
drivers/net/starfire.c | 4 +-
drivers/net/tokenring/ibmtr.c | 4 +-
drivers/net/tokenring/madgemc.c | 2 -
drivers/net/tokenring/proteon.c | 2 -
drivers/net/tokenring/skisa.c | 2 -
drivers/net/tulip/de2104x.c | 4 +-
drivers/net/tulip/tulip_core.c | 4 +-
drivers/net/usb/hso.c | 10 ++--
drivers/net/usb/smsc95xx.c | 2 -
drivers/net/wan/wanxl.c | 8 ++-
drivers/net/wan/x25_asy.c | 2 -
drivers/net/wan/z85230.c | 10 +---
drivers/net/wireless/airo.c | 2 -
drivers/net/wireless/ath9k/eeprom.c | 62 +++++++++++++------------
drivers/net/wireless/atmel.c | 2 -
drivers/net/wireless/b43/phy_a.c | 4 +-
drivers/net/wireless/b43/phy_g.c | 20 ++++----
drivers/net/wireless/ipw2x00/ipw2100.c | 6 +-
drivers/net/wireless/prism54/islpci_hotplug.c | 8 ++-
drivers/net/wireless/ray_cs.c | 2 -
48 files changed, 153 insertions(+), 158 deletions(-)


2008-12-22 19:16:08

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 01/27] drivers/net: fix sparse warning: use ANSI-style function declaration

Fix this sparse warning:

drivers/net/ne.c:932:24: warning: non-ANSI function declaration of function 'init_module'

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/ne.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/ne.c b/drivers/net/ne.c
index cb02698..5c3e242 100644
--- a/drivers/net/ne.c
+++ b/drivers/net/ne.c
@@ -929,7 +929,7 @@ static void __init ne_add_devices(void)
}

#ifdef MODULE
-int __init init_module()
+int __init init_module(void)
{
int retval;
ne_add_devices();

2008-12-22 19:17:38

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 04/27] drivers/net: fix sparse warnings: make symbols static

Fix this sparse warnings:

drivers/net/3c523.c:350:6: warning: symbol 'alloc586' was not declared. Should it be static?
drivers/net/cs89x0.c:1029:14: warning: symbol 'reset_chip' was not declared. Should it be static?
drivers/net/eepro.c:1399:1: warning: symbol 'read_eeprom' was not declared. Should it be static?
drivers/net/plip.c:1020:5: warning: symbol 'plip_hard_header_cache' was not declared. Should it be static?
drivers/net/s2io.c:5116:6: warning: symbol 'do_s2io_store_unicast_mc' was not declared. Should it be static?
drivers/net/smc9194.c:767:12: warning: symbol 'smc_findirq' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/3c523.c | 2 +-
drivers/net/cs89x0.c | 2 +-
drivers/net/eepro.c | 2 +-
drivers/net/plip.c | 4 ++--
drivers/net/s2io.c | 2 +-
drivers/net/smc9194.c | 2 +-
6 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/3c523.c b/drivers/net/3c523.c
index d9c9481..ff41e1f 100644
--- a/drivers/net/3c523.c
+++ b/drivers/net/3c523.c
@@ -347,7 +347,7 @@ static int __init check586(struct net_device *dev, unsigned long where, unsigned
* set iscp at the right place, called by elmc_probe and open586.
*/

-void alloc586(struct net_device *dev)
+static void alloc586(struct net_device *dev)
{
struct priv *p = netdev_priv(dev);

diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c
index f0edb8b..ff64976 100644
--- a/drivers/net/cs89x0.c
+++ b/drivers/net/cs89x0.c
@@ -1026,7 +1026,7 @@ skip_this_frame:

#endif /* ALLOW_DMA */

-void __init reset_chip(struct net_device *dev)
+static void __init reset_chip(struct net_device *dev)
{
#if !defined(CONFIG_MACH_MX31ADS)
#if !defined(CONFIG_MACH_IXDP2351) && !defined(CONFIG_ARCH_IXDP2X01)
diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c
index 0a98461..e187c88 100644
--- a/drivers/net/eepro.c
+++ b/drivers/net/eepro.c
@@ -1395,7 +1395,7 @@ set_multicast_list(struct net_device *dev)
#define eeprom_delay() { udelay(40); }
#define EE_READ_CMD (6 << 6)

-int
+static int
read_eeprom(int ioaddr, int location, struct net_device *dev)
{
int i;
diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index ed8582e..0c46d60 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -1017,8 +1017,8 @@ plip_hard_header(struct sk_buff *skb, struct net_device *dev,
return ret;
}

-int plip_hard_header_cache(const struct neighbour *neigh,
- struct hh_cache *hh)
+static int plip_hard_header_cache(const struct neighbour *neigh,
+ struct hh_cache *hh)
{
int ret;

diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c
index 1b489df..4f6a452 100644
--- a/drivers/net/s2io.c
+++ b/drivers/net/s2io.c
@@ -5113,7 +5113,7 @@ static void s2io_set_multicast(struct net_device *dev)
/* read from CAM unicast & multicast addresses and store it in
* def_mac_addr structure
*/
-void do_s2io_store_unicast_mc(struct s2io_nic *sp)
+static void do_s2io_store_unicast_mc(struct s2io_nic *sp)
{
int offset;
u64 mac_addr = 0x0;
diff --git a/drivers/net/smc9194.c b/drivers/net/smc9194.c
index e7cc80f..18d653b 100644
--- a/drivers/net/smc9194.c
+++ b/drivers/net/smc9194.c
@@ -764,7 +764,7 @@ out:
. interrupt, so an auto-detect routine can detect it, and find the IRQ,
------------------------------------------------------------------------
*/
-int __init smc_findirq( int ioaddr )
+static int __init smc_findirq(int ioaddr)
{
#ifndef NO_AUTOPROBE
int timeout = 20;

2008-12-22 19:16:58

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 03/27] drivers/net: fix sparse warning: returning void-valued expression

Fix this sparse warning:

drivers/net/niu.c:8850:2: warning: returning void-valued expression

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/niu.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/niu.c b/drivers/net/niu.c
index 022866d..a4b6913 100644
--- a/drivers/net/niu.c
+++ b/drivers/net/niu.c
@@ -8847,7 +8847,7 @@ static u64 niu_pci_map_page(struct device *dev, struct page *page,
static void niu_pci_unmap_page(struct device *dev, u64 dma_address,
size_t size, enum dma_data_direction direction)
{
- return dma_unmap_page(dev, dma_address, size, direction);
+ dma_unmap_page(dev, dma_address, size, direction);
}

static u64 niu_pci_map_single(struct device *dev, void *cpu_addr,

2008-12-22 19:16:35

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement

While at it insert some extra curly braces and fix formatting.

Fix this sparse warnings:

drivers/net/atp.c:811:8: warning: do-while statement is not a compound statement
drivers/net/atp.c:813:8: warning: do-while statement is not a compound statement
drivers/net/atp.c:815:11: warning: do-while statement is not a compound statement
drivers/net/atp.c:817:11: warning: do-while statement is not a compound statement
drivers/net/plip.c:642:4: warning: do-while statement is not a compound statement
drivers/net/plip.c:647:4: warning: do-while statement is not a compound statement
drivers/net/plip.c:820:4: warning: do-while statement is not a compound statement
drivers/net/plip.c:825:4: warning: do-while statement is not a compound statement
drivers/net/starfire.c:886:3: warning: do-while statement is not a compound statement

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/atp.c | 19 ++++++++++---------
drivers/net/plip.c | 16 ++++++++--------
drivers/net/starfire.c | 4 ++--
3 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/net/atp.c b/drivers/net/atp.c
index 1d6b74c..ea493ce 100644
--- a/drivers/net/atp.c
+++ b/drivers/net/atp.c
@@ -802,21 +802,22 @@ static void net_rx(struct net_device *dev)

static void read_block(long ioaddr, int length, unsigned char *p, int data_mode)
{
-
if (data_mode <= 3) { /* Mode 0 or 1 */
outb(Ctrl_LNibRead, ioaddr + PAR_CONTROL);
outb(length == 8 ? RdAddr | HNib | MAR : RdAddr | MAR,
ioaddr + PAR_DATA);
if (data_mode <= 1) { /* Mode 0 or 1 */
- do *p++ = read_byte_mode0(ioaddr); while (--length > 0);
- } else /* Mode 2 or 3 */
- do *p++ = read_byte_mode2(ioaddr); while (--length > 0);
- } else if (data_mode <= 5)
- do *p++ = read_byte_mode4(ioaddr); while (--length > 0);
- else
- do *p++ = read_byte_mode6(ioaddr); while (--length > 0);
+ do { *p++ = read_byte_mode0(ioaddr); } while (--length > 0);
+ } else { /* Mode 2 or 3 */
+ do { *p++ = read_byte_mode2(ioaddr); } while (--length > 0);
+ }
+ } else if (data_mode <= 5) {
+ do { *p++ = read_byte_mode4(ioaddr); } while (--length > 0);
+ } else {
+ do { *p++ = read_byte_mode6(ioaddr); } while (--length > 0);
+ }

- outb(EOC+HNib+MAR, ioaddr + PAR_DATA);
+ outb(EOC+HNib+MAR, ioaddr + PAR_DATA);
outb(Ctrl_SelData, ioaddr + PAR_CONTROL);
}

diff --git a/drivers/net/plip.c b/drivers/net/plip.c
index 5d904f7..ed8582e 100644
--- a/drivers/net/plip.c
+++ b/drivers/net/plip.c
@@ -638,14 +638,14 @@ plip_receive_packet(struct net_device *dev, struct net_local *nl,

case PLIP_PK_DATA:
lbuf = rcv->skb->data;
- do
+ do {
if (plip_receive(nibble_timeout, dev,
&rcv->nibble, &lbuf[rcv->byte]))
return TIMEOUT;
- while (++rcv->byte < rcv->length.h);
- do
+ } while (++rcv->byte < rcv->length.h);
+ do {
rcv->checksum += lbuf[--rcv->byte];
- while (rcv->byte);
+ } while (rcv->byte);
rcv->state = PLIP_PK_CHECKSUM;

case PLIP_PK_CHECKSUM:
@@ -816,14 +816,14 @@ plip_send_packet(struct net_device *dev, struct net_local *nl,
snd->checksum = 0;

case PLIP_PK_DATA:
- do
+ do {
if (plip_send(nibble_timeout, dev,
&snd->nibble, lbuf[snd->byte]))
return TIMEOUT;
- while (++snd->byte < snd->length.h);
- do
+ } while (++snd->byte < snd->length.h);
+ do {
snd->checksum += lbuf[--snd->byte];
- while (snd->byte);
+ } while (snd->byte);
snd->state = PLIP_PK_CHECKSUM;

case PLIP_PK_CHECKSUM:
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c
index 01493a4..8bfc15b 100644
--- a/drivers/net/starfire.c
+++ b/drivers/net/starfire.c
@@ -882,9 +882,9 @@ static int mdio_read(struct net_device *dev, int phy_id, int location)
void __iomem *mdio_addr = np->base + MIICtrl + (phy_id<<7) + (location<<2);
int result, boguscnt=1000;
/* ??? Should we add a busy-wait here? */
- do
+ do {
result = readl(mdio_addr);
- while ((result & 0xC0000000) != 0x80000000 && --boguscnt > 0);
+ } while ((result & 0xC0000000) != 0x80000000 && --boguscnt > 0);
if (boguscnt == 0)
return 0;
if ((result & 0xffff) == 0xffff)

2008-12-22 19:19:16

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 06/27] drivers/net/atlx: fix sparse warnings: make symbols static

Fix this sparse warnings:

drivers/net/atlx/atl1.c:198:16: warning: symbol 'atl1_check_options' was not declared. Should it be static?
drivers/net/atlx/atl1.c:526:5: warning: symbol 'atl1_read_mac_addr' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/atlx/atl1.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/atlx/atl1.c b/drivers/net/atlx/atl1.c
index aef7e47..c0ceee0 100644
--- a/drivers/net/atlx/atl1.c
+++ b/drivers/net/atlx/atl1.c
@@ -195,7 +195,7 @@ static int __devinit atl1_validate_option(int *value, struct atl1_option *opt,
* value exists, a default value is used. The final value is stored
* in a variable in the adapter structure.
*/
-void __devinit atl1_check_options(struct atl1_adapter *adapter)
+static void __devinit atl1_check_options(struct atl1_adapter *adapter)
{
struct pci_dev *pdev = adapter->pdev;
int bd = adapter->bd_number;
@@ -523,7 +523,7 @@ static int atl1_get_permanent_address(struct atl1_hw *hw)
* Reads the adapter's MAC address from the EEPROM
* hw - Struct containing variables accessed by shared code
*/
-s32 atl1_read_mac_addr(struct atl1_hw *hw)
+static s32 atl1_read_mac_addr(struct atl1_hw *hw)
{
u16 i;

2008-12-22 19:18:10

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 05/27] drivers/net/arcnet: fix sparse warnings: make symbols static

Fix this sparse warnings:

drivers/net/arcnet/capmode.c:64:6: warning: symbol 'arcnet_cap_init' was not declared. Should it be static?
drivers/net/arcnet/com90xx.c:586:5: warning: symbol 'com90xx_reset' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/arcnet/capmode.c | 2 +-
drivers/net/arcnet/com90xx.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c
index e544953..30580bb 100644
--- a/drivers/net/arcnet/capmode.c
+++ b/drivers/net/arcnet/capmode.c
@@ -61,7 +61,7 @@ static struct ArcProto capmode_proto =
};


-void arcnet_cap_init(void)
+static void arcnet_cap_init(void)
{
int count;

diff --git a/drivers/net/arcnet/com90xx.c b/drivers/net/arcnet/com90xx.c
index f4113d2..d762fe4 100644
--- a/drivers/net/arcnet/com90xx.c
+++ b/drivers/net/arcnet/com90xx.c
@@ -583,7 +583,7 @@ static void com90xx_setmask(struct net_device *dev, int mask)
*
* However, it does make sure the card is in a defined state.
*/
-int com90xx_reset(struct net_device *dev, int really_reset)
+static int com90xx_reset(struct net_device *dev, int really_reset)
{
struct arcnet_local *lp = netdev_priv(dev);
short ioaddr = dev->base_addr;

2008-12-22 19:19:40

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 07/27] drivers/net/bonding: fix sparse warnings: move decls to header file

Fix this sparse warnings:

drivers/net/bonding/bond_main.c:104:20: warning: symbol 'bonding_defaults' was not declared. Should it be static?
drivers/net/bonding/bond_main.c:204:22: warning: symbol 'ad_select_tbl' was not declared. Should it be static?
drivers/net/bonding/bond_sysfs.c:60:21: warning: symbol 'bonding_rwsem' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/bonding/bond_main.c | 1 -
drivers/net/bonding/bond_sysfs.c | 3 ---
drivers/net/bonding/bonding.h | 5 +++++
3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index a34c186..460c2ca 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -154,7 +154,6 @@ LIST_HEAD(bond_dev_list);
static struct proc_dir_entry *bond_proc_dir = NULL;
#endif

-extern struct rw_semaphore bonding_rwsem;
static __be32 arp_target[BOND_MAX_ARP_TARGETS] = { 0, } ;
static int arp_ip_count = 0;
static int bond_mode = BOND_MODE_ROUNDROBIN;
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 1860f81..18cf478 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -43,9 +43,6 @@

/*---------------------------- Declarations -------------------------------*/

-extern struct bond_params bonding_defaults;
-extern struct bond_parm_tbl ad_select_tbl[];
-
static int expected_refcount = -1;
/*--------------------------- Data Structures -----------------------------*/

diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 31ae5b5..ca849d2 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -350,6 +350,11 @@ extern const struct bond_parm_tbl bond_mode_tbl[];
extern const struct bond_parm_tbl xmit_hashtype_tbl[];
extern const struct bond_parm_tbl arp_validate_tbl[];
extern const struct bond_parm_tbl fail_over_mac_tbl[];
+extern struct bond_params bonding_defaults;
+extern struct bond_parm_tbl ad_select_tbl[];
+
+/* exported from bond_sysfs.c */
+extern struct rw_semaphore bonding_rwsem;

#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
void bond_send_unsolicited_na(struct bonding *bond);

2008-12-22 19:20:34

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 10/27] drivers/net/enic: fix sparse warning: make symbol static

Fix this sparse warning:

drivers/net/enic/vnic_dev.c:288:5: warning: symbol 'vnic_dev_capable' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/enic/vnic_dev.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/enic/vnic_dev.c b/drivers/net/enic/vnic_dev.c
index 08a37b0..1170857 100644
--- a/drivers/net/enic/vnic_dev.c
+++ b/drivers/net/enic/vnic_dev.c
@@ -285,7 +285,7 @@ int vnic_dev_cmd(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd,
return -ETIMEDOUT;
}

-int vnic_dev_capable(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd)
+static int vnic_dev_capable(struct vnic_dev *vdev, enum vnic_devcmd_cmd cmd)
{
u64 a0 = (u32)cmd, a1 = 0;
int wait = 1000;

2008-12-22 19:19:58

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 08/27] drivers/net/cxgb3: comment out dead code

The function 'vsc8211_set_speed_duplex' is not used, so comment it
out. For 'vsc8211_set_automdi' the function 'vsc8211_set_speed_duplex'
is the only caller, so comment it out as well.

Fix this (sparse) warning:

drivers/net/cxgb3/vsc8211.c:269: warning: 'vsc8211_set_automdi' defined but not used
drivers/net/cxgb3/vsc8211.c:295:5: warning: symbol 'vsc8211_set_speed_duplex' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/cxgb3/vsc8211.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/net/cxgb3/vsc8211.c b/drivers/net/cxgb3/vsc8211.c
index 33f956b..d071309 100644
--- a/drivers/net/cxgb3/vsc8211.c
+++ b/drivers/net/cxgb3/vsc8211.c
@@ -262,6 +262,7 @@ static int vsc8211_get_link_status_fiber(struct cphy *cphy, int *link_ok,
return 0;
}

+#ifdef UNUSED
/*
* Enable/disable auto MDI/MDI-X in forced link speed mode.
*/
@@ -301,6 +302,7 @@ int vsc8211_set_speed_duplex(struct cphy *phy, int speed, int duplex)
err = vsc8211_set_automdi(phy, 1);
return err;
}
+#endif /* UNUSED */

static int vsc8211_power_down(struct cphy *cphy, int enable)
{

2008-12-22 19:20:53

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 11/27] drivers/net/igb: remove dead code (function 'igb_read_pci_cfg')

Fix this warning:

drivers/net/igb/e1000_mac.c:54: warning: 'igb_read_pci_cfg' defined but not used

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/igb/e1000_mac.c | 7 -------
1 files changed, 0 insertions(+), 7 deletions(-)

diff --git a/drivers/net/igb/e1000_mac.c b/drivers/net/igb/e1000_mac.c
index 137269d..97f0049 100644
--- a/drivers/net/igb/e1000_mac.c
+++ b/drivers/net/igb/e1000_mac.c
@@ -50,13 +50,6 @@ void igb_remove_device(struct e1000_hw *hw)
kfree(hw->dev_spec);
}

-static void igb_read_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value)
-{
- struct igb_adapter *adapter = hw->back;
-
- pci_read_config_word(adapter->pdev, reg, value);
-}
-
static s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
{
struct igb_adapter *adapter = hw->back;

2008-12-22 19:21:18

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 12/27] drivers/net/irda: fix sparse warnings: make symbols static

Fix this sparse warnings:

drivers/net/irda/ma600-sir.c:239:5: warning: symbol 'ma600_reset' was not declared. Should it be static?
drivers/net/irda/smsc-ircc2.c:875:5: warning: symbol 'smsc_ircc_hard_xmit_sir' was not declared. Should it be static?
drivers/net/irda/smsc-ircc2.c:1131:6: warning: symbol 'smsc_ircc_set_sir_speed' was not declared. Should it be static?
drivers/net/irda/smsc-ircc2.c:1897:6: warning: symbol 'smsc_ircc_sir_start' was not declared. Should it be static?
drivers/net/irda/w83977af_ir.c:150:5: warning: symbol 'w83977af_open' was not declared. Should it be static?
drivers/net/irda/w83977af_ir.c:313:5: warning: symbol 'w83977af_probe' was not declared. Should it be static?
drivers/net/irda/w83977af_ir.c:412:6: warning: symbol 'w83977af_change_speed' was not declared. Should it be static?
drivers/net/irda/w83977af_ir.c:492:5: warning: symbol 'w83977af_hard_xmit' was not declared. Should it be static?
drivers/net/irda/w83977af_ir.c:734:5: warning: symbol 'w83977af_dma_receive' was not declared. Should it be static?
drivers/net/irda/w83977af_ir.c:806:5: warning: symbol 'w83977af_dma_receive_complete' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/irda/ma600-sir.c | 2 +-
drivers/net/irda/smsc-ircc2.c | 6 +++---
drivers/net/irda/w83977af_ir.c | 14 +++++++-------
3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/net/irda/ma600-sir.c b/drivers/net/irda/ma600-sir.c
index 1ceed9c..e912164 100644
--- a/drivers/net/irda/ma600-sir.c
+++ b/drivers/net/irda/ma600-sir.c
@@ -236,7 +236,7 @@ static int ma600_change_speed(struct sir_dev *dev, unsigned speed)
* avoid the state machine complexity before we get things working
*/

-int ma600_reset(struct sir_dev *dev)
+static int ma600_reset(struct sir_dev *dev)
{
IRDA_DEBUG(2, "%s()\n", __func__);

diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c
index b5360fe..5d09e15 100644
--- a/drivers/net/irda/smsc-ircc2.c
+++ b/drivers/net/irda/smsc-ircc2.c
@@ -872,7 +872,7 @@ static void smsc_ircc_timeout(struct net_device *dev)
* waits until the next transmit interrupt, and continues until the
* frame is transmitted.
*/
-int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev)
+static int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev)
{
struct smsc_ircc_cb *self;
unsigned long flags;
@@ -1128,7 +1128,7 @@ static void smsc_ircc_change_speed(struct smsc_ircc_cb *self, u32 speed)
* Set speed of IrDA port to specified baudrate
*
*/
-void smsc_ircc_set_sir_speed(struct smsc_ircc_cb *self, __u32 speed)
+static void smsc_ircc_set_sir_speed(struct smsc_ircc_cb *self, __u32 speed)
{
int iobase;
int fcr; /* FIFO control reg */
@@ -1894,7 +1894,7 @@ static void __exit smsc_ircc_cleanup(void)
* This function *must* be called with spinlock held, because it may
* be called from the irq handler (via smsc_ircc_change_speed()). - Jean II
*/
-void smsc_ircc_sir_start(struct smsc_ircc_cb *self)
+static void smsc_ircc_sir_start(struct smsc_ircc_cb *self)
{
struct net_device *dev;
int fir_base, sir_base;
diff --git a/drivers/net/irda/w83977af_ir.c b/drivers/net/irda/w83977af_ir.c
index 161d591..30ec913 100644
--- a/drivers/net/irda/w83977af_ir.c
+++ b/drivers/net/irda/w83977af_ir.c
@@ -147,8 +147,8 @@ static void __exit w83977af_cleanup(void)
* Open driver instance
*
*/
-int w83977af_open(int i, unsigned int iobase, unsigned int irq,
- unsigned int dma)
+static int w83977af_open(int i, unsigned int iobase, unsigned int irq,
+ unsigned int dma)
{
struct net_device *dev;
struct w83977af_ir *self;
@@ -310,7 +310,7 @@ static int w83977af_close(struct w83977af_ir *self)
return 0;
}

-int w83977af_probe( int iobase, int irq, int dma)
+static int w83977af_probe(int iobase, int irq, int dma)
{
int version;
int i;
@@ -409,7 +409,7 @@ int w83977af_probe( int iobase, int irq, int dma)
return -1;
}

-void w83977af_change_speed(struct w83977af_ir *self, __u32 speed)
+static void w83977af_change_speed(struct w83977af_ir *self, __u32 speed)
{
int ir_mode = HCR_SIR;
int iobase;
@@ -489,7 +489,7 @@ void w83977af_change_speed(struct w83977af_ir *self, __u32 speed)
* Sets up a DMA transfer to send the current frame.
*
*/
-int w83977af_hard_xmit(struct sk_buff *skb, struct net_device *dev)
+static int w83977af_hard_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct w83977af_ir *self;
__s32 speed;
@@ -731,7 +731,7 @@ static void w83977af_dma_xmit_complete(struct w83977af_ir *self)
* if it starts to receive a frame.
*
*/
-int w83977af_dma_receive(struct w83977af_ir *self)
+static int w83977af_dma_receive(struct w83977af_ir *self)
{
int iobase;
__u8 set;
@@ -803,7 +803,7 @@ int w83977af_dma_receive(struct w83977af_ir *self)
* Finished with receiving a frame
*
*/
-int w83977af_dma_receive_complete(struct w83977af_ir *self)
+static int w83977af_dma_receive_complete(struct w83977af_ir *self)
{
struct sk_buff *skb;
struct st_fifo *st_fifo;

2008-12-22 19:21:33

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 13/27] drivers/net/ixgbe: fix sparse warnings: make symbols static

Fix this sparse warnings:

drivers/net/ixgbe/ixgbe_82598.c:180:5: warning: symbol 'ixgbe_get_copper_link_capabilities_82598' was not declared. Should it be static?
drivers/net/ixgbe/ixgbe_82598.c:245:5: warning: symbol 'ixgbe_setup_fc_82598' was not declared. Should it be static?
drivers/net/ixgbe/ixgbe_82598.c:729:5: warning: symbol 'ixgbe_set_vmdq_82598' was not declared. Should it be static?
drivers/net/ixgbe/ixgbe_82598.c:773:5: warning: symbol 'ixgbe_set_vfta_82598' was not declared. Should it be static?
drivers/net/ixgbe/ixgbe_82598.c:897:5: warning: symbol 'ixgbe_read_analog_reg8_82598' was not declared. Should it be static?
drivers/net/ixgbe/ixgbe_82598.c:919:5: warning: symbol 'ixgbe_write_analog_reg8_82598' was not declared. Should it be static?
drivers/net/ixgbe/ixgbe_82598.c:940:5: warning: symbol 'ixgbe_read_i2c_eeprom_82598' was not declared. Should it be static?
drivers/net/ixgbe/ixgbe_82598.c:1000:5: warning: symbol 'ixgbe_get_supported_physical_layer_82598' was not declared. Should it be static?
drivers/net/ixgbe/ixgbe_dcb_82598.c:100:5: warning: symbol 'ixgbe_dcb_config_packet_buffers_82598' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/ixgbe/ixgbe_82598.c | 24 ++++++++++++------------
drivers/net/ixgbe/ixgbe_dcb_82598.c | 4 ++--
2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ixgbe/ixgbe_82598.c b/drivers/net/ixgbe/ixgbe_82598.c
index 7e09dab..ad5699d 100644
--- a/drivers/net/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ixgbe/ixgbe_82598.c
@@ -177,9 +177,9 @@ static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
*
* Determines the link capabilities by reading the AUTOC register.
**/
-s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw,
- ixgbe_link_speed *speed,
- bool *autoneg)
+static s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw,
+ ixgbe_link_speed *speed,
+ bool *autoneg)
{
s32 status = IXGBE_ERR_LINK_SETUP;
u16 speed_ability;
@@ -242,7 +242,7 @@ static enum ixgbe_media_type ixgbe_get_media_type_82598(struct ixgbe_hw *hw)
* Configures the flow control settings based on SW configuration. This
* function is used for 802.3x flow control configuration only.
**/
-s32 ixgbe_setup_fc_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
+static s32 ixgbe_setup_fc_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
{
u32 frctl_reg;
u32 rmcs_reg;
@@ -726,7 +726,7 @@ static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
* @rar: receive address register index to associate with a VMDq index
* @vmdq: VMDq set index
**/
-s32 ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
+static s32 ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
{
u32 rar_high;

@@ -770,8 +770,8 @@ static s32 ixgbe_clear_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
*
* Turn on/off specified VLAN in the VLAN filter table.
**/
-s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind,
- bool vlan_on)
+static s32 ixgbe_set_vfta_82598(struct ixgbe_hw *hw, u32 vlan, u32 vind,
+ bool vlan_on)
{
u32 regindex;
u32 bitindex;
@@ -894,7 +894,7 @@ static s32 ixgbe_blink_led_stop_82598(struct ixgbe_hw *hw, u32 index)
*
* Performs read operation to Atlas analog register specified.
**/
-s32 ixgbe_read_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 *val)
+static s32 ixgbe_read_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 *val)
{
u32 atlas_ctl;

@@ -916,7 +916,7 @@ s32 ixgbe_read_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 *val)
*
* Performs write operation to Atlas analog register specified.
**/
-s32 ixgbe_write_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 val)
+static s32 ixgbe_write_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 val)
{
u32 atlas_ctl;

@@ -937,8 +937,8 @@ s32 ixgbe_write_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 val)
*
* Performs byte read operation to SFP module's EEPROM over I2C interface.
**/
-s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
- u8 *eeprom_data)
+static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
+ u8 *eeprom_data)
{
s32 status = 0;
u16 sfp_addr = 0;
@@ -997,7 +997,7 @@ out:
*
* Determines physical layer capabilities of the current configuration.
**/
-s32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw)
+static s32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw)
{
s32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;

diff --git a/drivers/net/ixgbe/ixgbe_dcb_82598.c b/drivers/net/ixgbe/ixgbe_dcb_82598.c
index fce6867..2c046b0 100644
--- a/drivers/net/ixgbe/ixgbe_dcb_82598.c
+++ b/drivers/net/ixgbe/ixgbe_dcb_82598.c
@@ -97,8 +97,8 @@ s32 ixgbe_dcb_get_pfc_stats_82598(struct ixgbe_hw *hw,
*
* Configure packet buffers for DCB mode.
*/
-s32 ixgbe_dcb_config_packet_buffers_82598(struct ixgbe_hw *hw,
- struct ixgbe_dcb_config *dcb_config)
+static s32 ixgbe_dcb_config_packet_buffers_82598(struct ixgbe_hw *hw,
+ struct ixgbe_dcb_config *dcb_config)
{
s32 ret_val = 0;
u32 value = IXGBE_RXPBSIZE_64KB;

2008-12-22 19:21:51

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 14/27] drivers/net/netxen: fix sparse warnings: use NULL pointer instead of plain integer

Fix this sparse warnings:

drivers/net/netxen/netxen_nic_hw.c:1462:18: warning: Using plain integer as NULL pointer
drivers/net/netxen/netxen_nic_hw.c:1536:18: warning: Using plain integer as NULL pointer

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/netxen/netxen_nic_hw.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c
index 86379fd..aa6e603 100644
--- a/drivers/net/netxen/netxen_nic_hw.c
+++ b/drivers/net/netxen/netxen_nic_hw.c
@@ -1459,7 +1459,7 @@ static int netxen_nic_pci_mem_read_direct(struct netxen_adapter *adapter,
mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE * 2);
else
mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE);
- if (mem_ptr == 0UL) {
+ if (mem_ptr == NULL) {
*(uint8_t *)data = 0;
return -1;
}
@@ -1533,7 +1533,7 @@ netxen_nic_pci_mem_write_direct(struct netxen_adapter *adapter, u64 off,
mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE*2);
else
mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE);
- if (mem_ptr == 0UL)
+ if (mem_ptr == NULL)
return -1;
addr = mem_ptr;
addr += start & (PAGE_SIZE - 1);

2008-12-22 19:22:16

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 15/27] drivers/net/qlge: fix sparse warnings: make symbols static

Fix this sparse warnings:

drivers/net/qlge/qlge_ethtool.c:100:6: warning: symbol 'ql_update_stats' was not declared. Should it be static?
drivers/net/qlge/qlge_mpi.c:22:5: warning: symbol 'ql_get_mb_sts' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/qlge/qlge_ethtool.c | 2 +-
drivers/net/qlge/qlge_mpi.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/qlge/qlge_ethtool.c b/drivers/net/qlge/qlge_ethtool.c
index b62fbd4..eefb81b 100644
--- a/drivers/net/qlge/qlge_ethtool.c
+++ b/drivers/net/qlge/qlge_ethtool.c
@@ -97,7 +97,7 @@ exit:
return status;
}

-void ql_update_stats(struct ql_adapter *qdev)
+static void ql_update_stats(struct ql_adapter *qdev)
{
u32 i;
u64 data;
diff --git a/drivers/net/qlge/qlge_mpi.c b/drivers/net/qlge/qlge_mpi.c
index 24fe344..fa31891 100644
--- a/drivers/net/qlge/qlge_mpi.c
+++ b/drivers/net/qlge/qlge_mpi.c
@@ -19,7 +19,7 @@ exit:
return status;
}

-int ql_get_mb_sts(struct ql_adapter *qdev, struct mbox_params *mbcp)
+static int ql_get_mb_sts(struct ql_adapter *qdev, struct mbox_params *mbcp)
{
int i, status;

2008-12-22 19:22:37

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 16/27] drivers/net/skfp: fix sparse warnings: make symbols static

Fix this sparse warnings:

drivers/net/skfp/skfddi.c:620:13: warning: symbol 'skfp_interrupt' was not declared. Should it be static?
drivers/net/skfp/skfddi.c:687:25: warning: symbol 'skfp_ctl_get_stats' was not declared. Should it be static?
drivers/net/skfp/skfddi.c:1232:6: warning: symbol 'CheckSourceAddress' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/skfp/skfddi.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/skfp/skfddi.c b/drivers/net/skfp/skfddi.c
index 7fbd4f8..607efea 100644
--- a/drivers/net/skfp/skfddi.c
+++ b/drivers/net/skfp/skfddi.c
@@ -617,7 +617,7 @@ static int skfp_close(struct net_device *dev)
* Interrupts are disabled, then reenabled at the adapter.
*/

-irqreturn_t skfp_interrupt(int irq, void *dev_id)
+static irqreturn_t skfp_interrupt(int irq, void *dev_id)
{
struct net_device *dev = dev_id;
struct s_smc *smc; /* private board structure pointer */
@@ -684,7 +684,7 @@ irqreturn_t skfp_interrupt(int irq, void *dev_id)
* independent.
*
*/
-struct net_device_stats *skfp_ctl_get_stats(struct net_device *dev)
+static struct net_device_stats *skfp_ctl_get_stats(struct net_device *dev)
{
struct s_smc *bp = netdev_priv(dev);

@@ -1229,7 +1229,7 @@ static void send_queued_packets(struct s_smc *smc)
* Verify if the source address is set. Insert it if necessary.
*
************************/
-void CheckSourceAddress(unsigned char *frame, unsigned char *hw_addr)
+static void CheckSourceAddress(unsigned char *frame, unsigned char *hw_addr)
{
unsigned char SRBit;

2008-12-22 19:22:53

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 17/27] drivers/net/tokenring: fix sparse warnings: make symbols static

Fix this sparse warnings:

drivers/net/tokenring/ibmtr.c:1840:6: warning: symbol 'tok_rerun' was not declared. Should it be static?
drivers/net/tokenring/madgemc.c:469:16: warning: symbol 'madgemc_setnselout_pins' was not declared. Should it be static?
drivers/net/tokenring/proteon.c:286:16: warning: symbol 'proteon_setnselout_pins' was not declared. Should it be static?
drivers/net/tokenring/skisa.c:303:16: warning: symbol 'sk_isa_setnselout_pins' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/tokenring/ibmtr.c | 4 ++--
drivers/net/tokenring/madgemc.c | 2 +-
drivers/net/tokenring/proteon.c | 2 +-
drivers/net/tokenring/skisa.c | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c
index 9fd0993..fa7bce6 100644
--- a/drivers/net/tokenring/ibmtr.c
+++ b/drivers/net/tokenring/ibmtr.c
@@ -1837,8 +1837,8 @@ static void ibmtr_reset_timer(struct timer_list *tmr, struct net_device *dev)

/*****************************************************************************/

-void tok_rerun(unsigned long dev_addr){
-
+static void tok_rerun(unsigned long dev_addr)
+{
struct net_device *dev = (struct net_device *)dev_addr;
struct tok_info *ti = netdev_priv(dev);

diff --git a/drivers/net/tokenring/madgemc.c b/drivers/net/tokenring/madgemc.c
index 0ba6f0b..917b4d2 100644
--- a/drivers/net/tokenring/madgemc.c
+++ b/drivers/net/tokenring/madgemc.c
@@ -466,7 +466,7 @@ static irqreturn_t madgemc_interrupt(int irq, void *dev_id)
* zero to leave the TMS NSELOUT bits unaffected.
*
*/
-unsigned short madgemc_setnselout_pins(struct net_device *dev)
+static unsigned short madgemc_setnselout_pins(struct net_device *dev)
{
unsigned char reg1;
struct net_local *tp = netdev_priv(dev);
diff --git a/drivers/net/tokenring/proteon.c b/drivers/net/tokenring/proteon.c
index cd2d62f..b8c955f 100644
--- a/drivers/net/tokenring/proteon.c
+++ b/drivers/net/tokenring/proteon.c
@@ -283,7 +283,7 @@ static void proteon_read_eeprom(struct net_device *dev)
dev->dev_addr[i] = proteon_sifreadw(dev, SIFINC) >> 8;
}

-unsigned short proteon_setnselout_pins(struct net_device *dev)
+static unsigned short proteon_setnselout_pins(struct net_device *dev)
{
return 0;
}
diff --git a/drivers/net/tokenring/skisa.c b/drivers/net/tokenring/skisa.c
index b578744..c0f58f0 100644
--- a/drivers/net/tokenring/skisa.c
+++ b/drivers/net/tokenring/skisa.c
@@ -300,7 +300,7 @@ static void sk_isa_read_eeprom(struct net_device *dev)
dev->dev_addr[i] = sk_isa_sifreadw(dev, SIFINC) >> 8;
}

-unsigned short sk_isa_setnselout_pins(struct net_device *dev)
+static unsigned short sk_isa_setnselout_pins(struct net_device *dev)
{
return 0;
}

2008-12-22 19:23:20

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 18/27] drivers/net/tulip: fix sparse warnings: make do-while a compound statement

Fix this sparse warnings:

drivers/net/tulip/de2104x.c:1695:4: warning: do-while statement is not a compound statement
drivers/net/tulip/tulip_core.c:1433:5: warning: do-while statement is not a compound statement

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/tulip/de2104x.c | 4 ++--
drivers/net/tulip/tulip_core.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index 3aa60fa..5166be9 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -1691,9 +1691,9 @@ static void __devinit de21040_get_mac_address (struct de_private *de)

for (i = 0; i < 6; i++) {
int value, boguscnt = 100000;
- do
+ do {
value = dr32(ROMCmd);
- while (value < 0 && --boguscnt > 0);
+ } while (value < 0 && --boguscnt > 0);
de->dev->dev_addr[i] = value;
udelay(1);
if (boguscnt <= 0)
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index 1c5ef23..ff84bab 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -1429,9 +1429,9 @@ static int __devinit tulip_init_one (struct pci_dev *pdev,
for (i = 0; i < 3; i++) {
int value, boguscnt = 100000;
iowrite32(0x600 | i, ioaddr + 0x98);
- do
+ do {
value = ioread32(ioaddr + CSR9);
- while (value < 0 && --boguscnt > 0);
+ } while (value < 0 && --boguscnt > 0);
put_unaligned_le16(value, ((__le16 *)dev->dev_addr) + i);
sum += value & 0xffff;
}

2008-12-22 19:23:37

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 19/27] drivers/net/usb: fix sparse warnings: make symbols static

Fix this sparse warnings:

drivers/net/usb/hso.c:1249:6: warning: symbol 'hso_unthrottle_tasklet' was not declared. Should it be static?
drivers/net/usb/hso.c:1268:6: warning: symbol 'hso_unthrottle_workfunc' was not declared. Should it be static?
drivers/net/usb/hso.c:1466:5: warning: symbol 'tiocmget_submit_urb' was not declared. Should it be static?
drivers/net/usb/smsc95xx.c:62:5: warning: symbol 'turbo_mode' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/usb/hso.c | 10 +++++-----
drivers/net/usb/smsc95xx.c | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 2d41a10..1a09288 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -1246,7 +1246,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
* This needs to be a tasklet otherwise we will
* end up recursively calling this function.
*/
-void hso_unthrottle_tasklet(struct hso_serial *serial)
+static void hso_unthrottle_tasklet(struct hso_serial *serial)
{
unsigned long flags;

@@ -1265,7 +1265,7 @@ static void hso_unthrottle(struct tty_struct *tty)
tasklet_hi_schedule(&serial->unthrottle_tasklet);
}

-void hso_unthrottle_workfunc(struct work_struct *work)
+static void hso_unthrottle_workfunc(struct work_struct *work)
{
struct hso_serial *serial =
container_of(work, struct hso_serial,
@@ -1463,9 +1463,9 @@ static int hso_serial_chars_in_buffer(struct tty_struct *tty)

return chars;
}
-int tiocmget_submit_urb(struct hso_serial *serial,
- struct hso_tiocmget *tiocmget,
- struct usb_device *usb)
+static int tiocmget_submit_urb(struct hso_serial *serial,
+ struct hso_tiocmget *tiocmget,
+ struct usb_device *usb)
{
int result;

diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index fed22ff..111a365 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -59,7 +59,7 @@ struct usb_context {
struct usbnet *dev;
};

-int turbo_mode = true;
+static int turbo_mode = true;
module_param(turbo_mode, bool, 0644);
MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction");

2008-12-22 19:23:52

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 21/27] drivers/net/wan: fix sparse warning: make symbol static

Fix this sparse warning:

drivers/net/wan/x25_asy.c:623:5: warning: symbol 'x25_asy_esc' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/wan/x25_asy.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index 472bd0e..e6e2ce3 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -620,7 +620,7 @@ static struct net_device_stats *x25_asy_get_stats(struct net_device *dev)
* STANDARD X.25 ENCAPSULATION *
************************************************************************/

-int x25_asy_esc(unsigned char *s, unsigned char *d, int len)
+static int x25_asy_esc(unsigned char *s, unsigned char *d, int len)
{
unsigned char *ptr = d;
unsigned char c;

2008-12-22 19:24:16

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 22/27] drivers/net/wan/z85230.c: fix sparse warnings: un-EXPORT symbols

The symbols are only references within the translation unit they are
defined in, so un-EXPORT them und make them 'static'.

Fix this sparse warnings:

drivers/net/wan/z85230.c:604:25: warning: symbol 'z8530_dma_sync' was not declared. Should it be static?
drivers/net/wan/z85230.c:613:25: warning: symbol 'z8530_txdma_sync' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/wan/z85230.c | 10 ++--------
1 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wan/z85230.c b/drivers/net/wan/z85230.c
index d7bf53a..3d00971 100644
--- a/drivers/net/wan/z85230.c
+++ b/drivers/net/wan/z85230.c
@@ -601,24 +601,18 @@ static void z8530_dma_status(struct z8530_channel *chan)
write_zsctrl(chan, RES_H_IUS);
}

-struct z8530_irqhandler z8530_dma_sync=
-{
+static struct z8530_irqhandler z8530_dma_sync = {
z8530_dma_rx,
z8530_dma_tx,
z8530_dma_status
};

-EXPORT_SYMBOL(z8530_dma_sync);
-
-struct z8530_irqhandler z8530_txdma_sync=
-{
+static struct z8530_irqhandler z8530_txdma_sync = {
z8530_rx,
z8530_dma_tx,
z8530_dma_status
};

-EXPORT_SYMBOL(z8530_txdma_sync);
-
/**
* z8530_rx_clear - Handle RX events from a stopped chip
* @c: Z8530 channel to shut up

2008-12-22 19:24:57

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 24/27] drivers/net/wireless/ath9k: fix sparse warnings: make symbols static

Fix this sparse warnings:

drivers/net/wireless/ath9k/eeprom.c:195:6: warning: symbol 'ath9k_fill_eeprom' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:463:5: warning: symbol 'ath9k_check_eeprom' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:1219:6: warning: symbol 'ath9k_hw_set_def_power_per_rate_table' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:1510:6: warning: symbol 'ath9k_hw_set_4k_power_per_rate_table' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:2007:5: warning: symbol 'ath9k_set_txpower' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:2106:6: warning: symbol 'ath9k_set_addac' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:2543:6: warning: symbol 'ath9k_eeprom_set_board_values' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:2606:5: warning: symbol 'ath9k_get_eeprom_antenna_cfg' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:2622:4: warning: symbol 'ath9k_hw_get_4k_num_ant_config' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:2628:4: warning: symbol 'ath9k_hw_get_def_num_ant_config' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:2647:4: warning: symbol 'ath9k_get_num_ant_config' was not declared. Should it be static?
drivers/net/wireless/ath9k/eeprom.c:2790:5: warning: symbol 'ath9k_get_eeprom' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/wireless/ath9k/eeprom.c | 62 ++++++++++++++++++-----------------
1 files changed, 32 insertions(+), 30 deletions(-)

diff --git a/drivers/net/wireless/ath9k/eeprom.c b/drivers/net/wireless/ath9k/eeprom.c
index 14f8d40..acd6c53 100644
--- a/drivers/net/wireless/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath9k/eeprom.c
@@ -192,7 +192,7 @@ static bool ath9k_hw_fill_def_eeprom(struct ath_hal *ah)
#undef SIZE_EEPROM_DEF
}

-bool (*ath9k_fill_eeprom[]) (struct ath_hal *) = {
+static bool (*ath9k_fill_eeprom[]) (struct ath_hal *) = {
ath9k_hw_fill_def_eeprom,
ath9k_hw_fill_4k_eeprom
};
@@ -460,7 +460,7 @@ static int ath9k_hw_check_4k_eeprom(struct ath_hal *ah)
#undef EEPROM_4K_SIZE
}

-int (*ath9k_check_eeprom[]) (struct ath_hal *) = {
+static int (*ath9k_check_eeprom[]) (struct ath_hal *) = {
ath9k_hw_check_def_eeprom,
ath9k_hw_check_4k_eeprom
};
@@ -1216,13 +1216,13 @@ static bool ath9k_hw_set_4k_power_cal_table(struct ath_hal *ah,
return true;
}

-bool ath9k_hw_set_def_power_per_rate_table(struct ath_hal *ah,
- struct ath9k_channel *chan,
- int16_t *ratesArray,
- u16 cfgCtl,
- u16 AntennaReduction,
- u16 twiceMaxRegulatoryPower,
- u16 powerLimit)
+static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hal *ah,
+ struct ath9k_channel *chan,
+ int16_t *ratesArray,
+ u16 cfgCtl,
+ u16 AntennaReduction,
+ u16 twiceMaxRegulatoryPower,
+ u16 powerLimit)
{
#define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6 /* 10*log10(2)*2 */
#define REDUCE_SCALED_POWER_BY_THREE_CHAIN 10 /* 10*log10(3)*2 */
@@ -1507,13 +1507,13 @@ bool ath9k_hw_set_def_power_per_rate_table(struct ath_hal *ah,
return true;
}

-bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hal *ah,
- struct ath9k_channel *chan,
- int16_t *ratesArray,
- u16 cfgCtl,
- u16 AntennaReduction,
- u16 twiceMaxRegulatoryPower,
- u16 powerLimit)
+static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hal *ah,
+ struct ath9k_channel *chan,
+ int16_t *ratesArray,
+ u16 cfgCtl,
+ u16 AntennaReduction,
+ u16 twiceMaxRegulatoryPower,
+ u16 powerLimit)
{
struct ath_hal_5416 *ahp = AH5416(ah);
struct ar5416_eeprom_4k *pEepData = &ahp->ah_eeprom.map4k;
@@ -2004,9 +2004,9 @@ static int ath9k_hw_4k_set_txpower(struct ath_hal *ah,
return 0;
}

-int (*ath9k_set_txpower[]) (struct ath_hal *,
- struct ath9k_channel *,
- u16, u8, u8, u8) = {
+static int (*ath9k_set_txpower[]) (struct ath_hal *,
+ struct ath9k_channel *,
+ u16, u8, u8, u8) = {
ath9k_hw_def_set_txpower,
ath9k_hw_4k_set_txpower
};
@@ -2103,7 +2103,7 @@ static void ath9k_hw_set_4k_addac(struct ath_hal *ah,
}
}

-void (*ath9k_set_addac[]) (struct ath_hal *, struct ath9k_channel *) = {
+static void (*ath9k_set_addac[]) (struct ath_hal *, struct ath9k_channel *) = {
ath9k_hw_set_def_addac,
ath9k_hw_set_4k_addac
};
@@ -2540,8 +2540,8 @@ static bool ath9k_hw_eeprom_set_4k_board_values(struct ath_hal *ah,
return true;
}

-bool (*ath9k_eeprom_set_board_values[])(struct ath_hal *,
- struct ath9k_channel *) = {
+static bool (*ath9k_eeprom_set_board_values[])(struct ath_hal *,
+ struct ath9k_channel *) = {
ath9k_hw_eeprom_set_def_board_values,
ath9k_hw_eeprom_set_4k_board_values
};
@@ -2603,8 +2603,9 @@ static int ath9k_hw_get_4k_eeprom_antenna_cfg(struct ath_hal *ah,
return -EINVAL;
}

-int (*ath9k_get_eeprom_antenna_cfg[])(struct ath_hal *, struct ath9k_channel *,
- u8, u16 *) = {
+static int (*ath9k_get_eeprom_antenna_cfg[])(struct ath_hal *,
+ struct ath9k_channel *,
+ u8, u16 *) = {
ath9k_hw_get_def_eeprom_antenna_cfg,
ath9k_hw_get_4k_eeprom_antenna_cfg
};
@@ -2619,14 +2620,14 @@ int ath9k_hw_get_eeprom_antenna_cfg(struct ath_hal *ah,
index, config);
}

-u8 ath9k_hw_get_4k_num_ant_config(struct ath_hal *ah,
- enum ieee80211_band freq_band)
+static u8 ath9k_hw_get_4k_num_ant_config(struct ath_hal *ah,
+ enum ieee80211_band freq_band)
{
return 1;
}

-u8 ath9k_hw_get_def_num_ant_config(struct ath_hal *ah,
- enum ieee80211_band freq_band)
+static u8 ath9k_hw_get_def_num_ant_config(struct ath_hal *ah,
+ enum ieee80211_band freq_band)
{
struct ath_hal_5416 *ahp = AH5416(ah);
struct ar5416_eeprom_def *eep = &ahp->ah_eeprom.def;
@@ -2644,7 +2645,8 @@ u8 ath9k_hw_get_def_num_ant_config(struct ath_hal *ah,
return num_ant_config;
}

-u8 (*ath9k_get_num_ant_config[])(struct ath_hal *, enum ieee80211_band) = {
+static u8 (*ath9k_get_num_ant_config[])(struct ath_hal *,
+ enum ieee80211_band) = {
ath9k_hw_get_def_num_ant_config,
ath9k_hw_get_4k_num_ant_config
};
@@ -2787,7 +2789,7 @@ static u32 ath9k_hw_get_eeprom_def(struct ath_hal *ah,
}
}

-u32 (*ath9k_get_eeprom[])(struct ath_hal *, enum eeprom_param) = {
+static u32 (*ath9k_get_eeprom[])(struct ath_hal *, enum eeprom_param) = {
ath9k_hw_get_eeprom_def,
ath9k_hw_get_eeprom_4k
};

2008-12-22 19:24:39

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 23/27] drivers/net/wireless: fix sparse warnings: make symbols static

Fix this sparse warnings:

drivers/net/wireless/airo.c:3610:6: warning: symbol 'mpi_receive_802_11' was not declared. Should it be static?
drivers/net/wireless/atmel.c:3183:6: warning: symbol 'atmel_join_bss' was not declared. Should it be static?
drivers/net/wireless/ray_cs.c:831:5: warning: symbol 'ray_dev_init' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/wireless/airo.c | 2 +-
drivers/net/wireless/atmel.c | 2 +-
drivers/net/wireless/ray_cs.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index 67d504e..fc4322c 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -3607,7 +3607,7 @@ badrx:
}
}

-void mpi_receive_802_11 (struct airo_info *ai)
+static void mpi_receive_802_11(struct airo_info *ai)
{
RxFid rxd;
struct sk_buff *skb = NULL;
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 3962b55..350157f 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -3180,7 +3180,7 @@ static void associate(struct atmel_private *priv, u16 frame_len, u16 subtype)
}
}

-void atmel_join_bss(struct atmel_private *priv, int bss_index)
+static void atmel_join_bss(struct atmel_private *priv, int bss_index)
{
struct bss_info *bss = &priv->BSSinfo[bss_index];

diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 81b71f0..99ec7d6 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -828,7 +828,7 @@ static int ray_resume(struct pcmcia_device *link)
}

/*===========================================================================*/
-int ray_dev_init(struct net_device *dev)
+static int ray_dev_init(struct net_device *dev)
{
#ifdef RAY_IMMEDIATE_INIT
int i;

2008-12-22 19:25:24

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 25/27] drivers/net/wireless/b43: fix sparse warnings: make symbols static

Fix this sparse warnings:

drivers/net/wireless/b43/phy_a.c:80:6: warning: symbol 'b43_radio_set_tx_iq' was not declared. Should it be static?
drivers/net/wireless/b43/phy_a.c:150:6: warning: symbol 'b43_radio_init2060' was not declared. Should it be static?
drivers/net/wireless/b43/phy_g.c:57:10: warning: symbol 'b43_radio_channel_codes_bg' was not declared. Should it be static?
drivers/net/wireless/b43/phy_g.c:218:6: warning: symbol 'b43_set_txpower_g' was not declared. Should it be static?
drivers/net/wireless/b43/phy_g.c:386:6: warning: symbol 'b43_nrssi_hw_write' was not declared. Should it be static?
drivers/net/wireless/b43/phy_g.c:393:5: warning: symbol 'b43_nrssi_hw_read' was not declared. Should it be static?
drivers/net/wireless/b43/phy_g.c:404:6: warning: symbol 'b43_nrssi_hw_update' was not declared. Should it be static?
drivers/net/wireless/b43/phy_g.c:418:6: warning: symbol 'b43_nrssi_mem_update' was not declared. Should it be static?
drivers/net/wireless/b43/phy_g.c:592:6: warning: symbol 'b43_calc_nrssi_slope' was not declared. Should it be static?
drivers/net/wireless/b43/phy_g.c:1357:5: warning: symbol 'b43_radio_init2050' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/wireless/b43/phy_a.c | 4 ++--
drivers/net/wireless/b43/phy_g.c | 20 ++++++++++----------
2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/net/wireless/b43/phy_a.c b/drivers/net/wireless/b43/phy_a.c
index 0f1a84c..7fe9d17 100644
--- a/drivers/net/wireless/b43/phy_a.c
+++ b/drivers/net/wireless/b43/phy_a.c
@@ -77,7 +77,7 @@ static s8 b43_aphy_estimate_power_out(struct b43_wldev *dev, s8 tssi)
}
#endif

-void b43_radio_set_tx_iq(struct b43_wldev *dev)
+static void b43_radio_set_tx_iq(struct b43_wldev *dev)
{
static const u8 data_high[5] = { 0x00, 0x40, 0x80, 0x90, 0xD0 };
static const u8 data_low[5] = { 0x00, 0x01, 0x05, 0x06, 0x0A };
@@ -147,7 +147,7 @@ static void aphy_channel_switch(struct b43_wldev *dev, unsigned int channel)
//FIXME b43_phy_xmitpower(dev);
}

-void b43_radio_init2060(struct b43_wldev *dev)
+static void b43_radio_init2060(struct b43_wldev *dev)
{
b43_radio_write16(dev, 0x0004, 0x00C0);
b43_radio_write16(dev, 0x0005, 0x0008);
diff --git a/drivers/net/wireless/b43/phy_g.c b/drivers/net/wireless/b43/phy_g.c
index 232181f..9fc354c 100644
--- a/drivers/net/wireless/b43/phy_g.c
+++ b/drivers/net/wireless/b43/phy_g.c
@@ -54,7 +54,7 @@ static const s8 b43_tssi2dbm_g_table[] = {
-20, -20, -20, -20,
};

-const u8 b43_radio_channel_codes_bg[] = {
+static const u8 b43_radio_channel_codes_bg[] = {
12, 17, 22, 27,
32, 37, 42, 47,
52, 57, 62, 67,
@@ -215,9 +215,9 @@ void b43_gphy_set_baseband_attenuation(struct b43_wldev *dev,
}

/* Adjust the transmission power output (G-PHY) */
-void b43_set_txpower_g(struct b43_wldev *dev,
- const struct b43_bbatt *bbatt,
- const struct b43_rfatt *rfatt, u8 tx_control)
+static void b43_set_txpower_g(struct b43_wldev *dev,
+ const struct b43_bbatt *bbatt,
+ const struct b43_rfatt *rfatt, u8 tx_control)
{
struct b43_phy *phy = &dev->phy;
struct b43_phy_g *gphy = phy->g;
@@ -383,14 +383,14 @@ static void b43_set_original_gains(struct b43_wldev *dev)
}

/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */
-void b43_nrssi_hw_write(struct b43_wldev *dev, u16 offset, s16 val)
+static void b43_nrssi_hw_write(struct b43_wldev *dev, u16 offset, s16 val)
{
b43_phy_write(dev, B43_PHY_NRSSILT_CTRL, offset);
b43_phy_write(dev, B43_PHY_NRSSILT_DATA, (u16) val);
}

/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */
-s16 b43_nrssi_hw_read(struct b43_wldev *dev, u16 offset)
+static s16 b43_nrssi_hw_read(struct b43_wldev *dev, u16 offset)
{
u16 val;

@@ -401,7 +401,7 @@ s16 b43_nrssi_hw_read(struct b43_wldev *dev, u16 offset)
}

/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */
-void b43_nrssi_hw_update(struct b43_wldev *dev, u16 val)
+static void b43_nrssi_hw_update(struct b43_wldev *dev, u16 val)
{
u16 i;
s16 tmp;
@@ -415,7 +415,7 @@ void b43_nrssi_hw_update(struct b43_wldev *dev, u16 val)
}

/* http://bcm-specs.sipsolutions.net/NRSSILookupTable */
-void b43_nrssi_mem_update(struct b43_wldev *dev)
+static void b43_nrssi_mem_update(struct b43_wldev *dev)
{
struct b43_phy_g *gphy = dev->phy.g;
s16 i, delta;
@@ -589,7 +589,7 @@ static void b43_calc_nrssi_offset(struct b43_wldev *dev)
b43_phy_write(dev, 0x0811, backup[1]);
}

-void b43_calc_nrssi_slope(struct b43_wldev *dev)
+static void b43_calc_nrssi_slope(struct b43_wldev *dev)
{
struct b43_phy *phy = &dev->phy;
struct b43_phy_g *gphy = phy->g;
@@ -1354,7 +1354,7 @@ struct init2050_saved_values {
u16 phy_syncctl;
};

-u16 b43_radio_init2050(struct b43_wldev *dev)
+static u16 b43_radio_init2050(struct b43_wldev *dev)
{
struct b43_phy *phy = &dev->phy;
struct init2050_saved_values sav;

2008-12-22 19:25:48

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 26/27] drivers/net/wireless/ipw2x00: fix sparse warnings: make symbols static

Fix this sparse warnings:

drivers/net/wireless/ipw2x00/ipw2100.c:5271:6: warning: symbol 'ipw2100_queues_initialize' was not declared. Should it be static?
drivers/net/wireless/ipw2x00/ipw2100.c:5278:6: warning: symbol 'ipw2100_queues_free' was not declared. Should it be static?
drivers/net/wireless/ipw2x00/ipw2100.c:5285:5: warning: symbol 'ipw2100_queues_allocate' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/wireless/ipw2x00/ipw2100.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c
index 2d2044d..1667065 100644
--- a/drivers/net/wireless/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/ipw2x00/ipw2100.c
@@ -5268,21 +5268,21 @@ static int ipw2100_set_ibss_beacon_interval(struct ipw2100_priv *priv,
return 0;
}

-void ipw2100_queues_initialize(struct ipw2100_priv *priv)
+static void ipw2100_queues_initialize(struct ipw2100_priv *priv)
{
ipw2100_tx_initialize(priv);
ipw2100_rx_initialize(priv);
ipw2100_msg_initialize(priv);
}

-void ipw2100_queues_free(struct ipw2100_priv *priv)
+static void ipw2100_queues_free(struct ipw2100_priv *priv)
{
ipw2100_tx_free(priv);
ipw2100_rx_free(priv);
ipw2100_msg_free(priv);
}

-int ipw2100_queues_allocate(struct ipw2100_priv *priv)
+static int ipw2100_queues_allocate(struct ipw2100_priv *priv)
{
if (ipw2100_tx_allocate(priv) ||
ipw2100_rx_allocate(priv) || ipw2100_msg_allocate(priv))

2008-12-22 19:26:10

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 27/27] drivers/net/wireless/prism54: fix sparse warnings: make symbols static

Fix this sparse warnings:

drivers/net/wireless/prism54/islpci_hotplug.c:97:1: warning: symbol 'prism54_probe' was not declared. Should it be static?
drivers/net/wireless/prism54/islpci_hotplug.c:220:1: warning: symbol 'prism54_remove' was not declared. Should it be static?
drivers/net/wireless/prism54/islpci_hotplug.c:263:1: warning: symbol 'prism54_suspend' was not declared. Should it be static?
drivers/net/wireless/prism54/islpci_hotplug.c:286:1: warning: symbol 'prism54_resume' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/wireless/prism54/islpci_hotplug.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/prism54/islpci_hotplug.c b/drivers/net/wireless/prism54/islpci_hotplug.c
index af2e4f2..9a72b1e 100644
--- a/drivers/net/wireless/prism54/islpci_hotplug.c
+++ b/drivers/net/wireless/prism54/islpci_hotplug.c
@@ -93,7 +93,7 @@ static struct pci_driver prism54_driver = {
Module initialization functions
******************************************************************************/

-int
+static int
prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct net_device *ndev;
@@ -216,7 +216,7 @@ prism54_probe(struct pci_dev *pdev, const struct pci_device_id *id)
static volatile int __in_cleanup_module = 0;

/* this one removes one(!!) instance only */
-void
+static void
prism54_remove(struct pci_dev *pdev)
{
struct net_device *ndev = pci_get_drvdata(pdev);
@@ -259,7 +259,7 @@ prism54_remove(struct pci_dev *pdev)
pci_disable_device(pdev);
}

-int
+static int
prism54_suspend(struct pci_dev *pdev, pm_message_t state)
{
struct net_device *ndev = pci_get_drvdata(pdev);
@@ -282,7 +282,7 @@ prism54_suspend(struct pci_dev *pdev, pm_message_t state)
return 0;
}

-int
+static int
prism54_resume(struct pci_dev *pdev)
{
struct net_device *ndev = pci_get_drvdata(pdev);

2008-12-22 19:26:31

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 09/27] drivers/net/e1000e: fix sparse warnings: make symbols static

Fix this sparse warnings:

drivers/net/e1000e/es2lan.c:1265:5: warning: symbol 'e1000_read_kmrn_reg_80003es2lan' was not declared. Should it be static?
drivers/net/e1000e/es2lan.c:1298:5: warning: symbol 'e1000_write_kmrn_reg_80003es2lan' was not declared. Should it be static?

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/e1000e/es2lan.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/e1000e/es2lan.c b/drivers/net/e1000e/es2lan.c
index db51114..8964838 100644
--- a/drivers/net/e1000e/es2lan.c
+++ b/drivers/net/e1000e/es2lan.c
@@ -1262,7 +1262,8 @@ static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw)
* using the kumeran interface. The information retrieved is stored in data.
* Release the semaphore before exiting.
**/
-s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, u16 *data)
+static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
+ u16 *data)
{
u32 kmrnctrlsta;
s32 ret_val = 0;
@@ -1295,7 +1296,8 @@ s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, u16 *data)
* at the offset using the kumeran interface. Release semaphore
* before exiting.
**/
-s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, u16 data)
+static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,
+ u16 data)
{
u32 kmrnctrlsta;
s32 ret_val = 0;

2008-12-22 19:26:49

by Hannes Eder

[permalink] [raw]
Subject: [PATCH 20/27] drivers/net/wan: fix sparse warnings: make do-while a compound statement

Fix this sparse warnings:

drivers/net/wan/wanxl.c:414:3: warning: do-while statement is not a compound statement
drivers/net/wan/wanxl.c:441:3: warning: do-while statement is not a compound statement

Signed-off-by: Hannes Eder <[email protected]>
---
drivers/net/wan/wanxl.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c
index 8845949..4bffb67 100644
--- a/drivers/net/wan/wanxl.c
+++ b/drivers/net/wan/wanxl.c
@@ -410,12 +410,12 @@ static int wanxl_open(struct net_device *dev)
writel(1 << (DOORBELL_TO_CARD_OPEN_0 + port->node), dbr);

timeout = jiffies + HZ;
- do
+ do {
if (get_status(port)->open) {
netif_start_queue(dev);
return 0;
}
- while (time_after(timeout, jiffies));
+ } while (time_after(timeout, jiffies));

printk(KERN_ERR "%s: unable to open port\n", dev->name);
/* ask the card to close the port, should it be still alive */
@@ -437,10 +437,10 @@ static int wanxl_close(struct net_device *dev)
port->card->plx + PLX_DOORBELL_TO_CARD);

timeout = jiffies + HZ;
- do
+ do {
if (!get_status(port)->open)
break;
- while (time_after(timeout, jiffies));
+ } while (time_after(timeout, jiffies));

if (get_status(port)->open)
printk(KERN_ERR "%s: unable to close port\n", dev->name);

2008-12-22 22:12:23

by Krzysztof Halasa

[permalink] [raw]
Subject: Re: [PATCH 20/27] drivers/net/wan: fix sparse warnings: make do-while a compound statement

Hannes Eder <[email protected]> writes:

> drivers/net/wan/wanxl.c:414:3: warning: do-while statement is not a compound statement
> drivers/net/wan/wanxl.c:441:3: warning: do-while statement is not a compound statement

It's by design.
--
Krzysztof Halasa

2008-12-22 22:14:29

by Krzysztof Halasa

[permalink] [raw]
Subject: Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement

Hannes Eder <[email protected]> writes:

> Fix this sparse warnings:

Or: break the formating to silence sparse.

> drivers/net/atp.c:811:8: warning: do-while statement is not a compound statement
> drivers/net/atp.c:813:8: warning: do-while statement is not a compound statement
> drivers/net/atp.c:815:11: warning: do-while statement is not a compound statement
> drivers/net/atp.c:817:11: warning: do-while statement is not a compound statement

> --- a/drivers/net/starfire.c
> +++ b/drivers/net/starfire.c
> @@ -882,9 +882,9 @@ static int mdio_read(struct net_device *dev, int phy_id, int location)
> void __iomem *mdio_addr = np->base + MIICtrl + (phy_id<<7) + (location<<2);
> int result, boguscnt=1000;
> /* ??? Should we add a busy-wait here? */
> - do
> + do {
> result = readl(mdio_addr);
> - while ((result & 0xC0000000) != 0x80000000 && --boguscnt > 0);
> + } while ((result & 0xC0000000) != 0x80000000 && --boguscnt > 0);
> if (boguscnt == 0)
> return 0;
> if ((result & 0xffff) == 0xffff)


I don't know how one could think the above is an improvement.

This "do-while statement is not a compound statement" warning is
pure nonsense.
--
Krzysztof Halasa

2008-12-22 22:30:48

by Jeff Kirsher

[permalink] [raw]
Subject: Re: [PATCH 11/27] drivers/net/igb: remove dead code (function 'igb_read_pci_cfg')

On Mon, Dec 22, 2008 at 11:16 AM, Hannes Eder <[email protected]> wrote:
> Fix this warning:
>
> drivers/net/igb/e1000_mac.c:54: warning: 'igb_read_pci_cfg' defined but not used
>
> Signed-off-by: Hannes Eder <[email protected]>
> ---
> drivers/net/igb/e1000_mac.c | 7 -------
> 1 files changed, 0 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/igb/e1000_mac.c b/drivers/net/igb/e1000_mac.c
> index 137269d..97f0049 100644
> --- a/drivers/net/igb/e1000_mac.c
> +++ b/drivers/net/igb/e1000_mac.c
> @@ -50,13 +50,6 @@ void igb_remove_device(struct e1000_hw *hw)
> kfree(hw->dev_spec);
> }
>
> -static void igb_read_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value)
> -{
> - struct igb_adapter *adapter = hw->back;
> -
> - pci_read_config_word(adapter->pdev, reg, value);
> -}
> -
> static s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
> {
> struct igb_adapter *adapter = hw->back;
>


Acked-by: Jeff Kirsher <[email protected]>

Sorry, I caught this earlier and meant to have patch pushed out last
week. Thanks for correcting this.

--
Cheers,
Jeff

2008-12-22 23:44:40

by Håkon Løvdal

[permalink] [raw]
Subject: Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement

2008/12/22 Krzysztof Halasa <[email protected]>:>> --- a/drivers/net/starfire.c>> +++ b/drivers/net/starfire.c>> @@ -882,9 +882,9 @@ static int mdio_read(struct net_device *dev, int phy_id, int location)>> void __iomem *mdio_addr = np->base + MIICtrl + (phy_id<<7) + (location<<2);>> int result, boguscnt=1000;>> /* ??? Should we add a busy-wait here? */>> - do>> + do {>> result = readl(mdio_addr);>> - while ((result & 0xC0000000) != 0x80000000 && --boguscnt > 0);>> + } while ((result & 0xC0000000) != 0x80000000 && --boguscnt > 0);>> if (boguscnt == 0)>> return 0;>> if ((result & 0xffff) == 0xffff)>>> I don't know how one could think the above is an improvement.
For this specific issue the important aspect is to improve readability(and not just eventually satisfy some warning from a tool), which Iassume there is no disagrement on. Now what constitutes improvedreadbility on the other hand is another issue, and I guess there arenext to as many oppinions as developers... :)I would most certainly prefer to have code look consistently and alwayshave brackets, even in the case of just one body line.
Of secondary importance is the benefit that always using bracketsmakes them much more merge friendly. Consider the following scenario:
Common base: do result = readl(mdio_addr); while ((result & 0xC0000000) != 0x80000000 && --boguscnt > 0);
Branch 1 do { result = readl(mdio_addr); do_something(); } while ((result & 0xC0000000) != 0x80000000 && --boguscnt > 0);
Branch 2 do result = readl(mdio_addr); while (NOT_OK(result) && --boguscnt > 0);
In this case if both branch 1 and 2 are merged, there will be a merge conflictthat has to be resolved manually. If the brackets had been in place from thestart tools should be able to resolv this automatically.
BR Håkon Løvdal????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?

2008-12-23 16:31:34

by Krzysztof Halasa

[permalink] [raw]
Subject: Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement

"Håkon Løvdal" <[email protected]> writes:

> For this specific issue the important aspect is to improve readability
> (and not just eventually satisfy some warning from a tool), which I
> assume there is no disagrement on.

Precisely.

> Now what constitutes improved
> readbility on the other hand is another issue, and I guess there are
> next to as many oppinions as developers... :)

Yes. Thus the brackets (or lack of them) of do-while loops should
never be forced as a part of coding standard/tools. This is just an
unimportant detail of personal style and trying to force it is simply
damaging to all of us.

> Of secondary importance is the benefit that always using brackets
> makes them much more merge friendly.

There are many ways to make the code more merge friendly at a cost of
readability. Hope we don't go this way.
--
Krzysztof Halasa

2008-12-23 17:26:43

by Harvey Harrison

[permalink] [raw]
Subject: Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement

On Tue, 2008-12-23 at 17:31 +0100, Krzysztof Halasa wrote:
> "Håkon Løvdal" <[email protected]> writes:
>
> > For this specific issue the important aspect is to improve readability
> > (and not just eventually satisfy some warning from a tool), which I
> > assume there is no disagrement on.
>
> Precisely.
>
> > Now what constitutes improved
> > readbility on the other hand is another issue, and I guess there are
> > next to as many oppinions as developers... :)
>
> Yes. Thus the brackets (or lack of them) of do-while loops should
> never be forced as a part of coding standard/tools. This is just an
> unimportant detail of personal style and trying to force it is simply
> damaging to all of us.
>
> > Of secondary importance is the benefit that always using brackets
> > makes them much more merge friendly.
>
> There are many ways to make the code more merge friendly at a cost of
> readability. Hope we don't go this way.

Linus himself added that particular warning to sparse...may want to check
with him the reason for it.

Harvey

2008-12-23 17:36:38

by Krzysztof Halasa

[permalink] [raw]
Subject: Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement

Harvey Harrison <[email protected]> writes:

>> There are many ways to make the code more merge friendly at a cost of
>> readability. Hope we don't go this way.
>
> Linus himself added that particular warning to sparse...may want to check
> with him the reason for it.

Once again, this is a personal thing, and a harmless one.

Sometimes I think using this sparse thing does more harm than good.
Not that the tool itself is bad - I find it really useful, many sparse
warnings actually did cause code improvement.

It's like with knives, there are good uses and a bit less good ones.
--
Krzysztof Halasa

2008-12-23 18:09:42

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement


On Tue, 23 Dec 2008, Krzysztof Halasa wrote:

> Harvey Harrison <[email protected]> writes:
>
> >> There are many ways to make the code more merge friendly at a cost of
> >> readability. Hope we don't go this way.
> >
> > Linus himself added that particular warning to sparse...may want to check
> > with him the reason for it.
>
> Once again, this is a personal thing, and a harmless one.

It's more than that. I added the check after some person who had been
programming the kernel (and thus was supposedly fluent in C) literally
could not parse a macro that had "do x while (y)" in it.

Why? Because it's so uncommon, and because "while (y)" on its own means
something totally different.

So the syntactic sugar to _always_ have do-while loops have that brace is
a way to avoid one of the rather few places where the C language has
syntax that is very context-dependent.

Another example of this is "sizeof". The kernel universally (I hope) has
parenthesis around the sizeof argument, even though it's clearly not
required by the C language.

It's a coding standard.

And quite frankly, anybody who works on gcc has no place complaining about
sparse coding standard warnings. They are a _hell_ of a lot better than
some of the really crazy warnings gcc spews out with "-W". At least the
sparse warnings you can make go away while making the code more
understandable. Some of the -W warnings are unfixable without breaking the
source code.

Linus

2008-12-23 23:19:03

by Krzysztof Halasa

[permalink] [raw]
Subject: Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement

Linus Torvalds <[email protected]> writes:

> It's more than that. I added the check after some person who had been
> programming the kernel (and thus was supposedly fluent in C) literally
> could not parse a macro that had "do x while (y)" in it.

A literally that simple macro, or a complicated one?


I'm all for using brackets when there is / could be some possibility
of increasing code readability.

E.g. I always use parentheses in a nested if-if, because

if (x)
if (y)
a;
else
c;

may be confusing, especially if formatted differently.

if (x)
a;
else if (y)
b;
etc.

is simple and unambiguous and I don't put the braces.

So is a case like
do
x;
while (y);
It can't be made more clear with brackets.

IOW: improving the style is great. Changing it only to silence some
tool is not.

> Another example of this is "sizeof". The kernel universally (I hope) has
> parenthesis around the sizeof argument, even though it's clearly not
> required by the C language.
>
> It's a coding standard.

Right, but they (at least for me) make it more readable.
kmalloc(sizeof i) just doesn't look good, the operator looks like
a variable name.

But there is this return statement. Some people tend to write
return (x); I simply write return x;
It's clear, and so is a simple do-while.

> And quite frankly, anybody who works on gcc has no place complaining about
> sparse coding standard warnings. They are a _hell_ of a lot better than
> some of the really crazy warnings gcc spews out with "-W". At least the
> sparse warnings you can make go away while making the code more
> understandable. Some of the -W warnings are unfixable without breaking the
> source code.

:-)

BTW I think I may use sparse differently.
I can see false gcc warnings every time the project is being built.
OTOH I run sparse only when I have some (almost) completed project
(a patch, a driver etc). I make sure the remaining sparse warnings are
(from my POV) invalid and it won't spew them on next build again.
--
Krzysztof Halasa

2008-12-23 23:38:24

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement



On Wed, 24 Dec 2008, Krzysztof Halasa wrote:
>
> So is a case like
> do
> x;
> while (y);
> It can't be made more clear with brackets.

Oh yes it can. People look at that, and it's so uncommon that they
literally believe it is a mis-indent.

Your example with nested if-statements are totally pointless, because you
didn't even apparently understand my comment about "while()" having two
totally different meanings (which is not true of "if()"), nor realize the
importance of how common something is.

Common patterns become things that people take for granted and don't have
any trouble with. In contrast, do-while without braces is _extremely_
uncommon.

> IOW: improving the style is great. Changing it only to silence some
> tool is not.

Sorry, you're wrong. It's not changed to silence some tool. THIS IS THE
KERNEL CODING STYLE.

I don't care one whit about your personal coding style. The kernel has
brances. End of discussion. sparse complains about lack of them.
Comprende?

> Right, but they (at least for me) make it more readable.

I don't care.

> kmalloc(sizeof i) just doesn't look good, the operator looks like
> a variable name.

And I agree with you. "sizeof i" doesn't look good. It's uncommon, and
doesn't match peoples expectations.

> But there is this return statement. Some people tend to write
> return (x); I simply write return x;

I do to. And it's the common thing to do, and only totally confused people
think that 'return' is a somehow remotely like a "function" of its
arguments (the way 'sizeof' is - sizeof _is_ a function of its arguments,
albeit a very rare one).

> It's clear, and so is a simple do-while.

No. "return x;" is clear because it's the common thing, which means that
peopel are good at reading it.

Another example of "common vs non-common" is this:

if (0 <= x)
do something..

is something that crazy people do (sadly, one of the crazy people taught
the git maintainer C programming, so now even sane people do it). It's
crazy because it's uncommon, which means that most people have to think
about it A LOT MORE than about

if (x >= 0)
do something..

even though technically both are obviously EXACTLY THE SAME THING.

Can you see the argument? Doing things the common way is important,
because it allows people to see what they mean without having to think
about it. They just scan it, and the meaning is clear.

And that's why "do while" without braces is bad. If you scan it quickly on
its own, you may well end up just seeing the

while (x);

part, and get confused ("oh, a delay loop"). But if you see

} while (x);

you aren't confused, because the latter one is clearly an ending condition
of a do-while loop, IN A WAY THAT THE FIRST ONE IS NOT!

See?

do-while is very special, because as mentioned, "while" is a really magic
C keyword that has two TOTALLY DIFFERENT meanings. Don't make people look
for the "do".

Linus

2008-12-24 02:04:13

by Krzysztof Halasa

[permalink] [raw]
Subject: Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement

Linus Torvalds <[email protected]> writes:

> Oh yes it can. People look at that, and it's so uncommon that they
> literally believe it is a mis-indent.

People learn, or should, through the life :-)

I'm not sure being common or less common does matter here much.

OTOH I think it's pretty common. Approx as common as while (x) y is,
isn't it?

Except in macros: do-while(0) is commonly used in macros because it
"eats" the semicolon.

(do { xxx; yyy; zzz } while (0) is also quite common instead of "goto"
to add multiple exits from a long block).

> Your example with nested if-statements are totally pointless, because you
> didn't even apparently understand my comment about "while()" having two
> totally different meanings (which is not true of "if()"), nor realize the
> importance of how common something is.

Only apparently. If there is no ambiguity, there is no problem, the
double meaning does not seem relevant.

You tell me that

do
expr;
while (condition);

(with precisely this formatting) can be unclear?

Or you say

do {
expr;
} while (condition);

is better? If it is, then certainly not for me.


Now: are we going to write {} because you say so, even if it makes the
code worse? Or should we rather aim at improving the code, even if
only a bit? (I admit that, IMO, the second example is worse = less
readable, but only a small bit).

> Sorry, you're wrong. It's not changed to silence some tool.

Come on, you have it plain in the subject - "fix sparse warnings".
If it was "improve obscure notation" I wouldn't say a word.

> And I agree with you. "sizeof i" doesn't look good. It's uncommon, and
> doesn't match peoples expectations.

But it doesn't matter if it's common or not. It doesn't look good and
THIS IS WHY it's uncommon/nonexistent. Not the other way around.

There are many uncommon things in a project like a Linux kernel. There
are some macros which take me a while :-) to understand and they
thankfully don't spew warnings.

> Another example of "common vs non-common" is this:
>
> if (0 <= x)
> do something..
>
> is something that crazy people do (sadly, one of the crazy people taught
> the git maintainer C programming, so now even sane people do it). It's
> crazy because it's uncommon, which means that most people have to think
> about it A LOT MORE than about
>
> if (x >= 0)
> do something..

No. It's crazy not because it's uncommon, but because this is how we
have been taught in school.

I don't know reasons for "0 >= x" but I know one for
if (0 == x)
do something..

It's because people sometimes write "=" instead of "==" and "0 = x"
doesn't make sense to gcc. I think it's not a valid reason, and
(unless you use (()) which is IMHO also crazy) gcc will warn about
if (x = 0) (though I think the warning is stupid and "if (a = b)"
is a valid usage if a and b are short).

It's simple: one has to see the difference between if (x = 0) vs
if (x == 0), there is no way around it. if (0 >= x), I don't know.

> Can you see the argument? Doing things the common way is important,
> because it allows people to see what they mean without having to think
> about it. They just scan it, and the meaning is clear.

Then I must be different. Things are clear to me if they are clear,
even if they are uncommon. And common things aren't necessarily clear.
Hmm, I should have expected something like that.

> And that's why "do while" without braces is bad. If you scan it quickly on
> its own, you may well end up just seeing the
>
> while (x);
>
> part, and get confused ("oh, a delay loop").

Nope.
It raises a red flag in my head immediately. We don't do such busy
loops generally, and if we do, I would write it as:

while (x)
;

> But if you see
>
> } while (x);
>
> you aren't confused, because the latter one is clearly an ending condition
> of a do-while loop, IN A WAY THAT THE FIRST ONE IS NOT!
>
> See?

No. I must be different.

> do-while is very special, because as mentioned, "while" is a really magic
> C keyword that has two TOTALLY DIFFERENT meanings.

Probably. I just don't see it.

For me, every code fragment is different, and a program like sparse
can't even come close to know what's clear for me and what is not.

I use sparse as a great help - but only that, a help.
--
Krzysztof Halasa

2008-12-24 02:10:48

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement



On Wed, 24 Dec 2008, Krzysztof Halasa wrote:
>
> People learn, or should, through the life :-)

Sure. But you should learn about the things that matter - not learn to
avoid the stupid pitfalls that come from confusingly doing things so that
they visually look similar even when they do different things.

So don't make people learn by putting traps in their face. That just
wastes everybodys time.

> I'm not sure being common or less common does matter here much.
>
> OTOH I think it's pretty common. Approx as common as while (x) y is,
> isn't it?

I doubt it. It certainly wasn't in the kernel. When we added the sparse
warning, I think we got a couple of hits.

Anyway, not worth discussing. The fact is, the kernel does not accept do
while without braces. I told you why. You can ignore it. I'll ignore you.

Linus

2008-12-25 06:17:42

by Junio C Hamano

[permalink] [raw]
Subject: Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement

Krzysztof Halasa <[email protected]> writes:

> Linus Torvalds <[email protected]> writes:
> ...
>> Another example of "common vs non-common" is this:
>>
>> if (0 <= x)
>> do something..
>>
>> is something that crazy people do (sadly, one of the crazy people taught
>> the git maintainer C programming, so now even sane people do it). It's
>> crazy because it's uncommon, which means that most people have to think
>> about it A LOT MORE than about
>>
>> if (x >= 0)
>> do something..
>
> No. It's crazy not because it's uncommon, but because this is how we
> have been taught in school.
>
> I don't know reasons for "0 >= x" but I know one for
> if (0 == x)
> do something..
>
> It's because people sometimes write "=" instead of "==" and "0 = x"
> doesn't make sense to gcc.

It does not have anything to do with the assignment confusion.

It is "textual order should reflect actual order" (aka "have number line
in your head when you write your comparison conditional"):

http://thread.gmane.org/gmane.comp.version-control.git/3903/focus=4126

Even if it may make logical sense, I would not suggest using it when other
people are not familiar with the convention, though.

2008-12-25 17:03:02

by Krzysztof Halasa

[permalink] [raw]
Subject: Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement

Linus Torvalds <[email protected]> writes:

> Anyway, not worth discussing. The fact is, the kernel does not accept do
> while without braces. I told you why. You can ignore it. I'll ignore you.

Oh, I'm not a martyr.
--
Krzysztof Halasa

2008-12-26 00:17:52

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 03/27] drivers/net: fix sparse warning: returning void-valued expression

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:15:17 +0100

> Fix this sparse warning:
>
> drivers/net/niu.c:8850:2: warning: returning void-valued expression
>
> Signed-off-by: Hannes Eder <[email protected]>

Can we just fix sparse not to generate this warning? It's
marginal, at best. C++ even explicitly defines this as valid
and last time I brought this up Linus even agreed.

The types match, the function returns void and it is returning a void,
what is the problem?

2008-12-26 07:53:21

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 01/27] drivers/net: fix sparse warning: use ANSI-style function declaration

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:14:58 +0100

> Fix this sparse warning:
>
> drivers/net/ne.c:932:24: warning: non-ANSI function declaration of function 'init_module'
>
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 07:55:55

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:15:07 +0100

> While at it insert some extra curly braces and fix formatting.
...
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 07:56:36

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 03/27] drivers/net: fix sparse warning: returning void-valued expression

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:15:17 +0100

> Fix this sparse warning:
>
> drivers/net/niu.c:8850:2: warning: returning void-valued expression
>
> Signed-off-by: Hannes Eder <[email protected]>

Whilst, as stated, I disagree with this warning, I've
applied your patch.

Thanks.

2008-12-26 07:57:20

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 04/27] drivers/net: fix sparse warnings: make symbols static

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:15:26 +0100

> Fix this sparse warnings:
...
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 07:57:41

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 05/27] drivers/net/arcnet: fix sparse warnings: make symbols static

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:15:36 +0100

> Fix this sparse warnings:
>
> drivers/net/arcnet/capmode.c:64:6: warning: symbol 'arcnet_cap_init' was not declared. Should it be static?
> drivers/net/arcnet/com90xx.c:586:5: warning: symbol 'com90xx_reset' was not declared. Should it be static?
>
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 07:58:52

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 06/27] drivers/net/atlx: fix sparse warnings: make symbols static

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:15:45 +0100

> Fix this sparse warnings:
>
> drivers/net/atlx/atl1.c:198:16: warning: symbol 'atl1_check_options' was not declared. Should it be static?
> drivers/net/atlx/atl1.c:526:5: warning: symbol 'atl1_read_mac_addr' was not declared. Should it be static?
>
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 07:59:26

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 07/27] drivers/net/bonding: fix sparse warnings: move decls to header file

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:15:54 +0100

> Fix this sparse warnings:
...
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 07:59:51

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 08/27] drivers/net/cxgb3: comment out dead code

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:16:03 +0100

> The function 'vsc8211_set_speed_duplex' is not used, so comment it
> out. For 'vsc8211_set_automdi' the function 'vsc8211_set_speed_duplex'
> is the only caller, so comment it out as well.
>
> Fix this (sparse) warning:
...
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 08:01:47

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 10/27] drivers/net/enic: fix sparse warning: make symbol static

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:16:23 +0100

> Fix this sparse warning:
...
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 08:03:17

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 11/27] drivers/net/igb: remove dead code (function 'igb_read_pci_cfg')

From: "Jeff Kirsher" <[email protected]>
Date: Mon, 22 Dec 2008 14:30:00 -0800

> On Mon, Dec 22, 2008 at 11:16 AM, Hannes Eder <[email protected]> wrote:
> > Fix this warning:
> >
> > drivers/net/igb/e1000_mac.c:54: warning: 'igb_read_pci_cfg' defined but not used
> >
> > Signed-off-by: Hannes Eder <[email protected]>
...
> Acked-by: Jeff Kirsher <[email protected]>

Applied.

2008-12-26 08:03:53

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 12/27] drivers/net/irda: fix sparse warnings: make symbols static

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:16:41 +0100

> Fix this sparse warnings:
...
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 08:04:26

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 13/27] drivers/net/ixgbe: fix sparse warnings: make symbols static

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:16:50 +0100

> Fix this sparse warnings:
...
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 08:04:46

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 14/27] drivers/net/netxen: fix sparse warnings: use NULL pointer instead of plain integer

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:16:59 +0100

> Fix this sparse warnings:
...
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 08:05:22

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 15/27] drivers/net/qlge: fix sparse warnings: make symbols static

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:17:09 +0100

> Fix this sparse warnings:
...
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 08:06:48

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 16/27] drivers/net/skfp: fix sparse warnings: make symbols static

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:17:18 +0100

> Fix this sparse warnings:
...
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 08:07:35

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 17/27] drivers/net/tokenring: fix sparse warnings: make symbols static

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:17:27 +0100

> Fix this sparse warnings:
...
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 08:08:14

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 18/27] drivers/net/tulip: fix sparse warnings: make do-while a compound statement

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:17:37 +0100

> Fix this sparse warnings:
...
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 08:09:12

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 19/27] drivers/net/usb: fix sparse warnings: make symbols static

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:17:46 +0100

> Fix this sparse warnings:
...
> Signed-off-by: Hannes Eder <[email protected]>

There have been changes in this area in the net-next-2.6 tree
so this patch won't apply.

Please regenerate this after I am able to merge all of my
networking bits to Linus for the 2.6.29 merge window.

Thanks.

2008-12-26 08:11:37

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 21/27] drivers/net/wan: fix sparse warning: make symbol static

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:18:04 +0100

> Fix this sparse warning:
>
> drivers/net/wan/x25_asy.c:623:5: warning: symbol 'x25_asy_esc' was not declared. Should it be static?
>
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 08:12:24

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 22/27] drivers/net/wan/z85230.c: fix sparse warnings: un-EXPORT symbols

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:18:13 +0100

> The symbols are only references within the translation unit they are
> defined in, so un-EXPORT them und make them 'static'.
>
> Fix this sparse warnings:
>
> drivers/net/wan/z85230.c:604:25: warning: symbol 'z8530_dma_sync' was not declared. Should it be static?
> drivers/net/wan/z85230.c:613:25: warning: symbol 'z8530_txdma_sync' was not declared. Should it be static?
>
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 08:13:22

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 23/27] drivers/net/wireless: fix sparse warnings: make symbols static

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:18:23 +0100

> Fix this sparse warnings:
>
> drivers/net/wireless/airo.c:3610:6: warning: symbol 'mpi_receive_802_11' was not declared. Should it be static?
> drivers/net/wireless/atmel.c:3183:6: warning: symbol 'atmel_join_bss' was not declared. Should it be static?
> drivers/net/wireless/ray_cs.c:831:5: warning: symbol 'ray_dev_init' was not declared. Should it be static?
>
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 08:14:12

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 25/27] drivers/net/wireless/b43: fix sparse warnings: make symbols static

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:18:41 +0100

> Fix this sparse warnings:
...
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 08:14:59

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 26/27] drivers/net/wireless/ipw2x00: fix sparse warnings: make symbols static

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:18:51 +0100

> Fix this sparse warnings:
>
> drivers/net/wireless/ipw2x00/ipw2100.c:5271:6: warning: symbol 'ipw2100_queues_initialize' was not declared. Should it be static?
> drivers/net/wireless/ipw2x00/ipw2100.c:5278:6: warning: symbol 'ipw2100_queues_free' was not declared. Should it be static?
> drivers/net/wireless/ipw2x00/ipw2100.c:5285:5: warning: symbol 'ipw2100_queues_allocate' was not declared. Should it be static?
>
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 08:15:34

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 27/27] drivers/net/wireless/prism54: fix sparse warnings: make symbols static

From: Hannes Eder <[email protected]>
Date: Mon, 22 Dec 2008 20:19:00 +0100

> Fix this sparse warnings:
...
> Signed-off-by: Hannes Eder <[email protected]>

Applied.

2008-12-26 14:40:20

by Hannes Eder

[permalink] [raw]
Subject: Re: [PATCH 03/27] drivers/net: fix sparse warning: returning void-valued expression

On Fri, Dec 26, 2008 at 1:17 AM, David Miller <[email protected]> wrote:
> From: Hannes Eder <[email protected]>
> Date: Mon, 22 Dec 2008 20:15:17 +0100
>
>> Fix this sparse warning:
>>
>> drivers/net/niu.c:8850:2: warning: returning void-valued expression
>>
>> Signed-off-by: Hannes Eder <[email protected]>
>
> Can we just fix sparse not to generate this warning? It's
> marginal, at best. C++ even explicitly defines this as valid
> and last time I brought this up Linus even agreed.
>
> The types match, the function returns void and it is returning a void,
> what is the problem?

after reading the following thread I decided to submit such type of patches:

On Thu, 1 May 2008 at 13:53:39 +0100, Al Viro wrote:
> On Thu, May 01, 2008 at 03:42:14PM +0300, Boaz Harrosh wrote:
> > > 3. 6.8.6.4(1): A return statement with an expression shall not appear in
> > > a function whose return type is void.
> > >
> >
> > Please forgive my ignorance, where is this quote from?
>
> C99. I don't have C90 in front of me, so I can't give you exact quote from
> there, but it's been explicitly banned in C90 as well.

see http://lkml.org/lkml/2008/5/1/112

2008-12-26 19:59:41

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH 03/27] drivers/net: fix sparse warning: returning void-valued expression

On Thu, 25 Dec 2008 16:17:40 -0800 (PST)
David Miller <[email protected]> wrote:

> From: Hannes Eder <[email protected]>
> Date: Mon, 22 Dec 2008 20:15:17 +0100
>
> > Fix this sparse warning:
> >
> > drivers/net/niu.c:8850:2: warning: returning void-valued expression
> >
> > Signed-off-by: Hannes Eder <[email protected]>
>
> Can we just fix sparse not to generate this warning? It's
> marginal, at best. C++ even explicitly defines this as valid
> and last time I brought this up Linus even agreed.

Ack, I discussed it with him also and he thought that
they were just fine as they were...

> The types match, the function returns void and it is returning a void,
> what is the problem?


--
~Randy

2008-12-27 19:11:33

by Hannes Eder

[permalink] [raw]
Subject: Re: [PATCH 03/27] drivers/net: fix sparse warning: returning void-valued expression

On 12/26/08, Randy Dunlap <[email protected]> wrote:
> On Thu, 25 Dec 2008 16:17:40 -0800 (PST)
>
> David Miller <[email protected]> wrote:
>
>
> > From: Hannes Eder <[email protected]>
> > Date: Mon, 22 Dec 2008 20:15:17 +0100
> >
> > > Fix this sparse warning:
> > >
> > > drivers/net/niu.c:8850:2: warning: returning void-valued expression
> > >
> > > Signed-off-by: Hannes Eder <[email protected]>
> >
> > Can we just fix sparse not to generate this warning? It's
> > marginal, at best. C++ even explicitly defines this as valid
> > and last time I brought this up Linus even agreed.
>
>
> Ack, I discussed it with him also and he thought that
> they were just fine as they were...
>
>
> > The types match, the function returns void and it is returning a void,
> > what is the problem?

In fact there is no need to _fix_ sparse, as there is a command line option
-Wreturn-void / -Wno-return-void, so we could change the Makefile, see diff
below.

---

diff --git a/Makefile b/Makefile
index 64f14aa..cc62984 100644
--- a/Makefile
+++ b/Makefile
@@ -321,7 +321,7 @@ KALLSYMS = scripts/kallsyms
PERL = perl
CHECK = sparse

-CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF)
+CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise -Wno-return-void $(CF)
MODFLAGS = -DMODULE
CFLAGS_MODULE = $(MODFLAGS)
AFLAGS_MODULE = $(MODFLAGS)

2008-12-27 19:18:54

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH 03/27] drivers/net: fix sparse warning: returning void-valued expression

On Sat, Dec 27, 2008 at 08:11:11PM +0100, Hannes Eder wrote:
> On 12/26/08, Randy Dunlap <[email protected]> wrote:
> > On Thu, 25 Dec 2008 16:17:40 -0800 (PST)
> >
> > David Miller <[email protected]> wrote:
> >
> >
> > > From: Hannes Eder <[email protected]>
> > > Date: Mon, 22 Dec 2008 20:15:17 +0100
> > >
> > > > Fix this sparse warning:
> > > >
> > > > drivers/net/niu.c:8850:2: warning: returning void-valued expression
> > > >
> > > > Signed-off-by: Hannes Eder <[email protected]>
> > >
> > > Can we just fix sparse not to generate this warning? It's
> > > marginal, at best. C++ even explicitly defines this as valid
> > > and last time I brought this up Linus even agreed.
> >
> >
> > Ack, I discussed it with him also and he thought that
> > they were just fine as they were...
> >
> >
> > > The types match, the function returns void and it is returning a void,
> > > what is the problem?
>
> In fact there is no need to _fix_ sparse, as there is a command line option
> -Wreturn-void / -Wno-return-void, so we could change the Makefile, see diff
> below.

It is default off but out use of "-Wall" turn it on.
So your patch is the right approach.

Can you please re-send it with a proper changelog and signed-off.

Sam

2008-12-27 21:51:44

by Hannes Eder

[permalink] [raw]
Subject: [PATCH] Makefile: disable sparse warning "returning void-valued expression"

The sparse warning -Wreturn-void ("returning void-valued expression")
is off by default, but it is enabled with -Wall, so add
-Wno-return-void to CHECKFLAGS to disable it.

Signed-off-by: Hannes Eder <[email protected]>
---
Makefile | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 64f14aa..a5b5e8d 100644
--- a/Makefile
+++ b/Makefile
@@ -321,7 +321,8 @@ KALLSYMS = scripts/kallsyms
PERL = perl
CHECK = sparse

-CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise $(CF)
+CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
+ -Wbitwise -Wno-return-void $(CF)
MODFLAGS = -DMODULE
CFLAGS_MODULE = $(MODFLAGS)
AFLAGS_MODULE = $(MODFLAGS)

2008-12-27 21:55:55

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH] Makefile: disable sparse warning "returning void-valued expression"

On Sat, Dec 27, 2008 at 10:38:44PM +0100, Hannes Eder wrote:
> The sparse warning -Wreturn-void ("returning void-valued expression")
> is off by default, but it is enabled with -Wall, so add
> -Wno-return-void to CHECKFLAGS to disable it.
>
> Signed-off-by: Hannes Eder <[email protected]>

Thanks Hannes - applied.

Sam

2008-12-29 14:35:47

by Hannes Eder

[permalink] [raw]
Subject: Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement

On Wed, Dec 24, 2008 at 12:38 AM, Linus Torvalds
<[email protected]> wrote:
>
>
> On Wed, 24 Dec 2008, Krzysztof Halasa wrote:
>>
>> So is a case like
>> do
>> x;
>> while (y);
>> It can't be made more clear with brackets.
>
> Oh yes it can. People look at that, and it's so uncommon that they
> literally believe it is a mis-indent.
>
> [snip]
>
>> kmalloc(sizeof i) just doesn't look good, the operator looks like
>> a variable name.
>
> And I agree with you. "sizeof i" doesn't look good. It's uncommon, and
> doesn't match peoples expectations.
>
>> But there is this return statement. Some people tend to write
>> return (x); I simply write return x;
>
> I do to. And it's the common thing to do, and only totally confused people
> think that 'return' is a somehow remotely like a "function" of its
> arguments (the way 'sizeof' is - sizeof _is_ a function of its arguments,
> albeit a very rare one).
>
>> It's clear, and so is a simple do-while.
>
> No. "return x;" is clear because it's the common thing, which means that
> peopel are good at reading it.

I got curious and conducted a little experiment, here is the outcome
for the linux-2.6 kernel tree:

hannes@vmbox:~/linux-2.6$ find . -name "*.[ch]" -print0 | xargs -0 cat
| ../sparse/cstats -

stats for '-':
do's: 8092, non compound: 79 ( 1.0%)
sizeof's: 51216, without parenthesis: 1543 ( 3.0%)
return's: 286167, with parenthesis: 13552 ( 4.7%)

'cstats' is a little program I wrote using the sparse library, see below.

The value for "return's with parenthesis" is a bit of an estimation,
as 'cstats' operates only at the token level, so
"return (x) ? y : z;" counts as "return with parenthesis".

some sanity checks, to ensure the magnitudes are right:

hannes@vmbox:~/linux-2.6$ git grep -w do -- *.[ch] | wc -l
20599

hannes@vmbox:~/linux-2.6$ git grep '\bdo[ \t]*{' -- *.[ch] | wc -l
7805

I assume 'do' is used frequently in comments:

hannes@vmbox:~/linux-2.6$ git grep '\*.*\bdo\b' -- *.[ch] | wc -l
11358

hannes@vmbox:~/linux-2.6$ git grep '^[ \t]*do$' -- *.[ch] | wc -l
34

hannes@vmbox:~/linux-2.6$ git grep -w sizeof -- *.[ch] | wc -l
49631

constructs like sizeof(array)/sizeof(array[0]) or common:

hannes@vmbox:~/linux-2.6$ git grep 'sizeof.*sizeof' -- *.[ch] | wc -l
1827

hannes@vmbox:~/linux-2.6$ git grep '\bsizeof [^(]' -- *.[ch] | wc -l
1534

hannes@vmbox:~/linux-2.6$ git grep -w return -- *.[ch] | wc -l
295304

hannes@vmbox:~/linux-2.6$ git grep '\breturn (' -- *.[ch] | wc -l
11067

Best,
Hannes


#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>

#include "token.h"
#include "parse.h"

int main(int argc, char **argv)
{
struct string_list *filelist = NULL;
char *filename;

sparse_initialize(argc, argv, &filelist);
FOR_EACH_PTR_NOTAG(filelist, filename) {
int fd;
struct token *token;
int do_stats = 0;
int do_stats_nc = 0;
int sizeof_exprs = 0;
int sizeof_exprs_np = 0;
int return_stats = 0;
int return_stats_wp = 0;

if (strcmp(filename, "-") == 0) {
fd = 0;
} else {
fd = open(filename, O_RDONLY);
if (fd < 0)
die("No such file: %s", filename);
}

// Tokenize the input stream
token = tokenize(filename, fd, NULL, includepath);
close(fd);

for ( ; !eof_token(token); token = token->next) {
if (token_type(token) == TOKEN_IDENT) {
if (token->ident == &do_ident) {
do_stats++;
if (!match_op(token->next, '{'))
do_stats_nc++;
}
else if (token->ident == &sizeof_ident) {
sizeof_exprs++;
if (!match_op(token->next, '('))
sizeof_exprs_np++;
}
else if (token->ident == &return_ident) {
return_stats++;
if (match_op(token->next, '('))
return_stats_wp++;
}
}
}

printf("stats for '%s':\n", filename);
printf(" do's: %8d, non compound: %8d (%5.1f%%)\n",
do_stats, do_stats_nc,
100.0 * do_stats_nc / (do_stats?:1) );
printf(" sizeof's: %8d, without parenthesis: %8d (%5.1f%%)\n",
sizeof_exprs, sizeof_exprs_np,
100.0 * sizeof_exprs_np / (sizeof_exprs?:1) );
printf(" return's: %8d, with parenthesis: %8d (%5.1f%%)\n",
return_stats, return_stats_wp,
100.0 * return_stats_wp / (return_stats?:1) );

} END_FOR_EACH_PTR_NOTAG(filename);
return 0;
}