diff mbox series

xfs: Fix format specifier for max_folio_size in xfs_fs_fill_super()

Message ID 20240827-xfs-fix-wformat-bs-gt-ps-v1-1-aec6717609e0@kernel.org (mailing list archive)
State New
Headers show
Series xfs: Fix format specifier for max_folio_size in xfs_fs_fill_super() | expand

Commit Message

Nathan Chancellor Aug. 27, 2024, 11:15 p.m. UTC
When building for a 32-bit architecture, where 'size_t' is 'unsigned
int', there is a warning due to use of '%ld', the specifier for a 'long
int':

  In file included from fs/xfs/xfs_linux.h:82,
                   from fs/xfs/xfs.h:26,
                   from fs/xfs/xfs_super.c:7:
  fs/xfs/xfs_super.c: In function 'xfs_fs_fill_super':
  fs/xfs/xfs_super.c:1654:1: error: format '%ld' expects argument of type 'long int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
   1654 | "block size (%u bytes) not supported; Only block size (%ld) or less is supported",
        | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   1655 |                                 mp->m_sb.sb_blocksize, max_folio_size);
        |                                                        ~~~~~~~~~~~~~~
        |                                                        |
        |                                                        size_t {aka unsigned int}
  ...
  fs/xfs/xfs_super.c:1654:58: note: format string is defined here
   1654 | "block size (%u bytes) not supported; Only block size (%ld) or less is supported",
        |                                                        ~~^
        |                                                          |
        |                                                          long int
        |                                                        %d

Use the proper 'size_t' specifier, '%zu', to resolve the warning.

Fixes: 0ab3ca31b012 ("xfs: enable block size larger than page size support")
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 fs/xfs/xfs_super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


---
base-commit: f143d1a48d6ecce12f5bced0d18a10a0294726b5
change-id: 20240827-xfs-fix-wformat-bs-gt-ps-967f3aa1c142

Best regards,

Comments

Darrick J. Wong Aug. 27, 2024, 11:47 p.m. UTC | #1
On Tue, Aug 27, 2024 at 04:15:05PM -0700, Nathan Chancellor wrote:
> When building for a 32-bit architecture, where 'size_t' is 'unsigned
> int', there is a warning due to use of '%ld', the specifier for a 'long
> int':
> 
>   In file included from fs/xfs/xfs_linux.h:82,
>                    from fs/xfs/xfs.h:26,
>                    from fs/xfs/xfs_super.c:7:
>   fs/xfs/xfs_super.c: In function 'xfs_fs_fill_super':
>   fs/xfs/xfs_super.c:1654:1: error: format '%ld' expects argument of type 'long int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
>    1654 | "block size (%u bytes) not supported; Only block size (%ld) or less is supported",
>         | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    1655 |                                 mp->m_sb.sb_blocksize, max_folio_size);
>         |                                                        ~~~~~~~~~~~~~~
>         |                                                        |
>         |                                                        size_t {aka unsigned int}
>   ...
>   fs/xfs/xfs_super.c:1654:58: note: format string is defined here
>    1654 | "block size (%u bytes) not supported; Only block size (%ld) or less is supported",
>         |                                                        ~~^
>         |                                                          |
>         |                                                          long int
>         |                                                        %d
> 
> Use the proper 'size_t' specifier, '%zu', to resolve the warning.
> 
> Fixes: 0ab3ca31b012 ("xfs: enable block size larger than page size support")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Yep.
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/xfs_super.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 242271298a33..e8cc7900911e 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -1651,7 +1651,7 @@ xfs_fs_fill_super(
>  
>  		if (mp->m_sb.sb_blocksize > max_folio_size) {
>  			xfs_warn(mp,
> -"block size (%u bytes) not supported; Only block size (%ld) or less is supported",
> +"block size (%u bytes) not supported; Only block size (%zu) or less is supported",
>  				mp->m_sb.sb_blocksize, max_folio_size);
>  			error = -ENOSYS;
>  			goto out_free_sb;
> 
> ---
> base-commit: f143d1a48d6ecce12f5bced0d18a10a0294726b5
> change-id: 20240827-xfs-fix-wformat-bs-gt-ps-967f3aa1c142
> 
> Best regards,
> -- 
> Nathan Chancellor <nathan@kernel.org>
> 
>
Pankaj Raghav (Samsung) Aug. 28, 2024, 10:23 a.m. UTC | #2
On Tue, Aug 27, 2024 at 04:15:05PM -0700, Nathan Chancellor wrote:
> When building for a 32-bit architecture, where 'size_t' is 'unsigned
> int', there is a warning due to use of '%ld', the specifier for a 'long
> int':
> 
>   In file included from fs/xfs/xfs_linux.h:82,
>                    from fs/xfs/xfs.h:26,
>                    from fs/xfs/xfs_super.c:7:
>   fs/xfs/xfs_super.c: In function 'xfs_fs_fill_super':
>   fs/xfs/xfs_super.c:1654:1: error: format '%ld' expects argument of type 'long int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
>    1654 | "block size (%u bytes) not supported; Only block size (%ld) or less is supported",
>         | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    1655 |                                 mp->m_sb.sb_blocksize, max_folio_size);
>         |                                                        ~~~~~~~~~~~~~~
>         |                                                        |
>         |                                                        size_t {aka unsigned int}
>   ...
>   fs/xfs/xfs_super.c:1654:58: note: format string is defined here
>    1654 | "block size (%u bytes) not supported; Only block size (%ld) or less is supported",
>         |                                                        ~~^
>         |                                                          |
>         |                                                          long int
>         |                                                        %d
> 
> Use the proper 'size_t' specifier, '%zu', to resolve the warning.
> 
> Fixes: 0ab3ca31b012 ("xfs: enable block size larger than page size support")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Looks good,
Reviewed-by: Pankaj Raghav <p.raghav@samsung.com>

> ---
>  fs/xfs/xfs_super.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 242271298a33..e8cc7900911e 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -1651,7 +1651,7 @@ xfs_fs_fill_super(
>  
>  		if (mp->m_sb.sb_blocksize > max_folio_size) {
>  			xfs_warn(mp,
> -"block size (%u bytes) not supported; Only block size (%ld) or less is supported",
> +"block size (%u bytes) not supported; Only block size (%zu) or less is supported",
>  				mp->m_sb.sb_blocksize, max_folio_size);
>  			error = -ENOSYS;
>  			goto out_free_sb;
> 
> ---
> base-commit: f143d1a48d6ecce12f5bced0d18a10a0294726b5
> change-id: 20240827-xfs-fix-wformat-bs-gt-ps-967f3aa1c142
> 
> Best regards,
> -- 
> Nathan Chancellor <nathan@kernel.org>
>
Luis Chamberlain Aug. 28, 2024, 9:26 p.m. UTC | #3
On Tue, Aug 27, 2024 at 04:15:05PM -0700, Nathan Chancellor wrote:
> When building for a 32-bit architecture, where 'size_t' is 'unsigned
> int', there is a warning due to use of '%ld', the specifier for a 'long
> int':
> 
>   In file included from fs/xfs/xfs_linux.h:82,
>                    from fs/xfs/xfs.h:26,
>                    from fs/xfs/xfs_super.c:7:
>   fs/xfs/xfs_super.c: In function 'xfs_fs_fill_super':
>   fs/xfs/xfs_super.c:1654:1: error: format '%ld' expects argument of type 'long int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
>    1654 | "block size (%u bytes) not supported; Only block size (%ld) or less is supported",
>         | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    1655 |                                 mp->m_sb.sb_blocksize, max_folio_size);
>         |                                                        ~~~~~~~~~~~~~~
>         |                                                        |
>         |                                                        size_t {aka unsigned int}
>   ...
>   fs/xfs/xfs_super.c:1654:58: note: format string is defined here
>    1654 | "block size (%u bytes) not supported; Only block size (%ld) or less is supported",
>         |                                                        ~~^
>         |                                                          |
>         |                                                          long int
>         |                                                        %d
> 
> Use the proper 'size_t' specifier, '%zu', to resolve the warning.
> 
> Fixes: 0ab3ca31b012 ("xfs: enable block size larger than page size support")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>

  Luis
Matthew Wilcox Aug. 29, 2024, 3:46 a.m. UTC | #4
On Tue, Aug 27, 2024 at 04:15:05PM -0700, Nathan Chancellor wrote:
> When building for a 32-bit architecture, where 'size_t' is 'unsigned
> int', there is a warning due to use of '%ld', the specifier for a 'long
> int':
> 
>   In file included from fs/xfs/xfs_linux.h:82,
>                    from fs/xfs/xfs.h:26,
>                    from fs/xfs/xfs_super.c:7:
>   fs/xfs/xfs_super.c: In function 'xfs_fs_fill_super':
>   fs/xfs/xfs_super.c:1654:1: error: format '%ld' expects argument of type 'long int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
>    1654 | "block size (%u bytes) not supported; Only block size (%ld) or less is supported",
>         | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    1655 |                                 mp->m_sb.sb_blocksize, max_folio_size);
>         |                                                        ~~~~~~~~~~~~~~
>         |                                                        |
>         |                                                        size_t {aka unsigned int}
>   ...
>   fs/xfs/xfs_super.c:1654:58: note: format string is defined here
>    1654 | "block size (%u bytes) not supported; Only block size (%ld) or less is supported",
>         |                                                        ~~^
>         |                                                          |
>         |                                                          long int
>         |                                                        %d

Do we really need the incredibly verbose compiler warning messages?
Can't we just say "this is the wrong format specifier on 32 bit"
and be done with it?

> Use the proper 'size_t' specifier, '%zu', to resolve the warning.
> 
> Fixes: 0ab3ca31b012 ("xfs: enable block size larger than page size support")
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>  fs/xfs/xfs_super.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 242271298a33..e8cc7900911e 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -1651,7 +1651,7 @@ xfs_fs_fill_super(
>  
>  		if (mp->m_sb.sb_blocksize > max_folio_size) {
>  			xfs_warn(mp,
> -"block size (%u bytes) not supported; Only block size (%ld) or less is supported",
> +"block size (%u bytes) not supported; Only block size (%zu) or less is supported",
>  				mp->m_sb.sb_blocksize, max_folio_size);
>  			error = -ENOSYS;
>  			goto out_free_sb;
> 
> ---
> base-commit: f143d1a48d6ecce12f5bced0d18a10a0294726b5
> change-id: 20240827-xfs-fix-wformat-bs-gt-ps-967f3aa1c142
> 
> Best regards,
> -- 
> Nathan Chancellor <nathan@kernel.org>
> 
>
Darrick J. Wong Aug. 29, 2024, 5:20 a.m. UTC | #5
On Thu, Aug 29, 2024 at 04:46:41AM +0100, Matthew Wilcox wrote:
> On Tue, Aug 27, 2024 at 04:15:05PM -0700, Nathan Chancellor wrote:
> > When building for a 32-bit architecture, where 'size_t' is 'unsigned
> > int', there is a warning due to use of '%ld', the specifier for a 'long
> > int':
> > 
> >   In file included from fs/xfs/xfs_linux.h:82,
> >                    from fs/xfs/xfs.h:26,
> >                    from fs/xfs/xfs_super.c:7:
> >   fs/xfs/xfs_super.c: In function 'xfs_fs_fill_super':
> >   fs/xfs/xfs_super.c:1654:1: error: format '%ld' expects argument of type 'long int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
> >    1654 | "block size (%u bytes) not supported; Only block size (%ld) or less is supported",
> >         | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >    1655 |                                 mp->m_sb.sb_blocksize, max_folio_size);
> >         |                                                        ~~~~~~~~~~~~~~
> >         |                                                        |
> >         |                                                        size_t {aka unsigned int}
> >   ...
> >   fs/xfs/xfs_super.c:1654:58: note: format string is defined here
> >    1654 | "block size (%u bytes) not supported; Only block size (%ld) or less is supported",
> >         |                                                        ~~^
> >         |                                                          |
> >         |                                                          long int
> >         |                                                        %d
> 
> Do we really need the incredibly verbose compiler warning messages?
> Can't we just say "this is the wrong format specifier on 32 bit"
> and be done with it?

Clearly you haven't f*cked up^W^Wforgotten a comma in an xfs tracepoint
in a while, those will generate 60 pages of helpful diagnostics.

--D

> > Use the proper 'size_t' specifier, '%zu', to resolve the warning.
> > 
> > Fixes: 0ab3ca31b012 ("xfs: enable block size larger than page size support")
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> >  fs/xfs/xfs_super.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> > index 242271298a33..e8cc7900911e 100644
> > --- a/fs/xfs/xfs_super.c
> > +++ b/fs/xfs/xfs_super.c
> > @@ -1651,7 +1651,7 @@ xfs_fs_fill_super(
> >  
> >  		if (mp->m_sb.sb_blocksize > max_folio_size) {
> >  			xfs_warn(mp,
> > -"block size (%u bytes) not supported; Only block size (%ld) or less is supported",
> > +"block size (%u bytes) not supported; Only block size (%zu) or less is supported",
> >  				mp->m_sb.sb_blocksize, max_folio_size);
> >  			error = -ENOSYS;
> >  			goto out_free_sb;
> > 
> > ---
> > base-commit: f143d1a48d6ecce12f5bced0d18a10a0294726b5
> > change-id: 20240827-xfs-fix-wformat-bs-gt-ps-967f3aa1c142
> > 
> > Best regards,
> > -- 
> > Nathan Chancellor <nathan@kernel.org>
> > 
> > 
>
Nathan Chancellor Aug. 29, 2024, 5:50 p.m. UTC | #6
On Thu, Aug 29, 2024 at 04:46:41AM +0100, Matthew Wilcox wrote:
> On Tue, Aug 27, 2024 at 04:15:05PM -0700, Nathan Chancellor wrote:
> > When building for a 32-bit architecture, where 'size_t' is 'unsigned
> > int', there is a warning due to use of '%ld', the specifier for a 'long
> > int':
> > 
> >   In file included from fs/xfs/xfs_linux.h:82,
> >                    from fs/xfs/xfs.h:26,
> >                    from fs/xfs/xfs_super.c:7:
> >   fs/xfs/xfs_super.c: In function 'xfs_fs_fill_super':
> >   fs/xfs/xfs_super.c:1654:1: error: format '%ld' expects argument of type 'long int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
> >    1654 | "block size (%u bytes) not supported; Only block size (%ld) or less is supported",
> >         | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >    1655 |                                 mp->m_sb.sb_blocksize, max_folio_size);
> >         |                                                        ~~~~~~~~~~~~~~
> >         |                                                        |
> >         |                                                        size_t {aka unsigned int}
> >   ...
> >   fs/xfs/xfs_super.c:1654:58: note: format string is defined here
> >    1654 | "block size (%u bytes) not supported; Only block size (%ld) or less is supported",
> >         |                                                        ~~^
> >         |                                                          |
> >         |                                                          long int
> >         |                                                        %d
> 
> Do we really need the incredibly verbose compiler warning messages?
> Can't we just say "this is the wrong format specifier on 32 bit"
> and be done with it?

Sure, I could have been less verbose. I seem to recall maintainers
desiring the full compiler output at times so that it is easier to see
what the issue is and how the patch fixes the warning but obviously that
is going to vary from maintainer to maintainer. I can send a v2 with
that trimmed if desired or Christian could just axe it when applying if
he really cares? I guess squashing this into the original change would
make this irrelevant too.

> > Use the proper 'size_t' specifier, '%zu', to resolve the warning.
> > 
> > Fixes: 0ab3ca31b012 ("xfs: enable block size larger than page size support")
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > ---
> >  fs/xfs/xfs_super.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> > index 242271298a33..e8cc7900911e 100644
> > --- a/fs/xfs/xfs_super.c
> > +++ b/fs/xfs/xfs_super.c
> > @@ -1651,7 +1651,7 @@ xfs_fs_fill_super(
> >  
> >  		if (mp->m_sb.sb_blocksize > max_folio_size) {
> >  			xfs_warn(mp,
> > -"block size (%u bytes) not supported; Only block size (%ld) or less is supported",
> > +"block size (%u bytes) not supported; Only block size (%zu) or less is supported",
> >  				mp->m_sb.sb_blocksize, max_folio_size);
> >  			error = -ENOSYS;
> >  			goto out_free_sb;
> > 
> > ---
> > base-commit: f143d1a48d6ecce12f5bced0d18a10a0294726b5
> > change-id: 20240827-xfs-fix-wformat-bs-gt-ps-967f3aa1c142
> > 
> > Best regards,
> > -- 
> > Nathan Chancellor <nathan@kernel.org>
> > 
> >
Christian Brauner Sept. 3, 2024, 1:02 p.m. UTC | #7
On Tue, 27 Aug 2024 16:15:05 -0700, Nathan Chancellor wrote:
> When building for a 32-bit architecture, where 'size_t' is 'unsigned
> int', there is a warning due to use of '%ld', the specifier for a 'long
> int':
> 
>   In file included from fs/xfs/xfs_linux.h:82,
>                    from fs/xfs/xfs.h:26,
>                    from fs/xfs/xfs_super.c:7:
>   fs/xfs/xfs_super.c: In function 'xfs_fs_fill_super':
>   fs/xfs/xfs_super.c:1654:1: error: format '%ld' expects argument of type 'long int', but argument 5 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
>    1654 | "block size (%u bytes) not supported; Only block size (%ld) or less is supported",
>         | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>    1655 |                                 mp->m_sb.sb_blocksize, max_folio_size);
>         |                                                        ~~~~~~~~~~~~~~
>         |                                                        |
>         |                                                        size_t {aka unsigned int}
>   ...
>   fs/xfs/xfs_super.c:1654:58: note: format string is defined here
>    1654 | "block size (%u bytes) not supported; Only block size (%ld) or less is supported",
>         |                                                        ~~^
>         |                                                          |
>         |                                                          long int
>         |                                                        %d
> 
> [...]

The fix has been folded into the commit it fixes and a Link tag has been added
noting that this patch has been folded. Thanks!

---

Applied to the vfs.blocksize branch of the vfs/vfs.git tree.
Patches in the vfs.blocksize branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.blocksize

[1/1] xfs: Fix format specifier for max_folio_size in xfs_fs_fill_super()
      (no commit info)
diff mbox series

Patch

diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 242271298a33..e8cc7900911e 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1651,7 +1651,7 @@  xfs_fs_fill_super(
 
 		if (mp->m_sb.sb_blocksize > max_folio_size) {
 			xfs_warn(mp,
-"block size (%u bytes) not supported; Only block size (%ld) or less is supported",
+"block size (%u bytes) not supported; Only block size (%zu) or less is supported",
 				mp->m_sb.sb_blocksize, max_folio_size);
 			error = -ENOSYS;
 			goto out_free_sb;