]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
fm10k: reduce the scope of the local msg variable
authorJacob Keller <jacob.e.keller@intel.com>
Mon, 8 Jul 2019 23:12:26 +0000 (16:12 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Thu, 1 Aug 2019 21:57:38 +0000 (14:57 -0700)
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>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/fm10k/fm10k_mbx.c

index 21021fe4f1c3ffcfb9c132fab8c72753dc9df5b5..aece335b41f8b469985f9e647b79758116b94574 100644 (file)
@@ -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);