All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] bvec: avoid variable shadowing warning
@ 2016-08-11  8:15 Johannes Berg
  2016-08-11 15:41 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Johannes Berg @ 2016-08-11  8:15 UTC (permalink / raw)
  To: linux-block; +Cc: Ming Lei, Jens Axboe, Johannes Berg

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(-)

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;
-- 
2.8.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] bvec: avoid variable shadowing warning
  2016-08-11  8:15 [PATCH] bvec: avoid variable shadowing warning Johannes Berg
@ 2016-08-11 15:41 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2016-08-11 15:41 UTC (permalink / raw)
  To: Johannes Berg, linux-block; +Cc: Ming Lei, Jens Axboe, Johannes Berg

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 :-)

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-11 15:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-11  8:15 [PATCH] bvec: avoid variable shadowing warning Johannes Berg
2016-08-11 15:41 ` Jens Axboe

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.