All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alice Michael <alice.michael@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [next PATCH S93 08/11] i40e: fix warning about shadowed ring parameter
Date: Tue, 31 Jul 2018 03:41:45 -0700	[thread overview]
Message-ID: <20180731104148.11896-8-alice.michael@intel.com> (raw)
In-Reply-To: <20180731104148.11896-1-alice.michael@intel.com>

From: Jacob Keller <jacob.e.keller@intel.com>

In commit 147e81ec7568 ("i40e: Test memory before ethtool alloc succeeds")
code was added to handle ring allocation on systems with low memory.

It shadowed the ring parameter pointer by introducing a local ring
pointer inside the for loop. Most of the code in the loop already just
accessed the ring via &rx_rings[i]. Since most of the code already does
this, just remove the local variable.

If someone considers it worth keeping a local around, they should use it
for the whole section instead of just a couple of accesses.

This fixes a warning when -Wshadow is enabled

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
---
 drivers/net/ethernet/intel/i40e/i40e_ethtool.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index 12d279a..cd23d1e 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -1589,7 +1589,6 @@ static int i40e_set_ringparam(struct net_device *netdev,
 		}
 
 		for (i = 0; i < vsi->num_queue_pairs; i++) {
-			struct i40e_ring *ring;
 			u16 unused;
 
 			/* clone ring and setup updated count */
@@ -1613,9 +1612,8 @@ static int i40e_set_ringparam(struct net_device *netdev,
 			/* now allocate the Rx buffers to make sure the OS
 			 * has enough memory, any failure here means abort
 			 */
-			ring = &rx_rings[i];
-			unused = I40E_DESC_UNUSED(ring);
-			err = i40e_alloc_rx_buffers(ring, unused);
+			unused = I40E_DESC_UNUSED(&rx_rings[i]);
+			err = i40e_alloc_rx_buffers(&rx_rings[i], unused);
 rx_unwind:
 			if (err) {
 				do {
-- 
2.9.5


  parent reply	other threads:[~2018-07-31 10:41 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-31 10:41 [Intel-wired-lan] [next PATCH S93 01/11] i40e: add helper function for copying strings from stat arrays Alice Michael
2018-07-31 10:41 ` [Intel-wired-lan] [next PATCH S93 02/11] i40e: add helper to copy statistic values into ethtool buffer Alice Michael
2018-08-02 18:29   ` Bowers, AndrewX
2018-07-31 10:41 ` [Intel-wired-lan] [next PATCH S93 03/11] i40e: Set fec_config when forcing link state Alice Michael
2018-08-02 18:30   ` Bowers, AndrewX
2018-07-31 10:41 ` [Intel-wired-lan] [next PATCH S93 04/11] i40e: convert VEB TC stats to use an i40e_stats array Alice Michael
2018-08-02 18:30   ` Bowers, AndrewX
2018-07-31 10:41 ` [Intel-wired-lan] [next PATCH S93 05/11] i40e: convert priority flow control stats to use helpers Alice Michael
2018-08-02 18:31   ` Bowers, AndrewX
2018-07-31 10:41 ` [Intel-wired-lan] [next PATCH S93 06/11] i40e: Write access protected registers through AQC Alice Michael
2018-08-02 18:31   ` Bowers, AndrewX
2018-07-31 10:41 ` [Intel-wired-lan] [next PATCH S93 07/11] i40e: remove unnecessary i variable causing -Wshadow warning Alice Michael
2018-08-02 18:32   ` Bowers, AndrewX
2018-07-31 10:41 ` Alice Michael [this message]
2018-08-02 18:33   ` [Intel-wired-lan] [next PATCH S93 08/11] i40e: fix warning about shadowed ring parameter Bowers, AndrewX
2018-07-31 10:41 ` [Intel-wired-lan] [next PATCH S93 09/11] i40e: Add additional return code to i40e_asq_send_command Alice Michael
2018-08-02 18:33   ` Bowers, AndrewX
2018-07-31 10:41 ` [Intel-wired-lan] [next PATCH S93 10/11] i40e: Add AQ command for rearrange NVM structure Alice Michael
2018-08-02 18:34   ` Bowers, AndrewX
2018-07-31 10:41 ` [Intel-wired-lan] [next PATCH S93 11/11] i40e: fix i40e_add_queue_stats data pointer update Alice Michael
2018-08-02 18:34   ` Bowers, AndrewX
2018-08-02 18:29 ` [Intel-wired-lan] [next PATCH S93 01/11] i40e: add helper function for copying strings from stat arrays Bowers, AndrewX

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180731104148.11896-8-alice.michael@intel.com \
    --to=alice.michael@intel.com \
    --cc=intel-wired-lan@osuosl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.