Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1243301 > unrolled thread

[PATCH] md: fix 32-bit build warning

Started byArnd Bergmann <arnd@arndb.de>
First post2015-10-09 14:20 +0200
Last post2015-10-15 00:20 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] md: fix 32-bit build warning Arnd Bergmann <arnd@arndb.de> - 2015-10-09 14:20 +0200
    Re: [PATCH] md: fix 32-bit build warning Neil Brown <neilb@suse.com> - 2015-10-12 07:10 +0200
      Re: [PATCH] md: fix 32-bit build warning Arnd Bergmann <arnd@arndb.de> - 2015-10-12 11:40 +0200
        Re: [PATCH] md: fix 32-bit build warning Neil Brown <neilb@suse.com> - 2015-10-15 00:20 +0200

#1243301 — [PATCH] md: fix 32-bit build warning

FromArnd Bergmann <arnd@arndb.de>
Date2015-10-09 14:20 +0200
Subject[PATCH] md: fix 32-bit build warning
Message-ID<qhEOt-1Qq-13@gated-at.bofh.it>
On 32-bit architectures, the md code produces this warning when CONFIG_LDAF
is set:

drivers/md/md.c: In function 'check_sb_changes':
drivers/md/md.c:8990:10: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'sector_t {aka long long unsigned int}' [-Wformat=]
   pr_info("%s:%d recovery_cp changed from %lu to %lu\n", __func__,

The code was only recently introduced, and uses the wrong format string
for sector_t. As a workaround, this patch adds an explicit cast to 'u64'
so we can use the %llu format string on all architectures.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: e0212320066e ("md-cluster: Improve md_reload_sb to be less error prone")
Cc: Goldwyn Rodrigues <rgoldwyn@suse.com>
---

I also noticed that some commmits in md/for-next including the one causing
the problem lack a Signed-off-by line. It might make sense to just fold this
patch and add the lines at the same time.

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 7fff1e6884d6..e13f72a3b561 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -8987,9 +8987,9 @@ static void check_sb_changes(struct mddev *mddev, struct md_rdev *rdev)
 
 	/* recovery_cp changed */
 	if (le64_to_cpu(sb->resync_offset) != mddev->recovery_cp) {
-		pr_info("%s:%d recovery_cp changed from %lu to %lu\n", __func__,
-				__LINE__, mddev->recovery_cp,
-				(unsigned long) le64_to_cpu(sb->resync_offset));
+		pr_info("%s:%d recovery_cp changed from %llu to %llu\n", __func__,
+				__LINE__, (u64)mddev->recovery_cp,
+				(u64) le64_to_cpu(sb->resync_offset));
 		mddev->recovery_cp = le64_to_cpu(sb->resync_offset);
 	}
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1244384

FromNeil Brown <neilb@suse.com>
Date2015-10-12 07:10 +0200
Message-ID<qiDwZ-5Nl-1@gated-at.bofh.it>
In reply to#1243301

[Multipart message — attachments visible in raw view] — view raw

Arnd Bergmann <arnd@arndb.de> writes:

> On 32-bit architectures, the md code produces this warning when CONFIG_LDAF
> is set:
>
> drivers/md/md.c: In function 'check_sb_changes':
> drivers/md/md.c:8990:10: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'sector_t {aka long long unsigned int}' [-Wformat=]
>    pr_info("%s:%d recovery_cp changed from %lu to %lu\n", __func__,
>
> The code was only recently introduced, and uses the wrong format string
> for sector_t. As a workaround, this patch adds an explicit cast to 'u64'
> so we can use the %llu format string on all architectures.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: e0212320066e ("md-cluster: Improve md_reload_sb to be less error prone")
> Cc: Goldwyn Rodrigues <rgoldwyn@suse.com>
> ---
>
> I also noticed that some commmits in md/for-next including the one causing
> the problem lack a Signed-off-by line. It might make sense to just fold this
> patch and add the lines at the same time.
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 7fff1e6884d6..e13f72a3b561 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -8987,9 +8987,9 @@ static void check_sb_changes(struct mddev *mddev, struct md_rdev *rdev)
>  
>  	/* recovery_cp changed */
>  	if (le64_to_cpu(sb->resync_offset) != mddev->recovery_cp) {
> -		pr_info("%s:%d recovery_cp changed from %lu to %lu\n", __func__,
> -				__LINE__, mddev->recovery_cp,
> -				(unsigned long) le64_to_cpu(sb->resync_offset));
> +		pr_info("%s:%d recovery_cp changed from %llu to %llu\n", __func__,
> +				__LINE__, (u64)mddev->recovery_cp,
> +				(u64) le64_to_cpu(sb->resync_offset));
>  		mddev->recovery_cp = le64_to_cpu(sb->resync_offset);
>  	}
>  

Thanks, but is this really right?
I think u64 is "unsigned long" on 64bit.
I have always used (unsigned long long) when I want to use %llu on
sector_t.

How confident are you of using "u64" ?

Thanks,
NeilBrown

[toc] | [prev] | [next] | [standalone]


#1244537

FromArnd Bergmann <arnd@arndb.de>
Date2015-10-12 11:40 +0200
Message-ID<qiHKj-3k0-25@gated-at.bofh.it>
In reply to#1244384
On Monday 12 October 2015 15:59:27 Neil Brown wrote:
> > diff --git a/drivers/md/md.c b/drivers/md/md.c
> > index 7fff1e6884d6..e13f72a3b561 100644
> > --- a/drivers/md/md.c
> > +++ b/drivers/md/md.c
> > @@ -8987,9 +8987,9 @@ static void check_sb_changes(struct mddev *mddev, struct md_rdev *rdev)
> >  
> >       /* recovery_cp changed */
> >       if (le64_to_cpu(sb->resync_offset) != mddev->recovery_cp) {
> > -             pr_info("%s:%d recovery_cp changed from %lu to %lu\n", __func__,
> > -                             __LINE__, mddev->recovery_cp,
> > -                             (unsigned long) le64_to_cpu(sb->resync_offset));
> > +             pr_info("%s:%d recovery_cp changed from %llu to %llu\n", __func__,
> > +                             __LINE__, (u64)mddev->recovery_cp,
> > +                             (u64) le64_to_cpu(sb->resync_offset));
> >               mddev->recovery_cp = le64_to_cpu(sb->resync_offset);
> >       }
> >  
> 
> Thanks, but is this really right?
> I think u64 is "unsigned long" on 64bit.
> I have always used (unsigned long long) when I want to use %llu on
> sector_t.
> 
> How confident are you of using "u64" ?

Very confident ;-)

This used to not work until some linux-2.6 version when we changed all
architectures to use asm-generic/int-ll64.h in the kernel, because
a lot of code relied on printing u64 variables using %lld.

I tend to use u64 for things like this because it's shorter than
'unsigned long long'.

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1247222

FromNeil Brown <neilb@suse.com>
Date2015-10-15 00:20 +0200
Message-ID<qjCyS-3Hc-9@gated-at.bofh.it>
In reply to#1244537

[Multipart message — attachments visible in raw view] — view raw

Arnd Bergmann <arnd@arndb.de> writes:

> On Monday 12 October 2015 15:59:27 Neil Brown wrote:
>> > diff --git a/drivers/md/md.c b/drivers/md/md.c
>> > index 7fff1e6884d6..e13f72a3b561 100644
>> > --- a/drivers/md/md.c
>> > +++ b/drivers/md/md.c
>> > @@ -8987,9 +8987,9 @@ static void check_sb_changes(struct mddev *mddev, struct md_rdev *rdev)
>> >  
>> >       /* recovery_cp changed */
>> >       if (le64_to_cpu(sb->resync_offset) != mddev->recovery_cp) {
>> > -             pr_info("%s:%d recovery_cp changed from %lu to %lu\n", __func__,
>> > -                             __LINE__, mddev->recovery_cp,
>> > -                             (unsigned long) le64_to_cpu(sb->resync_offset));
>> > +             pr_info("%s:%d recovery_cp changed from %llu to %llu\n", __func__,
>> > +                             __LINE__, (u64)mddev->recovery_cp,
>> > +                             (u64) le64_to_cpu(sb->resync_offset));
>> >               mddev->recovery_cp = le64_to_cpu(sb->resync_offset);
>> >       }
>> >  
>> 
>> Thanks, but is this really right?
>> I think u64 is "unsigned long" on 64bit.
>> I have always used (unsigned long long) when I want to use %llu on
>> sector_t.
>> 
>> How confident are you of using "u64" ?
>
> Very confident ;-)
>
> This used to not work until some linux-2.6 version when we changed all
> architectures to use asm-generic/int-ll64.h in the kernel, because
> a lot of code relied on printing u64 variables using %lld.
>
> I tend to use u64 for things like this because it's shorter than
> 'unsigned long long'.
>

Ahh.. good to know - thanks.

It seems that we've since removed those 'pr_info' lines, so there is
nothing to fix any more.  I'll remember that about using "u64" though -
using "unsigned long long" always felt so clumsy.

Thanks,
NeilBrown

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web