diff mbox series

[01/10] xfs: fix C++ compilation errors in xfs_fs.h

Message ID 172480131521.2291268.17945339760767205637.stgit@frogsfrogsfrogs (mailing list archive)
State Superseded, archived
Headers show
Series [01/10] xfs: fix C++ compilation errors in xfs_fs.h | expand

Commit Message

Darrick J. Wong Aug. 27, 2024, 11:33 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Several people reported C++ compilation errors due to things that C
compilers allow but C++ compilers do not.  Fix both of these problems,
and hope there aren't more of these brown paper bags in 2 months when we
finally get these fixes through the process into a released xfsprogs.

Reported-by: kernel@mattwhitlock.name
Reported-by: sam@gentoo.org
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219203
Fixes: 233f4e12bbb2c ("xfs: add parent pointer ioctls")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 fs/xfs/libxfs/xfs_fs.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig Aug. 28, 2024, 4:09 a.m. UTC | #1
On Tue, Aug 27, 2024 at 04:33:58PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Several people reported C++ compilation errors due to things that C
> compilers allow but C++ compilers do not.  Fix both of these problems,
> and hope there aren't more of these brown paper bags in 2 months when we
> finally get these fixes through the process into a released xfsprogs.

Meh.  I hate these stupid constrains C++ places on but which we need
to care for :(

Maybe also put a comment into xfs_fs.h that it needs to be C++-clean?

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
Dave Chinner Aug. 29, 2024, 1:29 a.m. UTC | #2
On Tue, Aug 27, 2024 at 04:33:58PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Several people reported C++ compilation errors due to things that C
> compilers allow but C++ compilers do not.  Fix both of these problems,
> and hope there aren't more of these brown paper bags in 2 months when we
> finally get these fixes through the process into a released xfsprogs.
> 
> Reported-by: kernel@mattwhitlock.name
> Reported-by: sam@gentoo.org
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219203
> Fixes: 233f4e12bbb2c ("xfs: add parent pointer ioctls")
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  fs/xfs/libxfs/xfs_fs.h |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> 
> diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h
> index c85c8077fac39..6a63634547ca9 100644
> --- a/fs/xfs/libxfs/xfs_fs.h
> +++ b/fs/xfs/libxfs/xfs_fs.h
> @@ -930,13 +930,13 @@ static inline struct xfs_getparents_rec *
>  xfs_getparents_next_rec(struct xfs_getparents *gp,
>  			struct xfs_getparents_rec *gpr)
>  {
> -	void *next = ((void *)gpr + gpr->gpr_reclen);
> +	void *next = ((char *)gpr + gpr->gpr_reclen);
>  	void *end = (void *)(uintptr_t)(gp->gp_buffer + gp->gp_bufsize);
>  
>  	if (next >= end)
>  		return NULL;
>  
> -	return next;
> +	return (struct xfs_getparents_rec *)next;
>  }

Please move this code completely out of the xfs_fs.h header. It is
not part of the kernel UAPI, and we have always tried to keep code
out of public header files like this because it tends to cause
unexpected build problems for users and 3rd party applications....

-Dave.
Carlos Maiolino Sept. 2, 2024, 3:20 p.m. UTC | #3
On Tue, Aug 27, 2024 at 04:33:58PM GMT, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Several people reported C++ compilation errors due to things that C
> compilers allow but C++ compilers do not.  Fix both of these problems,
> and hope there aren't more of these brown paper bags in 2 months when we
> finally get these fixes through the process into a released xfsprogs.
> 
> Reported-by: kernel@mattwhitlock.name
> Reported-by: sam@gentoo.org
> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=219203
> Fixes: 233f4e12bbb2c ("xfs: add parent pointer ioctls")
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  fs/xfs/libxfs/xfs_fs.h |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> 
> diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h
> index c85c8077fac39..6a63634547ca9 100644
> --- a/fs/xfs/libxfs/xfs_fs.h
> +++ b/fs/xfs/libxfs/xfs_fs.h
> @@ -930,13 +930,13 @@ static inline struct xfs_getparents_rec *
>  xfs_getparents_next_rec(struct xfs_getparents *gp,
>  			struct xfs_getparents_rec *gpr)
>  {
> -	void *next = ((void *)gpr + gpr->gpr_reclen);
> +	void *next = ((char *)gpr + gpr->gpr_reclen);
>  	void *end = (void *)(uintptr_t)(gp->gp_buffer + gp->gp_bufsize);
> 
>  	if (next >= end)
>  		return NULL;
> 
> -	return next;
> +	return (struct xfs_getparents_rec *)next;
>  }
> 
>  /* Iterate through this file handle's directory parent pointers. */

I'm taking this patch alone from this series, so we can fix 6.10 asap, we can
move it out of xfs_fs.h (which I agree with), and pull in the dummy code later.
Getting 6.10.1 out with this fix is priority by now.
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h
index c85c8077fac39..6a63634547ca9 100644
--- a/fs/xfs/libxfs/xfs_fs.h
+++ b/fs/xfs/libxfs/xfs_fs.h
@@ -930,13 +930,13 @@  static inline struct xfs_getparents_rec *
 xfs_getparents_next_rec(struct xfs_getparents *gp,
 			struct xfs_getparents_rec *gpr)
 {
-	void *next = ((void *)gpr + gpr->gpr_reclen);
+	void *next = ((char *)gpr + gpr->gpr_reclen);
 	void *end = (void *)(uintptr_t)(gp->gp_buffer + gp->gp_bufsize);
 
 	if (next >= end)
 		return NULL;
 
-	return next;
+	return (struct xfs_getparents_rec *)next;
 }
 
 /* Iterate through this file handle's directory parent pointers. */