aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorBart Van Assche <bart.vanassche@wdc.com>2018-03-18 20:36:33 -0400
committerJens Axboe <axboe@kernel.dk>2018-03-18 22:15:20 -0400
commit5f2b18ec8e1643410a2369f06888951cdedea0bf (patch)
tree19fffc596284b0b162301b0020a2c873ee5d6ed5 /drivers/md
parent20d3a518713e394efa5a899c84574b4b79ec5098 (diff)
bcache: Fix a compiler warning in bcache_device_init()
Avoid that building with W=1 triggers the following compiler warning: drivers/md/bcache/super.c:776:20: warning: comparison is always false due to limited range of data type [-Wtype-limits] d->nr_stripes > SIZE_MAX / sizeof(atomic_t)) { ^ Reviewed-by: Coly Li <colyli@suse.de> Reviewed-by: Michael Lyle <mlyle@lyle.org> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/bcache/super.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 06f4b4833755..a21694788619 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -778,6 +778,8 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size,
778 sector_t sectors) 778 sector_t sectors)
779{ 779{
780 struct request_queue *q; 780 struct request_queue *q;
781 const size_t max_stripes = min_t(size_t, INT_MAX,
782 SIZE_MAX / sizeof(atomic_t));
781 size_t n; 783 size_t n;
782 int idx; 784 int idx;
783 785
@@ -786,9 +788,7 @@ static int bcache_device_init(struct bcache_device *d, unsigned block_size,
786 788
787 d->nr_stripes = DIV_ROUND_UP_ULL(sectors, d->stripe_size); 789 d->nr_stripes = DIV_ROUND_UP_ULL(sectors, d->stripe_size);
788 790
789 if (!d->nr_stripes || 791 if (!d->nr_stripes || d->nr_stripes > max_stripes) {
790 d->nr_stripes > INT_MAX ||
791 d->nr_stripes > SIZE_MAX / sizeof(atomic_t)) {
792 pr_err("nr_stripes too large or invalid: %u (start sector beyond end of disk?)", 792 pr_err("nr_stripes too large or invalid: %u (start sector beyond end of disk?)",
793 (unsigned)d->nr_stripes); 793 (unsigned)d->nr_stripes);
794 return -ENOMEM; 794 return -ENOMEM;