[Drbd-dev] [PATCH] DRDB: Fix comparison always false warning due to long/long long compare

Lars Ellenberg lars.ellenberg at linbit.com
Wed Jun 15 12:09:18 CEST 2011


On Wed, Jun 15, 2011 at 12:59:04AM +0100, David Howells wrote:
> Fix warnings of the following nature in the drbd header:
> 
> In file included from drivers/block/drbd/drbd_bitmap.c:32:
> drivers/block/drbd/drbd_int.h: In function 'drbd_get_syncer_progress':
> drivers/block/drbd/drbd_int.h:2234: warning: comparison is always false due to limited range of data
> 
> where mdev->rs_total (an unsigned long) is being compared to 1ULL << 32, which
> is always false on a 32-bit machine.

Ack.  Though you also fell for the most frequent DRBD misspellings in
the subject ;-)

Jens, we will prepare an other tree for you to pull from next week,
with this and a few other small DRBD fixes in it, if that's ok with you.


	Lars

> Signed-off-by: David Howells <dhowells at redhat.com>
> cc: Philipp Reisner <philipp.reisner at linbit.com>
> cc: Lars Ellenberg <lars.ellenberg at linbit.com>
> cc: drbd-dev at lists.linbit.com
> cc: Jens Axboe <axboe at kernel.dk>
> ---
> 
>  drivers/block/drbd/drbd_int.h |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
> index ef2ceed..2e0278d 100644
> --- a/drivers/block/drbd/drbd_int.h
> +++ b/drivers/block/drbd/drbd_int.h
> @@ -2231,7 +2231,7 @@ static inline void drbd_get_syncer_progress(struct drbd_conf *mdev,
>  		 * Note: currently we don't support such large bitmaps on 32bit
>  		 * arch anyways, but no harm done to be prepared for it here.
>  		 */
> -		unsigned int shift = mdev->rs_total >= (1ULL << 32) ? 16 : 10;
> +		unsigned int shift = mdev->rs_total > UINT_MAX ? 16 : 10;
>  		unsigned long left = *bits_left >> shift;
>  		unsigned long total = 1UL + (mdev->rs_total >> shift);
>  		unsigned long tmp = 1000UL - left * 1000UL/total;


More information about the drbd-dev mailing list