Message ID | 20170830184211.12471-5-bart.vanassche@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
> Il giorno 30 ago 2017, alle ore 20:42, Bart Van Assche <bart.vanassche@wdc.com> ha scritto: > > This patch avoids that the following warnings are reported when > building with W=1: > > block/bfq-iosched.c: In function 'bfq_back_seek_max_store': > block/bfq-iosched.c:4860:13: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] > if (__data < (MIN)) \ > ^ > block/bfq-iosched.c:4876:1: note: in expansion of macro 'STORE_FUNCTION' > STORE_FUNCTION(bfq_back_seek_max_store, &bfqd->bfq_back_max, 0, INT_MAX, 0); > ^~~~~~~~~~~~~~ > block/bfq-iosched.c: In function 'bfq_slice_idle_store': > block/bfq-iosched.c:4860:13: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] > if (__data < (MIN)) \ > ^ > block/bfq-iosched.c:4879:1: note: in expansion of macro 'STORE_FUNCTION' > STORE_FUNCTION(bfq_slice_idle_store, &bfqd->bfq_slice_idle, 0, INT_MAX, 2); > ^~~~~~~~~~~~~~ > block/bfq-iosched.c: In function 'bfq_slice_idle_us_store': > block/bfq-iosched.c:4892:13: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] > if (__data < (MIN)) \ > ^ > block/bfq-iosched.c:4899:1: note: in expansion of macro 'USEC_STORE_FUNCTION' > USEC_STORE_FUNCTION(bfq_slice_idle_us_store, &bfqd->bfq_slice_idle, 0, > ^~~~~~~~~~~~~~~~~~~ > > Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> > Cc: Paolo Valente <paolo.valente@linaro.org> Acked-by: Paolo Valente <paolo.valente@linaro.org> > --- > block/bfq-iosched.c | 20 ++++++++++---------- > 1 file changed, 10 insertions(+), 10 deletions(-) > > diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c > index cf92f16eb5f2..d375b29ad085 100644 > --- a/block/bfq-iosched.c > +++ b/block/bfq-iosched.c > @@ -4851,16 +4851,16 @@ static ssize_t \ > __FUNC(struct elevator_queue *e, const char *page, size_t count) \ > { \ > struct bfq_data *bfqd = e->elevator_data; \ > - unsigned long __data; \ > + unsigned long __data, __min = (MIN), __max = (MAX); \ > int ret; \ > \ > ret = bfq_var_store(&__data, (page)); \ > if (ret) \ > return ret; \ > - if (__data < (MIN)) \ > - __data = (MIN); \ > - else if (__data > (MAX)) \ > - __data = (MAX); \ > + if (__data < __min) \ > + __data = __min; \ > + else if (__data > __max) \ > + __data = __max; \ > if (__CONV == 1) \ > *(__PTR) = msecs_to_jiffies(__data); \ > else if (__CONV == 2) \ > @@ -4883,16 +4883,16 @@ STORE_FUNCTION(bfq_slice_idle_store, &bfqd->bfq_slice_idle, 0, INT_MAX, 2); > static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)\ > { \ > struct bfq_data *bfqd = e->elevator_data; \ > - unsigned long __data; \ > + unsigned long __data, __min = (MIN), __max = (MAX); \ > int ret; \ > \ > ret = bfq_var_store(&__data, (page)); \ > if (ret) \ > return ret; \ > - if (__data < (MIN)) \ > - __data = (MIN); \ > - else if (__data > (MAX)) \ > - __data = (MAX); \ > + if (__data < __min) \ > + __data = __min; \ > + else if (__data > __max) \ > + __data = __max; \ > *(__PTR) = (u64)__data * NSEC_PER_USEC; \ > return count; \ > } > -- > 2.14.1 >
diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index cf92f16eb5f2..d375b29ad085 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -4851,16 +4851,16 @@ static ssize_t \ __FUNC(struct elevator_queue *e, const char *page, size_t count) \ { \ struct bfq_data *bfqd = e->elevator_data; \ - unsigned long __data; \ + unsigned long __data, __min = (MIN), __max = (MAX); \ int ret; \ \ ret = bfq_var_store(&__data, (page)); \ if (ret) \ return ret; \ - if (__data < (MIN)) \ - __data = (MIN); \ - else if (__data > (MAX)) \ - __data = (MAX); \ + if (__data < __min) \ + __data = __min; \ + else if (__data > __max) \ + __data = __max; \ if (__CONV == 1) \ *(__PTR) = msecs_to_jiffies(__data); \ else if (__CONV == 2) \ @@ -4883,16 +4883,16 @@ STORE_FUNCTION(bfq_slice_idle_store, &bfqd->bfq_slice_idle, 0, INT_MAX, 2); static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)\ { \ struct bfq_data *bfqd = e->elevator_data; \ - unsigned long __data; \ + unsigned long __data, __min = (MIN), __max = (MAX); \ int ret; \ \ ret = bfq_var_store(&__data, (page)); \ if (ret) \ return ret; \ - if (__data < (MIN)) \ - __data = (MIN); \ - else if (__data > (MAX)) \ - __data = (MAX); \ + if (__data < __min) \ + __data = __min; \ + else if (__data > __max) \ + __data = __max; \ *(__PTR) = (u64)__data * NSEC_PER_USEC; \ return count; \ }
This patch avoids that the following warnings are reported when building with W=1: block/bfq-iosched.c: In function 'bfq_back_seek_max_store': block/bfq-iosched.c:4860:13: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] if (__data < (MIN)) \ ^ block/bfq-iosched.c:4876:1: note: in expansion of macro 'STORE_FUNCTION' STORE_FUNCTION(bfq_back_seek_max_store, &bfqd->bfq_back_max, 0, INT_MAX, 0); ^~~~~~~~~~~~~~ block/bfq-iosched.c: In function 'bfq_slice_idle_store': block/bfq-iosched.c:4860:13: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] if (__data < (MIN)) \ ^ block/bfq-iosched.c:4879:1: note: in expansion of macro 'STORE_FUNCTION' STORE_FUNCTION(bfq_slice_idle_store, &bfqd->bfq_slice_idle, 0, INT_MAX, 2); ^~~~~~~~~~~~~~ block/bfq-iosched.c: In function 'bfq_slice_idle_us_store': block/bfq-iosched.c:4892:13: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] if (__data < (MIN)) \ ^ block/bfq-iosched.c:4899:1: note: in expansion of macro 'USEC_STORE_FUNCTION' USEC_STORE_FUNCTION(bfq_slice_idle_us_store, &bfqd->bfq_slice_idle, 0, ^~~~~~~~~~~~~~~~~~~ Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> Cc: Paolo Valente <paolo.valente@linaro.org> --- block/bfq-iosched.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)