diff options
author | Alejandro Martinez Ruiz <alex@flawedcode.org> | 2007-10-18 04:00:15 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:03:36 -0500 |
commit | 4c3616cdda0632a3d0e39069765f9ea0e6bd093e (patch) | |
tree | d913f63996d479394bcdabd21ebfbdbe16bd1844 /drivers/net | |
parent | f59d9782751bf1a2c51e7e1e9f614ffec35fb52e (diff) |
netdev: use ARRAY_SIZE() instead of sizeof(array) / ETH_GSTRING_LEN
Using ARRAY_SIZE() on arrays of the form array[][K] makes it unnecessary
to know the value of K when checking its size.
Signed-off-by: Alejandro Martinez Ruiz <alex@flawedcode.org>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/cassini.c | 2 | ||||
-rw-r--r-- | drivers/net/e100.c | 4 | ||||
-rw-r--r-- | drivers/net/e1000/e1000_ethtool.c | 2 | ||||
-rw-r--r-- | drivers/net/e1000e/ethtool.c | 2 | ||||
-rw-r--r-- | drivers/net/myri10ge/myri10ge.c | 2 | ||||
-rw-r--r-- | drivers/net/netxen/netxen_nic_ethtool.c | 2 | ||||
-rw-r--r-- | drivers/net/pcnet32.c | 2 | ||||
-rw-r--r-- | drivers/net/s2io.c | 9 | ||||
-rw-r--r-- | drivers/net/tehuti.c | 8 |
9 files changed, 15 insertions, 18 deletions
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c index d66915d82b24..2bacb5e4604d 100644 --- a/drivers/net/cassini.c +++ b/drivers/net/cassini.c | |||
@@ -4394,7 +4394,7 @@ static struct { | |||
4394 | {"tx_fifo_errors"}, | 4394 | {"tx_fifo_errors"}, |
4395 | {"tx_packets"} | 4395 | {"tx_packets"} |
4396 | }; | 4396 | }; |
4397 | #define CAS_NUM_STAT_KEYS (sizeof(ethtool_cassini_statnames)/ETH_GSTRING_LEN) | 4397 | #define CAS_NUM_STAT_KEYS ARRAY_SIZE(ethtool_cassini_statnames) |
4398 | 4398 | ||
4399 | static struct { | 4399 | static struct { |
4400 | const int offsets; /* neg. values for 2nd arg to cas_read_phy */ | 4400 | const int offsets; /* neg. values for 2nd arg to cas_read_phy */ |
diff --git a/drivers/net/e100.c b/drivers/net/e100.c index b87402bc8308..597fd2953658 100644 --- a/drivers/net/e100.c +++ b/drivers/net/e100.c | |||
@@ -2369,7 +2369,7 @@ static const char e100_gstrings_test[][ETH_GSTRING_LEN] = { | |||
2369 | "Mac loopback (offline)", | 2369 | "Mac loopback (offline)", |
2370 | "Phy loopback (offline)", | 2370 | "Phy loopback (offline)", |
2371 | }; | 2371 | }; |
2372 | #define E100_TEST_LEN sizeof(e100_gstrings_test) / ETH_GSTRING_LEN | 2372 | #define E100_TEST_LEN ARRAY_SIZE(e100_gstrings_test) |
2373 | 2373 | ||
2374 | static void e100_diag_test(struct net_device *netdev, | 2374 | static void e100_diag_test(struct net_device *netdev, |
2375 | struct ethtool_test *test, u64 *data) | 2375 | struct ethtool_test *test, u64 *data) |
@@ -2431,7 +2431,7 @@ static const char e100_gstrings_stats[][ETH_GSTRING_LEN] = { | |||
2431 | "rx_flow_control_unsupported", "tx_tco_packets", "rx_tco_packets", | 2431 | "rx_flow_control_unsupported", "tx_tco_packets", "rx_tco_packets", |
2432 | }; | 2432 | }; |
2433 | #define E100_NET_STATS_LEN 21 | 2433 | #define E100_NET_STATS_LEN 21 |
2434 | #define E100_STATS_LEN sizeof(e100_gstrings_stats) / ETH_GSTRING_LEN | 2434 | #define E100_STATS_LEN ARRAY_SIZE(e100_gstrings_stats) |
2435 | 2435 | ||
2436 | static int e100_get_sset_count(struct net_device *netdev, int sset) | 2436 | static int e100_get_sset_count(struct net_device *netdev, int sset) |
2437 | { | 2437 | { |
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c index b83ccce8a9b7..2e44191d4b42 100644 --- a/drivers/net/e1000/e1000_ethtool.c +++ b/drivers/net/e1000/e1000_ethtool.c | |||
@@ -110,7 +110,7 @@ static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = { | |||
110 | "Interrupt test (offline)", "Loopback test (offline)", | 110 | "Interrupt test (offline)", "Loopback test (offline)", |
111 | "Link test (on/offline)" | 111 | "Link test (on/offline)" |
112 | }; | 112 | }; |
113 | #define E1000_TEST_LEN sizeof(e1000_gstrings_test) / ETH_GSTRING_LEN | 113 | #define E1000_TEST_LEN ARRAY_SIZE(e1000_gstrings_test) |
114 | 114 | ||
115 | static int | 115 | static int |
116 | e1000_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) | 116 | e1000_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) |
diff --git a/drivers/net/e1000e/ethtool.c b/drivers/net/e1000e/ethtool.c index 87f9da1b6b4e..b36b853bed1a 100644 --- a/drivers/net/e1000e/ethtool.c +++ b/drivers/net/e1000e/ethtool.c | |||
@@ -103,7 +103,7 @@ static const char e1000_gstrings_test[][ETH_GSTRING_LEN] = { | |||
103 | "Interrupt test (offline)", "Loopback test (offline)", | 103 | "Interrupt test (offline)", "Loopback test (offline)", |
104 | "Link test (on/offline)" | 104 | "Link test (on/offline)" |
105 | }; | 105 | }; |
106 | #define E1000_TEST_LEN sizeof(e1000_gstrings_test) / ETH_GSTRING_LEN | 106 | #define E1000_TEST_LEN ARRAY_SIZE(e1000_gstrings_test) |
107 | 107 | ||
108 | static int e1000_get_settings(struct net_device *netdev, | 108 | static int e1000_get_settings(struct net_device *netdev, |
109 | struct ethtool_cmd *ecmd) | 109 | struct ethtool_cmd *ecmd) |
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c index c90958f6d3fe..6bdabc3a84bf 100644 --- a/drivers/net/myri10ge/myri10ge.c +++ b/drivers/net/myri10ge/myri10ge.c | |||
@@ -1431,7 +1431,7 @@ static const char myri10ge_gstrings_stats[][ETH_GSTRING_LEN] = { | |||
1431 | }; | 1431 | }; |
1432 | 1432 | ||
1433 | #define MYRI10GE_NET_STATS_LEN 21 | 1433 | #define MYRI10GE_NET_STATS_LEN 21 |
1434 | #define MYRI10GE_STATS_LEN sizeof(myri10ge_gstrings_stats) / ETH_GSTRING_LEN | 1434 | #define MYRI10GE_STATS_LEN ARRAY_SIZE(myri10ge_gstrings_stats) |
1435 | 1435 | ||
1436 | static void | 1436 | static void |
1437 | myri10ge_get_strings(struct net_device *netdev, u32 stringset, u8 * data) | 1437 | myri10ge_get_strings(struct net_device *netdev, u32 stringset, u8 * data) |
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c index cfb847b0cae3..cdec4f87e1ed 100644 --- a/drivers/net/netxen/netxen_nic_ethtool.c +++ b/drivers/net/netxen/netxen_nic_ethtool.c | |||
@@ -86,7 +86,7 @@ static const char netxen_nic_gstrings_test[][ETH_GSTRING_LEN] = { | |||
86 | "Link_Test_on_offline" | 86 | "Link_Test_on_offline" |
87 | }; | 87 | }; |
88 | 88 | ||
89 | #define NETXEN_NIC_TEST_LEN sizeof(netxen_nic_gstrings_test) / ETH_GSTRING_LEN | 89 | #define NETXEN_NIC_TEST_LEN ARRAY_SIZE(netxen_nic_gstrings_test) |
90 | 90 | ||
91 | #define NETXEN_NIC_REGS_COUNT 42 | 91 | #define NETXEN_NIC_REGS_COUNT 42 |
92 | #define NETXEN_NIC_REGS_LEN (NETXEN_NIC_REGS_COUNT * sizeof(__le32)) | 92 | #define NETXEN_NIC_REGS_LEN (NETXEN_NIC_REGS_COUNT * sizeof(__le32)) |
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c index 90498ffe26f2..c4b74e9fed20 100644 --- a/drivers/net/pcnet32.c +++ b/drivers/net/pcnet32.c | |||
@@ -137,7 +137,7 @@ static const char pcnet32_gstrings_test[][ETH_GSTRING_LEN] = { | |||
137 | "Loopback test (offline)" | 137 | "Loopback test (offline)" |
138 | }; | 138 | }; |
139 | 139 | ||
140 | #define PCNET32_TEST_LEN (sizeof(pcnet32_gstrings_test) / ETH_GSTRING_LEN) | 140 | #define PCNET32_TEST_LEN ARRAY_SIZE(pcnet32_gstrings_test) |
141 | 141 | ||
142 | #define PCNET32_NUM_REGS 136 | 142 | #define PCNET32_NUM_REGS 136 |
143 | 143 | ||
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index f2ba944e035e..67e0a65fc28c 100644 --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c | |||
@@ -335,10 +335,9 @@ static char ethtool_driver_stats_keys[][ETH_GSTRING_LEN] = { | |||
335 | {"mc_err_cnt"} | 335 | {"mc_err_cnt"} |
336 | }; | 336 | }; |
337 | 337 | ||
338 | #define S2IO_XENA_STAT_LEN sizeof(ethtool_xena_stats_keys)/ ETH_GSTRING_LEN | 338 | #define S2IO_XENA_STAT_LEN ARRAY_SIZE(ethtool_xena_stats_keys) |
339 | #define S2IO_ENHANCED_STAT_LEN sizeof(ethtool_enhanced_stats_keys)/ \ | 339 | #define S2IO_ENHANCED_STAT_LEN ARRAY_SIZE(ethtool_enhanced_stats_keys) |
340 | ETH_GSTRING_LEN | 340 | #define S2IO_DRIVER_STAT_LEN ARRAY_SIZE(ethtool_driver_stats_keys) |
341 | #define S2IO_DRIVER_STAT_LEN sizeof(ethtool_driver_stats_keys)/ ETH_GSTRING_LEN | ||
342 | 341 | ||
343 | #define XFRAME_I_STAT_LEN (S2IO_XENA_STAT_LEN + S2IO_DRIVER_STAT_LEN ) | 342 | #define XFRAME_I_STAT_LEN (S2IO_XENA_STAT_LEN + S2IO_DRIVER_STAT_LEN ) |
344 | #define XFRAME_II_STAT_LEN (XFRAME_I_STAT_LEN + S2IO_ENHANCED_STAT_LEN ) | 343 | #define XFRAME_II_STAT_LEN (XFRAME_I_STAT_LEN + S2IO_ENHANCED_STAT_LEN ) |
@@ -346,7 +345,7 @@ static char ethtool_driver_stats_keys[][ETH_GSTRING_LEN] = { | |||
346 | #define XFRAME_I_STAT_STRINGS_LEN ( XFRAME_I_STAT_LEN * ETH_GSTRING_LEN ) | 345 | #define XFRAME_I_STAT_STRINGS_LEN ( XFRAME_I_STAT_LEN * ETH_GSTRING_LEN ) |
347 | #define XFRAME_II_STAT_STRINGS_LEN ( XFRAME_II_STAT_LEN * ETH_GSTRING_LEN ) | 346 | #define XFRAME_II_STAT_STRINGS_LEN ( XFRAME_II_STAT_LEN * ETH_GSTRING_LEN ) |
348 | 347 | ||
349 | #define S2IO_TEST_LEN sizeof(s2io_gstrings) / ETH_GSTRING_LEN | 348 | #define S2IO_TEST_LEN ARRAY_SIZE(s2io_gstrings) |
350 | #define S2IO_STRINGS_LEN S2IO_TEST_LEN * ETH_GSTRING_LEN | 349 | #define S2IO_STRINGS_LEN S2IO_TEST_LEN * ETH_GSTRING_LEN |
351 | 350 | ||
352 | #define S2IO_TIMER_CONF(timer, handle, arg, exp) \ | 351 | #define S2IO_TIMER_CONF(timer, handle, arg, exp) \ |
diff --git a/drivers/net/tehuti.c b/drivers/net/tehuti.c index 21230c97b2a0..ccb8d447cec6 100644 --- a/drivers/net/tehuti.c +++ b/drivers/net/tehuti.c | |||
@@ -2174,8 +2174,7 @@ bdx_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo) | |||
2174 | strlcat(drvinfo->bus_info, pci_name(priv->pdev), | 2174 | strlcat(drvinfo->bus_info, pci_name(priv->pdev), |
2175 | sizeof(drvinfo->bus_info)); | 2175 | sizeof(drvinfo->bus_info)); |
2176 | 2176 | ||
2177 | drvinfo->n_stats = ((priv->stats_flag) ? | 2177 | drvinfo->n_stats = ((priv->stats_flag) ? ARRAY_SIZE(bdx_stat_names) : 0); |
2178 | (sizeof(bdx_stat_names) / ETH_GSTRING_LEN) : 0); | ||
2179 | drvinfo->testinfo_len = 0; | 2178 | drvinfo->testinfo_len = 0; |
2180 | drvinfo->regdump_len = 0; | 2179 | drvinfo->regdump_len = 0; |
2181 | drvinfo->eedump_len = 0; | 2180 | drvinfo->eedump_len = 0; |
@@ -2375,10 +2374,9 @@ static void bdx_get_strings(struct net_device *netdev, u32 stringset, u8 *data) | |||
2375 | static int bdx_get_stats_count(struct net_device *netdev) | 2374 | static int bdx_get_stats_count(struct net_device *netdev) |
2376 | { | 2375 | { |
2377 | struct bdx_priv *priv = netdev->priv; | 2376 | struct bdx_priv *priv = netdev->priv; |
2378 | BDX_ASSERT(sizeof(bdx_stat_names) / ETH_GSTRING_LEN | 2377 | BDX_ASSERT(ARRAY_SIZE(bdx_stat_names) |
2379 | != sizeof(struct bdx_stats) / sizeof(u64)); | 2378 | != sizeof(struct bdx_stats) / sizeof(u64)); |
2380 | return ((priv->stats_flag) ? (sizeof(bdx_stat_names) / ETH_GSTRING_LEN) | 2379 | return ((priv->stats_flag) ? ARRAY_SIZE(bdx_stat_names) : 0); |
2381 | : 0); | ||
2382 | } | 2380 | } |
2383 | 2381 | ||
2384 | /* | 2382 | /* |