From c58e557fcd4fd08443bd451f3356c009081496ca Mon Sep 17 00:00:00 2001 From: rsuntk Date: Sat, 23 Aug 2025 13:59:15 +0700 Subject: [PATCH] kernel: address -Wunused-but-set-variable Signed-off-by: rsuntk --- kernel/core_hook.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/kernel/core_hook.c b/kernel/core_hook.c index a7bd9091..bbda97fb 100644 --- a/kernel/core_hook.c +++ b/kernel/core_hook.c @@ -1150,17 +1150,14 @@ static bool should_umount(struct path *path) } #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0) || defined(KSU_HAS_PATH_UMOUNT) -static void ksu_path_umount(const char *mnt, struct path *path, int flags) +static int ksu_path_umount(struct path *path, int flags) { - int ret = path_umount(path, flags); -#ifdef CONFIG_KSU_DEBUG - pr_info("%s: path: %s ret: %d\n", __func__, mnt, ret); -#endif + return path_umount(path, flags); } -#define ksu_umount_mnt(mnt, path, flags) (ksu_path_umount(mnt, path, flags)) +#define ksu_umount_mnt(__unused, path, flags) (ksu_path_umount(path, flags)) #else // TODO: Search a way to make this works without set_fs functions -static void ksu_sys_umount(const char *mnt, int flags) +static int ksu_sys_umount(const char *mnt, int flags) { char __user *usermnt = (char __user *)mnt; mm_segment_t old_fs; @@ -1174,7 +1171,8 @@ static void ksu_sys_umount(const char *mnt, int flags) ret = sys_umount(usermnt, flags); // cuz asmlinkage long sys##name #endif set_fs(old_fs); - pr_info("%s: path: %s ret: %d\n", __func__, usermnt, ret); + pr_info("%s was called, ret: %d\n", __func__, ret); + return ret; } #define ksu_umount_mnt(mnt, __unused, flags) \ @@ -1192,6 +1190,7 @@ static void try_umount(const char *mnt, bool check_mnt, int flags) #endif { struct path path; + int ret; int err = kern_path(mnt, 0, &path); if (err) { return; @@ -1215,7 +1214,12 @@ static void try_umount(const char *mnt, bool check_mnt, int flags) } #endif -ksu_umount_mnt(mnt, &path, flags); + ret = ksu_umount_mnt(mnt, &path, flags); + if (ret) { +#ifdef CONFIG_KSU_DEBUG + pr_info("%s: path: %s, ret: %d\n", __func__, mnt, ret); +#endif + } } #ifdef CONFIG_KSU_SUSFS_TRY_UMOUNT