Commit 787e67f9 authored by Nathan Chancellor's avatar Nathan Chancellor Committed by Wentao Guan
Browse files

hostfs: Add const qualifier to host_root in hostfs_fill_super()

stable inclusion
from stable-v6.6.76
commit 1fbe93dd7e6a0dab59a5fce99f16703f7d52ed81
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBW08Q

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=1fbe93dd7e6a0dab59a5fce99f16703f7d52ed81



--------------------------------

commit 104eef133fd9c17e4dc28bf43f592a86f26d8a59 upstream.

After the recent conversion to the new mount API, there is a warning
when building hostfs (which may be upgraded to an error via
CONFIG_WERROR=y):

  fs/hostfs/hostfs_kern.c: In function 'hostfs_fill_super':
  fs/hostfs/hostfs_kern.c:942:27: warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
    942 |         char *host_root = fc->source;
        |                           ^~

Add the 'const' qualifier, as host_root will not be modified after its
assignment. Move the assignment to keep the existing reverse Christmas
tree order intact.

Fixes: cd140ce9f611 ("hostfs: convert hostfs to use the new mount API")
Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20240611-hostfs-fix-mount-api-conversion-v1-1-ef75bbc77f44@kernel.org


Acked-by: default avatarRichard Weinberger <richard@nod.at>
Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 1fbe93dd7e6a0dab59a5fce99f16703f7d52ed81)
Signed-off-by: default avatarWentao Guan <guanwentao@uniontech.com>
parent f2de4164
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -925,8 +925,8 @@ static const struct inode_operations hostfs_link_iops = {
static int hostfs_fill_super(struct super_block *sb, struct fs_context *fc)
{
	struct hostfs_fs_info *fsi = sb->s_fs_info;
	const char *host_root = fc->source;
	struct inode *root_inode;
	char *host_root = fc->source;
	int err;

	sb->s_blocksize = 1024;