Skip to content

Commit 9b10df5

Browse files
jacob-kellerJeff Kirsher
authored andcommitted
i40e: use WARN_ONCE to replace the commented BUG_ON size check
We don't really want to use BUG_ON here since that would completely crash the kernel, thus the reason we commented it out. We *can't* use BUILD_BUG_ON because at least now (a) the sizes aren't constant (we are fixing this) and (b) not all compilers are smart enough to understand that "p - data" is a constant. Instead, just use a WARN_ONCE so that the first time we end up with an incorrect size we will dump a stack trace and a message, hopefully highlighting the issues early in testing. Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
1 parent 019b9cd commit 9b10df5

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/net/ethernet/intel/i40e/i40e_ethtool.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,8 +1792,8 @@ static void i40e_get_stat_strings(struct net_device *netdev, u8 *data)
17921792
struct i40e_netdev_priv *np = netdev_priv(netdev);
17931793
struct i40e_vsi *vsi = np->vsi;
17941794
struct i40e_pf *pf = vsi->back;
1795-
char *p = (char *)data;
17961795
unsigned int i;
1796+
u8 *p = data;
17971797

17981798
for (i = 0; i < I40E_NETDEV_STATS_LEN; i++) {
17991799
snprintf(p, ETH_GSTRING_LEN, "%s",
@@ -1864,7 +1864,9 @@ static void i40e_get_stat_strings(struct net_device *netdev, u8 *data)
18641864
"port.rx_priority_%u_xon_2_xoff", i);
18651865
p += ETH_GSTRING_LEN;
18661866
}
1867-
/* BUG_ON(p - data != I40E_STATS_LEN * ETH_GSTRING_LEN); */
1867+
1868+
WARN_ONCE(p - data != i40e_get_stats_count(netdev) * ETH_GSTRING_LEN,
1869+
"stat strings count mismatch!");
18681870
}
18691871

18701872
static void i40e_get_priv_flag_strings(struct net_device *netdev, u8 *data)

0 commit comments

Comments
 (0)