diff mbox

bvec: avoid variable shadowing warning

Message ID 1470903356-22381-1-git-send-email-johannes@sipsolutions.net (mailing list archive)
State New, archived
Headers show

Commit Message

Johannes Berg Aug. 11, 2016, 8:15 a.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

Due to the (indirect) nesting of min(..., min(...)), sparse will
show a variable shadowing warning whenever bvec.h is included.

Avoid that by assigning the inner min() to a temporary variable first.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 include/linux/bvec.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jens Axboe Aug. 11, 2016, 3:41 p.m. UTC | #1
On 08/11/2016 02:15 AM, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
>
> Due to the (indirect) nesting of min(..., min(...)), sparse will
> show a variable shadowing warning whenever bvec.h is included.
>
> Avoid that by assigning the inner min() to a temporary variable first.

Grumble, reluctantly applied :-)
diff mbox

Patch

diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index 701b64a3b7c5..89b65b82d98f 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -74,7 +74,8 @@  static inline void bvec_iter_advance(const struct bio_vec *bv,
 		  "Attempted to advance past end of bvec iter\n");
 
 	while (bytes) {
-		unsigned len = min(bytes, bvec_iter_len(bv, *iter));
+		unsigned iter_len = bvec_iter_len(bv, *iter);
+		unsigned len = min(bytes, iter_len);
 
 		bytes -= len;
 		iter->bi_size -= len;