Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jacob Keller <jacob.e.keller@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH 09/19] fm10k: reduce the scope of the local msg variable
Date: Mon,  8 Jul 2019 16:12:26 -0700	[thread overview]
Message-ID: <20190708231236.20516-10-jacob.e.keller@intel.com> (raw)
In-Reply-To: <20190708231236.20516-1-jacob.e.keller@intel.com>

The msg variable in the fm10k_mbx_validate_msg_size and
fm10k_sm_mbx_transmit functions is only used within the do {} loop
scope. Reduce its scope only to where it is used.

This was detected by cppcheck, and resolves the following warnings
produced by that tool:

[fm10k_mbx.c:299]: (style) The scope of the variable 'msg' can be reduced.
[fm10k_mbx.c:2004]: (style) The scope of the variable 'msg' can be reduced.

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

diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_mbx.c b/drivers/net/ethernet/intel/fm10k/fm10k_mbx.c
index 21021fe4f1c3..aece335b41f8 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_mbx.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_mbx.c
@@ -297,13 +297,14 @@ static u16 fm10k_mbx_validate_msg_size(struct fm10k_mbx_info *mbx, u16 len)
 {
 	struct fm10k_mbx_fifo *fifo = &mbx->rx;
 	u16 total_len = 0, msg_len;
-	u32 *msg;
 
 	/* length should include previous amounts pushed */
 	len += mbx->pushed;
 
 	/* offset in message is based off of current message size */
 	do {
+		u32 *msg;
+
 		msg = fifo->buffer + fm10k_fifo_tail_offset(fifo, total_len);
 		msg_len = FM10K_TLV_DWORD_LEN(*msg);
 		total_len += msg_len;
@@ -1920,7 +1921,6 @@ static void fm10k_sm_mbx_transmit(struct fm10k_hw *hw,
 	/* reduce length by 1 to convert to a mask */
 	u16 mbmem_len = mbx->mbmem_len - 1;
 	u16 tail_len, len = 0;
-	u32 *msg;
 
 	/* push head behind tail */
 	if (mbx->tail < head)
@@ -1930,6 +1930,8 @@ static void fm10k_sm_mbx_transmit(struct fm10k_hw *hw,
 
 	/* determine msg aligned offset for end of buffer */
 	do {
+		u32 *msg;
+
 		msg = fifo->buffer + fm10k_fifo_head_offset(fifo, len);
 		tail_len = len;
 		len += FM10K_TLV_DWORD_LEN(*msg);
-- 
2.22.0.214.g8dca754b1e87


  parent reply	other threads:[~2019-07-08 23:12 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-08 23:12 [Intel-wired-lan] [PATCH 00/19] cleanup cppcheck warnings for fm10k driver Jacob Keller
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 01/19] fm10k: reduce scope of the err variable Jacob Keller
2019-07-12 17:59   ` Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 02/19] fm10k: reduce scope of *p local variable Jacob Keller
2019-07-12 17:59   ` Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 03/19] fm10k: reduce the scope of qv " Jacob Keller
2019-07-12 18:00   ` Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 04/19] fm10k: reduce the scope of local err variable Jacob Keller
2019-07-12 18:00   ` Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 05/19] fm10k: reduce the scope of the q_idx local variable Jacob Keller
2019-07-12 18:01   ` Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 06/19] fm10k: reduce the scope of the tx_buffer variable Jacob Keller
2019-07-12 18:02   ` Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 07/19] fm10k: reduce the scope of the err variable Jacob Keller
2019-07-12 18:02   ` Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 08/19] fm10k: reduce the scope of the local i variable Jacob Keller
2019-07-12 18:02   ` Bowers, AndrewX
2019-07-08 23:12 ` Jacob Keller [this message]
2019-07-12 18:03   ` [Intel-wired-lan] [PATCH 09/19] fm10k: reduce the scope of the local msg variable Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 10/19] fm10k: reduce the scope of the result local variable Jacob Keller
2019-07-12 18:04   ` Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 11/19] fm10k: reduce scope of the ring variable Jacob Keller
2019-07-12 18:04   ` Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 12/19] fm10k: remove unnecessary variable initializer Jacob Keller
2019-07-12 18:05   ` Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 13/19] fm10k: remove needless assignment of err local variable Jacob Keller
2019-07-12 18:05   ` Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 14/19] fm10k: remove needless initialization of size " Jacob Keller
2019-07-12 18:06   ` Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 15/19] fm10k: explicitly return 0 on success path in function Jacob Keller
2019-07-12 18:06   ` Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 16/19] fm10k: cast page_addr to u8 * when incrementing it Jacob Keller
2019-07-12 18:07   ` Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 17/19] fm10k: mark unused parameters with __always_unused Jacob Keller
2019-07-12 18:07   ` Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 18/19] fm10k: convert NON_Q_VECTORS(hw) into NON_Q_VECTORS Jacob Keller
2019-07-12 18:08   ` Bowers, AndrewX
2019-07-08 23:12 ` [Intel-wired-lan] [PATCH 19/19] fm10k: fix fm10k_get_fault_pf to read correct address Jacob Keller
2019-07-12 18:08   ` 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=20190708231236.20516-10-jacob.e.keller@intel.com \
    --to=jacob.e.keller@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox