public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfsprogs: Fix mismatched return type of filesize()
@ 2025-02-17 15:50 ` Pavel Reichl
  2025-02-18  8:18   ` Carlos Maiolino
  0 siblings, 1 reply; 6+ messages in thread
From: Pavel Reichl @ 2025-02-17 15:50 UTC (permalink / raw)
  To: aalbersh; +Cc: linux-xfs

The function filesize() was declared with a return type of 'long' but
defined with 'off_t'. This mismatch caused build issues due to type
incompatibility.

This commit updates the declaration to match the definition, ensuring
consistency and preventing potential compilation errors.

Signed-off-by: Pavel Reichl <preichl@redhat.com>
---
 mkfs/proto.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mkfs/proto.c b/mkfs/proto.c
index 6dd3a200..981f5b11 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -20,7 +20,7 @@ static struct xfs_trans * getres(struct xfs_mount *mp, uint blocks);
 static void rsvfile(xfs_mount_t *mp, xfs_inode_t *ip, long long len);
 static int newregfile(char **pp, char **fname);
 static void rtinit(xfs_mount_t *mp);
-static long filesize(int fd);
+static off_t filesize(int fd);
 static int slashes_are_spaces;
 
 /*
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] xfsprogs: Fix mismatched return type of filesize()
  2025-02-17 15:50 ` Pavel Reichl
@ 2025-02-18  8:18   ` Carlos Maiolino
  2025-02-18 18:15     ` Darrick J. Wong
  0 siblings, 1 reply; 6+ messages in thread
From: Carlos Maiolino @ 2025-02-18  8:18 UTC (permalink / raw)
  To: Pavel Reichl; +Cc: aalbersh, linux-xfs

On Mon, Feb 17, 2025 at 04:50:43PM +0100, Pavel Reichl wrote:
> The function filesize() was declared with a return type of 'long' but
> defined with 'off_t'. This mismatch caused build issues due to type
> incompatibility.
> 
> This commit updates the declaration to match the definition, ensuring
> consistency and preventing potential compilation errors.
> 
> Signed-off-by: Pavel Reichl <preichl@redhat.com>

Looks good, perhaps add:

Fixes: 73fb78e5ee8 ("mkfs: support copying in large or sparse files")

?

Otherwise,
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

> ---
>  mkfs/proto.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mkfs/proto.c b/mkfs/proto.c
> index 6dd3a200..981f5b11 100644
> --- a/mkfs/proto.c
> +++ b/mkfs/proto.c
> @@ -20,7 +20,7 @@ static struct xfs_trans * getres(struct xfs_mount *mp, uint blocks);
>  static void rsvfile(xfs_mount_t *mp, xfs_inode_t *ip, long long len);
>  static int newregfile(char **pp, char **fname);
>  static void rtinit(xfs_mount_t *mp);
> -static long filesize(int fd);
> +static off_t filesize(int fd);
>  static int slashes_are_spaces;
> 
>  /*
> --
> 2.48.1
> 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] xfsprogs: Fix mismatched return type of filesize()
  2025-02-18  8:18   ` Carlos Maiolino
@ 2025-02-18 18:15     ` Darrick J. Wong
  0 siblings, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2025-02-18 18:15 UTC (permalink / raw)
  To: Carlos Maiolino; +Cc: Pavel Reichl, aalbersh, linux-xfs

On Tue, Feb 18, 2025 at 09:18:46AM +0100, Carlos Maiolino wrote:
> On Mon, Feb 17, 2025 at 04:50:43PM +0100, Pavel Reichl wrote:
> > The function filesize() was declared with a return type of 'long' but
> > defined with 'off_t'. This mismatch caused build issues due to type
> > incompatibility.
> > 
> > This commit updates the declaration to match the definition, ensuring
> > consistency and preventing potential compilation errors.
> > 
> > Signed-off-by: Pavel Reichl <preichl@redhat.com>
> 
> Looks good, perhaps add:
> 
> Fixes: 73fb78e5ee8 ("mkfs: support copying in large or sparse files")

Yes please!  Sorry about the discrepancy.

With that fixed,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ?
> 
> Otherwise,
> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
> 
> > ---
> >  mkfs/proto.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/mkfs/proto.c b/mkfs/proto.c
> > index 6dd3a200..981f5b11 100644
> > --- a/mkfs/proto.c
> > +++ b/mkfs/proto.c
> > @@ -20,7 +20,7 @@ static struct xfs_trans * getres(struct xfs_mount *mp, uint blocks);
> >  static void rsvfile(xfs_mount_t *mp, xfs_inode_t *ip, long long len);
> >  static int newregfile(char **pp, char **fname);
> >  static void rtinit(xfs_mount_t *mp);
> > -static long filesize(int fd);
> > +static off_t filesize(int fd);
> >  static int slashes_are_spaces;
> > 
> >  /*
> > --
> > 2.48.1
> > 
> > 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] xfsprogs: Fix mismatched return type of filesize()
@ 2025-04-02  0:22 ` Theodore Ts'o
  2025-04-02  5:50   ` Carlos Maiolino
  2025-04-02 14:31   ` Darrick J. Wong
  0 siblings, 2 replies; 6+ messages in thread
From: Theodore Ts'o @ 2025-04-02  0:22 UTC (permalink / raw)
  To: Pavel Reichl
  Cc: Darrick J. Wong, Carlos Maiolino, Andrey Albershteyn, linux-xfs

On Fri, Feb 21, 2025 at 07:57:57PM +0100, Pavel Reichl wrote:
> The function filesize() was declared with a return type of 'long' but
> defined with 'off_t'. This mismatch caused build issues due to type
> incompatibility.
> 
> This commit updates the declaration to match the definition, ensuring
> consistency and preventing potential compilation errors.
> 
> Fixes: 73fb78e5ee8 ("mkfs: support copying in large or sparse files")

I had run into this issue when building xfsprogs on i386, and had
investigated the compilation failure before finding this commit in
origin/for-next.  But in my fix, I also found that there was a missing
long -> off_t conversion in setup_proto():

diff --git a/mkfs/proto.c b/mkfs/proto.c
index 7f56a3d8..52ef64ff 100644
--- a/mkfs/proto.c
+++ b/mkfs/proto.c
@@ -61,7 +61,7 @@ setup_proto(
 	char		*buf = NULL;
 	static char	dflt[] = "d--755 0 0 $";
 	int		fd;
-	long		size;
+	off_t		size;
 
 	if (!fname)
 		return dflt;

... since setup_proto() also calls filesize():

	if ((fd = open(fname, O_RDONLY)) < 0 || (size = filesize(fd)) < 0) {

How important is it fix this up?  I can send a formal patch if that
would be helpful, but commit a5466cee9874 is certainly enough to fix
the build failure so maybe it's enough.

Cheers,

					- Ted

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] xfsprogs: Fix mismatched return type of filesize()
  2025-04-02  0:22 ` [PATCH] xfsprogs: Fix mismatched return type of filesize() Theodore Ts'o
@ 2025-04-02  5:50   ` Carlos Maiolino
  2025-04-02 14:31   ` Darrick J. Wong
  1 sibling, 0 replies; 6+ messages in thread
From: Carlos Maiolino @ 2025-04-02  5:50 UTC (permalink / raw)
  To: Theodore Ts'o
  Cc: Pavel Reichl, Darrick J. Wong, Andrey Albershteyn, linux-xfs

On Tue, Apr 01, 2025 at 08:22:33PM -0400, Theodore Ts'o wrote:
> On Fri, Feb 21, 2025 at 07:57:57PM +0100, Pavel Reichl wrote:
> > The function filesize() was declared with a return type of 'long' but
> > defined with 'off_t'. This mismatch caused build issues due to type
> > incompatibility.
> >
> > This commit updates the declaration to match the definition, ensuring
> > consistency and preventing potential compilation errors.
> >
> > Fixes: 73fb78e5ee8 ("mkfs: support copying in large or sparse files")
> 
> I had run into this issue when building xfsprogs on i386, and had
> investigated the compilation failure before finding this commit in
> origin/for-next.  But in my fix, I also found that there was a missing
> long -> off_t conversion in setup_proto():
> 
> diff --git a/mkfs/proto.c b/mkfs/proto.c
> index 7f56a3d8..52ef64ff 100644
> --- a/mkfs/proto.c
> +++ b/mkfs/proto.c
> @@ -61,7 +61,7 @@ setup_proto(
>  	char		*buf = NULL;
>  	static char	dflt[] = "d--755 0 0 $";
>  	int		fd;
> -	long		size;
> +	off_t		size;
> 
>  	if (!fname)
>  		return dflt;
> 
> ... since setup_proto() also calls filesize():
> 
> 	if ((fd = open(fname, O_RDONLY)) < 0 || (size = filesize(fd)) < 0) {
> 
> How important is it fix this up?  I can send a formal patch if that
> would be helpful, but commit a5466cee9874 is certainly enough to fix
> the build failure so maybe it's enough.

Every fix is welcome, this is something that can clearly be tripped over in the
future.
 
> 
> Cheers,
> 
> 					- Ted

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] xfsprogs: Fix mismatched return type of filesize()
  2025-04-02  0:22 ` [PATCH] xfsprogs: Fix mismatched return type of filesize() Theodore Ts'o
  2025-04-02  5:50   ` Carlos Maiolino
@ 2025-04-02 14:31   ` Darrick J. Wong
  1 sibling, 0 replies; 6+ messages in thread
From: Darrick J. Wong @ 2025-04-02 14:31 UTC (permalink / raw)
  To: Theodore Ts'o
  Cc: Pavel Reichl, Carlos Maiolino, Andrey Albershteyn, linux-xfs

On Tue, Apr 01, 2025 at 08:22:33PM -0400, Theodore Ts'o wrote:
> On Fri, Feb 21, 2025 at 07:57:57PM +0100, Pavel Reichl wrote:
> > The function filesize() was declared with a return type of 'long' but
> > defined with 'off_t'. This mismatch caused build issues due to type
> > incompatibility.
> > 
> > This commit updates the declaration to match the definition, ensuring
> > consistency and preventing potential compilation errors.
> > 
> > Fixes: 73fb78e5ee8 ("mkfs: support copying in large or sparse files")
> 
> I had run into this issue when building xfsprogs on i386, and had
> investigated the compilation failure before finding this commit in
> origin/for-next.  But in my fix, I also found that there was a missing
> long -> off_t conversion in setup_proto():
> 
> diff --git a/mkfs/proto.c b/mkfs/proto.c
> index 7f56a3d8..52ef64ff 100644
> --- a/mkfs/proto.c
> +++ b/mkfs/proto.c
> @@ -61,7 +61,7 @@ setup_proto(
>  	char		*buf = NULL;
>  	static char	dflt[] = "d--755 0 0 $";
>  	int		fd;
> -	long		size;
> +	off_t		size;
>  
>  	if (!fname)
>  		return dflt;
> 
> ... since setup_proto() also calls filesize():
> 
> 	if ((fd = open(fname, O_RDONLY)) < 0 || (size = filesize(fd)) < 0) {
> 
> How important is it fix this up?  I can send a formal patch if that
> would be helpful, but commit a5466cee9874 is certainly enough to fix
> the build failure so maybe it's enough.

Yes, this is important -- off_t can be larger than long, and that can
result in incorrect truncations.  I hope that nobody will ever pass mkfs
a 5GB protofile on 32-bit, but at least the C type usage could be
correct.

--D

> 
> Cheers,
> 
> 					- Ted
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-04-02 14:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <rVcV0bUochTHYCUeMeo8VPv0LODkI0DQY8oB8J3Pf1--Zp8jG4weSLdbo-ME7csTl1V_Cdw3SXvCzwH-8jBFNQ==@protonmail.internalid>
2025-04-02  0:22 ` [PATCH] xfsprogs: Fix mismatched return type of filesize() Theodore Ts'o
2025-04-02  5:50   ` Carlos Maiolino
2025-04-02 14:31   ` Darrick J. Wong
     [not found] <-uT7HOcTG_xe8v8U0_5OQg6ll9vJyYEFQeSs_2FwUHujx116vYRcX2iovzoJvkN8K9zDDmQxQWB6H1CDLiOVdw==@protonmail.internalid>
2025-02-17 15:50 ` Pavel Reichl
2025-02-18  8:18   ` Carlos Maiolino
2025-02-18 18:15     ` Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox