diff mbox

btrfs: fix size_t format string

Message ID 20180717135236.3673195-1-arnd@arndb.de (mailing list archive)
State New, archived
Headers show

Commit Message

Arnd Bergmann July 17, 2018, 1:52 p.m. UTC
The newly added check_block_group_item() function causes a build warning
on 32-bit architectures:

fs/btrfs/tree-checker.c: In function 'check_block_group_item':
fs/btrfs/tree-checker.c:404:41: error: format '%lu' expects argument of type 'long unsigned int', but argument 6 has type 'unsigned int' [-Werror=format=]

The type of a sizeof() expression is size_t, which is correctly printed
using the %zu format string.

Fixes: 9dc16aad5660 ("btrfs: tree-checker: Verify block_group_item")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/btrfs/tree-checker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Qu Wenruo July 17, 2018, 2:33 p.m. UTC | #1
On 2018年07月17日 21:52, Arnd Bergmann wrote:
> The newly added check_block_group_item() function causes a build warning
> on 32-bit architectures:
> 
> fs/btrfs/tree-checker.c: In function 'check_block_group_item':
> fs/btrfs/tree-checker.c:404:41: error: format '%lu' expects argument of type 'long unsigned int', but argument 6 has type 'unsigned int' [-Werror=format=]
> 
> The type of a sizeof() expression is size_t, which is correctly printed
> using the %zu format string.
> 
> Fixes: 9dc16aad5660 ("btrfs: tree-checker: Verify block_group_item")

My fault again. :(

Is there anyway to make gcc report such problem even under x86_64?

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>  fs/btrfs/tree-checker.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
> index e9414c3f375e..4c82a628df85 100644
> --- a/fs/btrfs/tree-checker.c
> +++ b/fs/btrfs/tree-checker.c
> @@ -401,7 +401,7 @@ static int check_block_group_item(struct btrfs_fs_info *fs_info,
>  
>  	if (item_size != sizeof(bgi)) {
>  		block_group_err(fs_info, leaf, slot,
> -			"invalid item size, have %u expect %lu",
> +			"invalid item size, have %u expect %zu",
>  				item_size, sizeof(bgi));
>  		return -EUCLEAN;
>  	}
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Sterba July 17, 2018, 3:04 p.m. UTC | #2
On Tue, Jul 17, 2018 at 03:52:27PM +0200, Arnd Bergmann wrote:
> The newly added check_block_group_item() function causes a build warning
> on 32-bit architectures:
> 
> fs/btrfs/tree-checker.c: In function 'check_block_group_item':
> fs/btrfs/tree-checker.c:404:41: error: format '%lu' expects argument of type 'long unsigned int', but argument 6 has type 'unsigned int' [-Werror=format=]
> 
> The type of a sizeof() expression is size_t, which is correctly printed
> using the %zu format string.
> 
> Fixes: 9dc16aad5660 ("btrfs: tree-checker: Verify block_group_item")

Folded to the commit, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Arnd Bergmann July 17, 2018, 4:02 p.m. UTC | #3
On Tue, Jul 17, 2018 at 4:33 PM, Qu Wenruo <quwenruo.btrfs@gmx.com> wrote:
>
>
> On 2018年07月17日 21:52, Arnd Bergmann wrote:
>> The newly added check_block_group_item() function causes a build warning
>> on 32-bit architectures:
>>
>> fs/btrfs/tree-checker.c: In function 'check_block_group_item':
>> fs/btrfs/tree-checker.c:404:41: error: format '%lu' expects argument of type 'long unsigned int', but argument 6 has type 'unsigned int' [-Werror=format=]
>>
>> The type of a sizeof() expression is size_t, which is correctly printed
>> using the %zu format string.
>>
>> Fixes: 9dc16aad5660 ("btrfs: tree-checker: Verify block_group_item")
>
> My fault again. :(
>
> Is there anyway to make gcc report such problem even under x86_64?

I don't think so. However, if you post a patch to the mainling list, the
0-day bot should report any build regressions within a day.

      Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Randy Dunlap July 23, 2018, 5:07 p.m. UTC | #4
On 07/17/2018 08:04 AM, David Sterba wrote:
> On Tue, Jul 17, 2018 at 03:52:27PM +0200, Arnd Bergmann wrote:
>> The newly added check_block_group_item() function causes a build warning
>> on 32-bit architectures:
>>
>> fs/btrfs/tree-checker.c: In function 'check_block_group_item':
>> fs/btrfs/tree-checker.c:404:41: error: format '%lu' expects argument of type 'long unsigned int', but argument 6 has type 'unsigned int' [-Werror=format=]
>>
>> The type of a sizeof() expression is size_t, which is correctly printed
>> using the %zu format string.
>>
>> Fixes: 9dc16aad5660 ("btrfs: tree-checker: Verify block_group_item")
> 
> Folded to the commit, thanks.
> 

Hi David,
Where did this patch end up?  linux-next-20180723 is still showing this
format warning.

thanks,
David Sterba July 24, 2018, 8:19 a.m. UTC | #5
On Mon, Jul 23, 2018 at 10:07:42AM -0700, Randy Dunlap wrote:
> On 07/17/2018 08:04 AM, David Sterba wrote:
> > On Tue, Jul 17, 2018 at 03:52:27PM +0200, Arnd Bergmann wrote:
> >> The newly added check_block_group_item() function causes a build warning
> >> on 32-bit architectures:
> >>
> >> fs/btrfs/tree-checker.c: In function 'check_block_group_item':
> >> fs/btrfs/tree-checker.c:404:41: error: format '%lu' expects argument of type 'long unsigned int', but argument 6 has type 'unsigned int' [-Werror=format=]
> >>
> >> The type of a sizeof() expression is size_t, which is correctly printed
> >> using the %zu format string.
> >>
> >> Fixes: 9dc16aad5660 ("btrfs: tree-checker: Verify block_group_item")
> > 
> > Folded to the commit, thanks.
> > 
> 
> Hi David,
> Where did this patch end up?  linux-next-20180723 is still showing this
> format warning.

It's still in a local branch, I haven't pushed for-next for a few days
but will do today.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index e9414c3f375e..4c82a628df85 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -401,7 +401,7 @@  static int check_block_group_item(struct btrfs_fs_info *fs_info,
 
 	if (item_size != sizeof(bgi)) {
 		block_group_err(fs_info, leaf, slot,
-			"invalid item size, have %u expect %lu",
+			"invalid item size, have %u expect %zu",
 				item_size, sizeof(bgi));
 		return -EUCLEAN;
 	}