For improved const-correctness.
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
---
arch/s390/mm/mmap.c | 5 +++--
arch/sparc/kernel/sys_sparc_64.c | 5 +++--
arch/x86/mm/mmap.c | 7 ++++---
include/linux/sched/mm.h | 4 ++--
mm/util.c | 9 ++++++---
5 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
index c0f619fb9ab3..a47c7133d82a 100644
--- a/arch/s390/mm/mmap.c
+++ b/arch/s390/mm/mmap.c
@@ -47,7 +47,7 @@ static unsigned long mmap_base_legacy(unsigned long rnd)
}
static inline unsigned long mmap_base(unsigned long rnd,
- struct rlimit *rlim_stack)
+ const struct rlimit *const rlim_stack)
{
unsigned long gap = rlim_stack->rlim_cur;
unsigned long pad = stack_maxrandom_size() + stack_guard_gap;
@@ -169,7 +169,8 @@ unsigned long arch_get_unmapped_area_topdown(struct file *filp, unsigned long ad
* This function, called very early during the creation of a new
* process VM image, sets up which VM layout function to use:
*/
-void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
+void arch_pick_mmap_layout(struct mm_struct *const mm,
+ const struct rlimit *const rlim_stack)
{
unsigned long random_factor = 0UL;
diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
index 785e9909340f..e3f0d9b74b00 100644
--- a/arch/sparc/kernel/sys_sparc_64.c
+++ b/arch/sparc/kernel/sys_sparc_64.c
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-2.0
+ickj// SPDX-License-Identifier: GPL-2.0
/* linux/arch/sparc64/kernel/sys_sparc.c
*
* This file contains various random system calls that
@@ -294,7 +294,8 @@ static unsigned long mmap_rnd(void)
return rnd << PAGE_SHIFT;
}
-void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
+void arch_pick_mmap_layout(struct mm_struct *const mm,
+ const struct rlimit *const rlim_stack)
{
unsigned long random_factor = mmap_rnd();
unsigned long gap;
diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
index 708f85dc9380..13bde4ba2f24 100644
--- a/arch/x86/mm/mmap.c
+++ b/arch/x86/mm/mmap.c
@@ -80,7 +80,7 @@ unsigned long arch_mmap_rnd(void)
}
static unsigned long mmap_base(unsigned long rnd, unsigned long task_size,
- struct rlimit *rlim_stack)
+ const struct rlimit *const rlim_stack)
{
unsigned long gap = rlim_stack->rlim_cur;
unsigned long pad = stack_maxrandom_size(task_size) + stack_guard_gap;
@@ -110,7 +110,7 @@ static unsigned long mmap_legacy_base(unsigned long rnd,
*/
static void arch_pick_mmap_base(unsigned long *base, unsigned long *legacy_base,
unsigned long random_factor, unsigned long task_size,
- struct rlimit *rlim_stack)
+ const struct rlimit *const rlim_stack)
{
*legacy_base = mmap_legacy_base(random_factor, task_size);
if (mmap_is_legacy())
@@ -119,7 +119,8 @@ static void arch_pick_mmap_base(unsigned long *base, unsigned long *legacy_base,
*base = mmap_base(random_factor, task_size, rlim_stack);
}
-void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
+void arch_pick_mmap_layout(struct mm_struct *const mm,
+ const struct rlimit *const rlim_stack)
{
if (mmap_is_legacy())
mm_flags_clear(MMF_TOPDOWN, mm);
diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h
index 2201da0afecc..0232d983b715 100644
--- a/include/linux/sched/mm.h
+++ b/include/linux/sched/mm.h
@@ -178,7 +178,7 @@ static inline void mm_update_next_owner(struct mm_struct *mm)
#endif
extern void arch_pick_mmap_layout(struct mm_struct *mm,
- struct rlimit *rlim_stack);
+ const struct rlimit *rlim_stack);
unsigned long
arch_get_unmapped_area(struct file *filp, unsigned long addr,
@@ -211,7 +211,7 @@ generic_get_unmapped_area_topdown(struct file *filp, unsigned long addr,
unsigned long flags, vm_flags_t vm_flags);
#else
static inline void arch_pick_mmap_layout(struct mm_struct *mm,
- struct rlimit *rlim_stack) {}
+ const struct rlimit *rlim_stack) {}
#endif
static inline bool in_vfork(struct task_struct *tsk)
diff --git a/mm/util.c b/mm/util.c
index f5a35efba7bf..24f08217cd95 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -431,7 +431,8 @@ static int mmap_is_legacy(const struct rlimit *const rlim_stack)
#define MIN_GAP (SZ_128M)
#define MAX_GAP (STACK_TOP / 6 * 5)
-static unsigned long mmap_base(unsigned long rnd, struct rlimit *rlim_stack)
+static unsigned long mmap_base(const unsigned long rnd,
+ const struct rlimit *const rlim_stack)
{
#ifdef CONFIG_STACK_GROWSUP
/*
@@ -462,7 +463,8 @@ static unsigned long mmap_base(unsigned long rnd, struct rlimit *rlim_stack)
#endif
}
-void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
+void arch_pick_mmap_layout(struct mm_struct *const mm,
+ const struct rlimit *const rlim_stack)
{
unsigned long random_factor = 0UL;
@@ -478,7 +480,8 @@ void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
}
}
#elif defined(CONFIG_MMU) && !defined(HAVE_ARCH_PICK_MMAP_LAYOUT)
-void arch_pick_mmap_layout(struct mm_struct *mm, struct rlimit *rlim_stack)
+void arch_pick_mmap_layout(struct mm_struct *const mm,
+ const struct rlimit *const rlim_stack)
{
mm->mmap_base = TASK_UNMAPPED_BASE;
mm_flags_clear(MMF_TOPDOWN, mm);
--
2.47.2
Hi Max, kernel test robot noticed the following build errors: [auto build test ERROR on akpm-mm/mm-everything] url: https://github.com/intel-lab-lkp/linux/commits/Max-Kellermann/mm-shmem-add-const-to-lots-of-pointer-parameters/20250831-174136 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything patch link: https://lore.kernel.org/r/20250831093918.2815332-9-max.kellermann%40ionos.com patch subject: [PATCH v2 08/12] arch, mm/util: add const to arch_pick_mmap_layout() parameter config: sparc64-randconfig-001-20250901 (https://download.01.org/0day-ci/archive/20250901/202509010724.bSPPSD1X-lkp@intel.com/config) compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250901/202509010724.bSPPSD1X-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202509010724.bSPPSD1X-lkp@intel.com/ All errors (new ones prefixed by >>): >> arch/sparc/kernel/sys_sparc_64.c:1:1: error: unknown type name 'ickj' 1 | ickj// SPDX-License-Identifier: GPL-2.0 | ^ In file included from arch/sparc/kernel/sys_sparc_64.c:11: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:98:11: warning: array index 3 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds] 98 | return (set->sig[3] | set->sig[2] | | ^ ~ arch/sparc/include/uapi/asm/signal.h:113:8: note: array 'sig' declared here 113 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from arch/sparc/kernel/sys_sparc_64.c:11: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:98:25: warning: array index 2 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds] 98 | return (set->sig[3] | set->sig[2] | | ^ ~ arch/sparc/include/uapi/asm/signal.h:113:8: note: array 'sig' declared here 113 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from arch/sparc/kernel/sys_sparc_64.c:11: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:99:4: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds] 99 | set->sig[1] | set->sig[0]) == 0; | ^ ~ arch/sparc/include/uapi/asm/signal.h:113:8: note: array 'sig' declared here 113 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from arch/sparc/kernel/sys_sparc_64.c:11: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:101:11: warning: array index 1 is past the end of the array (that has type 'unsigned long[1]') [-Warray-bounds] 101 | return (set->sig[1] | set->sig[0]) == 0; | ^ ~ arch/sparc/include/uapi/asm/signal.h:113:8: note: array 'sig' declared here 113 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from arch/sparc/kernel/sys_sparc_64.c:11: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:114:11: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds] 114 | return (set1->sig[3] == set2->sig[3]) && | ^ ~ arch/sparc/include/uapi/asm/signal.h:113:8: note: array 'sig' declared here 113 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from arch/sparc/kernel/sys_sparc_64.c:11: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:114:27: warning: array index 3 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds] 114 | return (set1->sig[3] == set2->sig[3]) && | ^ ~ arch/sparc/include/uapi/asm/signal.h:113:8: note: array 'sig' declared here 113 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from arch/sparc/kernel/sys_sparc_64.c:11: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:115:5: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds] 115 | (set1->sig[2] == set2->sig[2]) && | ^ ~ arch/sparc/include/uapi/asm/signal.h:113:8: note: array 'sig' declared here 113 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from arch/sparc/kernel/sys_sparc_64.c:11: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:115:21: warning: array index 2 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds] 115 | (set1->sig[2] == set2->sig[2]) && | ^ ~ arch/sparc/include/uapi/asm/signal.h:113:8: note: array 'sig' declared here 113 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from arch/sparc/kernel/sys_sparc_64.c:11: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:116:5: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds] 116 | (set1->sig[1] == set2->sig[1]) && | ^ ~ arch/sparc/include/uapi/asm/signal.h:113:8: note: array 'sig' declared here 113 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from arch/sparc/kernel/sys_sparc_64.c:11: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:116:21: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds] 116 | (set1->sig[1] == set2->sig[1]) && | ^ ~ arch/sparc/include/uapi/asm/signal.h:113:8: note: array 'sig' declared here 113 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from arch/sparc/kernel/sys_sparc_64.c:11: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:119:11: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds] 119 | return (set1->sig[1] == set2->sig[1]) && | ^ ~ arch/sparc/include/uapi/asm/signal.h:113:8: note: array 'sig' declared here 113 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from arch/sparc/kernel/sys_sparc_64.c:11: In file included from include/linux/sched/signal.h:6: include/linux/signal.h:119:27: warning: array index 1 is past the end of the array (that has type 'const unsigned long[1]') [-Warray-bounds] 119 | return (set1->sig[1] == set2->sig[1]) && | ^ ~ arch/sparc/include/uapi/asm/signal.h:113:8: note: array 'sig' declared here 113 | unsigned long sig[_NSIG_WORDS]; | ^ In file included from arch/sparc/kernel/sys_sparc_64.c:11: In file included from include/linux/sched/signal.h:6: vim +/ickj +1 arch/sparc/kernel/sys_sparc_64.c > 1 ickj// SPDX-License-Identifier: GPL-2.0 2 /* linux/arch/sparc64/kernel/sys_sparc.c 3 * 4 * This file contains various random system calls that 5 * have a non-standard calling sequence on the Linux/sparc 6 * platform. 7 */ 8 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
On Mon, Sep 1, 2025 at 1:44 AM kernel test robot <lkp@intel.com> wrote: > All errors (new ones prefixed by >>): > > >> arch/sparc/kernel/sys_sparc_64.c:1:1: error: unknown type name 'ickj' > 1 | ickj// SPDX-License-Identifier: GPL-2.0 > | ^ Oops how did that slip in here...
© 2016 - 2025 Red Hat, Inc.