linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs/ntfs3: fix wrong cast in xattr.c
@ 2022-11-15  8:17 Daniel Pinto
  2022-12-26 15:07 ` Konstantin Komarov
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Pinto @ 2022-11-15  8:17 UTC (permalink / raw)
  To: kernel test robot
  Cc: ntfs3, linux-fsdevel, Linux Kernel Mailing List, oe-kbuild-all,
	Linux Memory Management List, Konstantin Komarov

cpu_to_be32 and be32_to_cpu respectively return and receive
__be32, change the cast to the correct types.

Fixes the following sparse warnings:
fs/ntfs3/xattr.c:811:48: sparse: sparse: incorrect type in
                         assignment (different base types)
fs/ntfs3/xattr.c:901:34: sparse: sparse: cast to restricted __be32

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Daniel Pinto <danielpinto52@gmail.com>
---
 fs/ntfs3/xattr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
index 8620a7b4b3e6..6056ecbe8e4f 100644
--- a/fs/ntfs3/xattr.c
+++ b/fs/ntfs3/xattr.c
@@ -808,7 +808,7 @@ static int ntfs_getxattr(const struct xattr_handler *handler, struct dentry *de,
 			err = sizeof(u32);
 			*(u32 *)buffer = le32_to_cpu(ni->std_fa);
 			if (!strcmp(name, SYSTEM_NTFS_ATTRIB_BE))
-				*(u32 *)buffer = cpu_to_be32(*(u32 *)buffer);
+				*(__be32 *)buffer = cpu_to_be32(*(u32 *)buffer);
 		}
 		goto out;
 	}
@@ -898,7 +898,7 @@ static noinline int ntfs_setxattr(const struct xattr_handler *handler,
 		if (size != sizeof(u32))
 			goto out;
 		if (!strcmp(name, SYSTEM_NTFS_ATTRIB_BE))
-			new_fa = cpu_to_le32(be32_to_cpu(*(u32 *)value));
+			new_fa = cpu_to_le32(be32_to_cpu(*(__be32 *)value));
 		else
 			new_fa = cpu_to_le32(*(u32 *)value);


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

* Re: [PATCH] fs/ntfs3: fix wrong cast in xattr.c
  2022-11-15  8:17 [PATCH] fs/ntfs3: fix wrong cast in xattr.c Daniel Pinto
@ 2022-12-26 15:07 ` Konstantin Komarov
  0 siblings, 0 replies; 2+ messages in thread
From: Konstantin Komarov @ 2022-12-26 15:07 UTC (permalink / raw)
  To: Daniel Pinto, kernel test robot
  Cc: ntfs3, linux-fsdevel, Linux Kernel Mailing List, oe-kbuild-all,
	Linux Memory Management List

On 15.11.2022 12:17, Daniel Pinto wrote:
> cpu_to_be32 and be32_to_cpu respectively return and receive
> __be32, change the cast to the correct types.
>
> Fixes the following sparse warnings:
> fs/ntfs3/xattr.c:811:48: sparse: sparse: incorrect type in
>                           assignment (different base types)
> fs/ntfs3/xattr.c:901:34: sparse: sparse: cast to restricted __be32
>
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Daniel Pinto <danielpinto52@gmail.com>
> ---
>   fs/ntfs3/xattr.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
> index 8620a7b4b3e6..6056ecbe8e4f 100644
> --- a/fs/ntfs3/xattr.c
> +++ b/fs/ntfs3/xattr.c
> @@ -808,7 +808,7 @@ static int ntfs_getxattr(const struct xattr_handler *handler, struct dentry *de,
>   			err = sizeof(u32);
>   			*(u32 *)buffer = le32_to_cpu(ni->std_fa);
>   			if (!strcmp(name, SYSTEM_NTFS_ATTRIB_BE))
> -				*(u32 *)buffer = cpu_to_be32(*(u32 *)buffer);
> +				*(__be32 *)buffer = cpu_to_be32(*(u32 *)buffer);
>   		}
>   		goto out;
>   	}
> @@ -898,7 +898,7 @@ static noinline int ntfs_setxattr(const struct xattr_handler *handler,
>   		if (size != sizeof(u32))
>   			goto out;
>   		if (!strcmp(name, SYSTEM_NTFS_ATTRIB_BE))
> -			new_fa = cpu_to_le32(be32_to_cpu(*(u32 *)value));
> +			new_fa = cpu_to_le32(be32_to_cpu(*(__be32 *)value));
>   		else
>   			new_fa = cpu_to_le32(*(u32 *)value);

Thank you for your work, applied!


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

end of thread, other threads:[~2022-12-26 15:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-15  8:17 [PATCH] fs/ntfs3: fix wrong cast in xattr.c Daniel Pinto
2022-12-26 15:07 ` Konstantin Komarov

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