This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit c099c625f8ea68e8b96066a1eb62c045ada2b168
Author: Marco Casaroli <[email protected]>
AuthorDate: Tue Oct 20 19:43:45 2026 +0200

    include: Do not use param as a parameter name in public headers.
    
    A program may define a macro of a common name, for example
    "#define param vname", before it includes the system headers.  Then
    every prototype or inline function in the headers that names a
    parameter "param" fails to compile: sched_getparam() and the other
    sched_param functions of <sched.h>, <pthread.h>, <spawn.h> and
    nuttx/sched.h, mallopt() in <malloc.h>, lcong48() in <stdlib.h>, the
    inline functions of nuttx/lib/math32.h (which <stdio.h> brings in) and
    smh_call() in the arm64 <arch/syscall.h> (which <ucontext.h> brings in).
    
    Leave the name out of the prototypes, as other C libraries do, and use
    other names in the inline functions.  No code change.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: Marco Casaroli <[email protected]>
---
 arch/arm64/include/syscall.h |  4 ++--
 include/malloc.h             |  2 +-
 include/nuttx/lib/math32.h   | 38 +++++++++++++++++++-------------------
 include/nuttx/sched.h        |  6 +++---
 include/pthread.h            |  8 ++++----
 include/sched.h              |  6 +++---
 include/spawn.h              |  4 ++--
 include/stdlib.h             |  2 +-
 8 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/arch/arm64/include/syscall.h b/arch/arm64/include/syscall.h
index 4814ed79c7c..39d2845cc9a 100644
--- a/arch/arm64/include/syscall.h
+++ b/arch/arm64/include/syscall.h
@@ -344,10 +344,10 @@ static inline uintptr_t sys_call6(unsigned int nbr, 
uintptr_t parm1,
 
 /* semihosting(SMH) call with call number and one parameter */
 
-static inline long smh_call(unsigned int nbr, void *param)
+static inline long smh_call(unsigned int nbr, void *parm)
 {
   register uint64_t reg0 __asm__("x0") = (uint64_t)(nbr);
-  register uint64_t reg1 __asm__("x1") = (uint64_t)(param);
+  register uint64_t reg1 __asm__("x1") = (uint64_t)(parm);
 
   __asm__ __volatile__
   (
diff --git a/include/malloc.h b/include/malloc.h
index 1955b175cea..cb238857f66 100644
--- a/include/malloc.h
+++ b/include/malloc.h
@@ -99,7 +99,7 @@ extern "C"
 {
 #endif
 
-int mallopt(int param, int value);
+int mallopt(int, int);
 struct mallinfo mallinfo(void);
 size_t malloc_size(FAR void *ptr);
 struct mallinfo_task mallinfo_task(FAR const struct malltask *task);
diff --git a/include/nuttx/lib/math32.h b/include/nuttx/lib/math32.h
index d793779b9b1..db69ef9c63a 100644
--- a/include/nuttx/lib/math32.h
+++ b/include/nuttx/lib/math32.h
@@ -373,22 +373,22 @@ extern "C"
  *   d - The divisor (unsigned integer). d != 0 and d != 1 is required.
  *
  * Output Parameters:
- *   param - The invariant division parameter to be cached.
+ *   ip    - The invariant division parameter to be cached.
  *
  ****************************************************************************/
 
 static inline_function
-void invdiv_init_param32(uint32_t d, FAR invdiv_param32_t *param)
+void invdiv_init_param32(uint32_t d, FAR invdiv_param32_t *ip)
 {
   int      l  = log2ceil(d);
   uint64_t t1 = (uint64_t)1 << 32;
   uint64_t t2 = (uint64_t)1 << l;
 
-  param->mult  = (t1 * (t2 - d)) / d + 1;
+  ip->mult  = (t1 * (t2 - d)) / d + 1;
 #if ULONG_MAX == 4294967295UL
-  param->shift = l - 1;
+  ip->shift = l - 1;
 #else
-  param->shift = l;
+  ip->shift = l;
 #endif
 }
 
@@ -402,7 +402,7 @@ void invdiv_init_param32(uint32_t d, FAR invdiv_param32_t 
*param)
  *
  * Input Parameters:
  *   n - The dividend (uint32_t).
- *   param - The invariant division parameter already cached.
+ *   ip    - The invariant division parameter already cached.
  *
  * Returned Value:
  *  The result of `n / d`
@@ -410,17 +410,17 @@ void invdiv_init_param32(uint32_t d, FAR invdiv_param32_t 
*param)
  ****************************************************************************/
 
 static inline_function
-uint64_t invdiv_u32(uint32_t n, FAR const invdiv_param32_t *param)
+uint64_t invdiv_u32(uint32_t n, FAR const invdiv_param32_t *ip)
 {
-  uint8_t  sh = param->shift;
+  uint8_t  sh = ip->shift;
 #if ULONG_MAX == 4294967295UL
-  uint32_t m  = param->mult;
+  uint32_t m  = ip->mult;
   uint32_t t1 = ((uint64_t)m * n) >> 32; /* UMULH if supported */
   uint32_t t2 = (n - t1) >> 1;
 #else
   /* This division can be 25% faster using 64-bit register. */
 
-  uint64_t m  = param->mult;
+  uint64_t m  = ip->mult;
   uint64_t t1 = (m * n) >> 32;
   uint32_t t2 = n;
 #endif
@@ -512,12 +512,12 @@ static inline_function uint64_t invdiv_umulh64(uint64_t 
a, uint64_t b)
  *   d - The divisor (unsigned integer), d != 0 and d != 1 is required.
  *
  * Output Parameters:
- *   param - The invariant division parameter to be cached.
+ *   ip    - The invariant division parameter to be cached.
  *
  ****************************************************************************/
 
 static inline_function
-void invdiv_init_param64(uint64_t d, FAR invdiv_param64_t *param)
+void invdiv_init_param64(uint64_t d, FAR invdiv_param64_t *ip)
 {
   int      l = log2ceil(d);
   uint64_t t = ((uint64_t)1 << l) - d;
@@ -541,12 +541,12 @@ void invdiv_init_param64(uint64_t d, FAR invdiv_param64_t 
*param)
 
   invdiv_udiv_soft(mres, 2, q, d);
 
-  param->mult = q[0] + 1;
+  ip->mult = q[0] + 1;
 #else
   __uint128_t one128 = 1;
-  param->mult = (one128 << 64) * t / d + 1;
+  ip->mult = (one128 << 64) * t / d + 1;
 #endif
-  param->shift = l - 1;
+  ip->shift = l - 1;
 }
 
 /****************************************************************************
@@ -559,7 +559,7 @@ void invdiv_init_param64(uint64_t d, FAR invdiv_param64_t 
*param)
  *
  * Input Parameters:
  *   n - The dividend (uint64_t).
- *   param - The invariant division parameter already cached.
+ *   ip    - The invariant division parameter already cached.
  *
  * Returned Value:
  *  The result of `n / d`
@@ -567,13 +567,13 @@ void invdiv_init_param64(uint64_t d, FAR invdiv_param64_t 
*param)
  ****************************************************************************/
 
 static inline_function
-uint64_t invdiv_u64(uint64_t n, FAR const invdiv_param64_t *param)
+uint64_t invdiv_u64(uint64_t n, FAR const invdiv_param64_t *ip)
 {
   uint64_t t1;
   uint64_t t2;
-  uint64_t m   = param->mult;
+  uint64_t m   = ip->mult;
   uint8_t  sh1 = 1;
-  uint8_t  sh2 = param->shift;
+  uint8_t  sh2 = ip->shift;
 
   /* Calculate the 128-bit mres = 64-bit n * 64-bit m, where t1 = mres >> 64.
    * Please do not use `umul64_const` or `umul64` here.
diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h
index c21332968dd..75fedb3a555 100644
--- a/include/nuttx/sched.h
+++ b/include/nuttx/sched.h
@@ -1294,7 +1294,7 @@ size_t nxtask_argvstr(FAR struct tcb_s *tcb, FAR char 
*args, size_t size);
  *
  ****************************************************************************/
 
-int nxsched_get_param(pid_t pid, FAR struct sched_param *param);
+int nxsched_get_param(pid_t pid, FAR struct sched_param *);
 
 /****************************************************************************
  * Name:  nxsched_set_param
@@ -1330,7 +1330,7 @@ int nxsched_get_param(pid_t pid, FAR struct sched_param 
*param);
  *
  ****************************************************************************/
 
-int nxsched_set_param(pid_t pid, FAR const struct sched_param *param);
+int nxsched_set_param(pid_t pid, FAR const struct sched_param *);
 
 /****************************************************************************
  * Name: nxsched_get_scheduler
@@ -1398,7 +1398,7 @@ int nxsched_get_scheduler(pid_t pid);
  ****************************************************************************/
 
 int nxsched_set_scheduler(pid_t pid, int policy,
-                          FAR const struct sched_param *param);
+                          FAR const struct sched_param *);
 
 /****************************************************************************
  * Name: nxsched_get_affinity
diff --git a/include/pthread.h b/include/pthread.h
index f8d7868bcdc..242664a58e7 100644
--- a/include/pthread.h
+++ b/include/pthread.h
@@ -486,9 +486,9 @@ int pthread_attr_setschedpolicy(FAR pthread_attr_t *attr, 
int policy);
 int pthread_attr_getschedpolicy(FAR const pthread_attr_t *attr,
                                 FAR int *policy);
 int pthread_attr_setschedparam(FAR pthread_attr_t *attr,
-                               FAR const struct sched_param *param);
+                               FAR const struct sched_param *);
 int pthread_attr_getschedparam(FAR const pthread_attr_t *attr,
-                               FAR struct sched_param *param);
+                               FAR struct sched_param *);
 int pthread_attr_setinheritsched(FAR pthread_attr_t *attr,
                                  int inheritsched);
 int pthread_attr_getinheritsched(FAR const pthread_attr_t *attr,
@@ -606,9 +606,9 @@ int pthread_equal(pthread_t t1, pthread_t t2);
 /* Thread scheduling parameters */
 
 int pthread_getschedparam(pthread_t thread, FAR int *policy,
-                          FAR struct sched_param *param);
+                          FAR struct sched_param *);
 int pthread_setschedparam(pthread_t thread, int policy,
-                          FAR const struct sched_param *param);
+                          FAR const struct sched_param *);
 int pthread_setschedprio(pthread_t thread, int prio);
 
 #ifdef CONFIG_SMP
diff --git a/include/sched.h b/include/sched.h
index 7b29d8a3a40..53c87331d4d 100644
--- a/include/sched.h
+++ b/include/sched.h
@@ -242,10 +242,10 @@ void   task_testcancel(void);
 /* Task Scheduling Interfaces (based on POSIX APIs) */
 
 int    sched_getcpu(void);
-int    sched_setparam(pid_t pid, FAR const struct sched_param *param);
-int    sched_getparam(pid_t pid, FAR struct sched_param *param);
+int    sched_setparam(pid_t pid, FAR const struct sched_param *);
+int    sched_getparam(pid_t pid, FAR struct sched_param *);
 int    sched_setscheduler(pid_t pid, int policy,
-                          FAR const struct sched_param *param);
+                          FAR const struct sched_param *);
 int    sched_getscheduler(pid_t pid);
 int    sched_yield(void);
 int    sched_get_priority_max(int policy);
diff --git a/include/spawn.h b/include/spawn.h
index 2e5a759d4c9..b11d07245b2 100644
--- a/include/spawn.h
+++ b/include/spawn.h
@@ -184,7 +184,7 @@ int posix_spawnattr_getflags(FAR const posix_spawnattr_t 
*attr,
                              FAR short *flags);
 #define posix_spawnattr_getpgroup(attr,group) (ENOSYS)
 int posix_spawnattr_getschedparam(FAR const posix_spawnattr_t *attr,
-                                  FAR struct sched_param *param);
+                                  FAR struct sched_param *);
 int posix_spawnattr_getschedpolicy(FAR const posix_spawnattr_t *attr,
                                    FAR int *policy);
 #define posix_spawnattr_getsigdefault(attr,sigdefault) (ENOSYS)
@@ -196,7 +196,7 @@ int posix_spawnattr_getsigmask(FAR const posix_spawnattr_t 
*attr,
 int posix_spawnattr_setflags(FAR posix_spawnattr_t *attr, short flags);
 #define posix_spawnattr_setpgroup(attr,group) (ENOSYS)
 int posix_spawnattr_setschedparam(FAR posix_spawnattr_t *attr,
-                                  FAR const struct sched_param *param);
+                                  FAR const struct sched_param *);
 int posix_spawnattr_setschedpolicy(FAR posix_spawnattr_t *attr, int policy);
 #define posix_spawnattr_setsigdefault(attr,sigdefault) (ENOSYS)
 int posix_spawnattr_setsigmask(FAR posix_spawnattr_t *attr,
diff --git a/include/stdlib.h b/include/stdlib.h
index 7df1005fe74..bb0bdd6e9ca 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -151,7 +151,7 @@ extern "C"
 void      srand(unsigned int seed);
 int       rand(void);
 int       rand_r(FAR unsigned int *seedp);
-void      lcong48(FAR unsigned short int param[7]);
+void      lcong48(FAR unsigned short int [7]);
 FAR unsigned short int *seed48(FAR unsigned short int seed16v[3]);
 void      srand48(long int seedval);
 long int  jrand48(FAR unsigned short int xsubi[3]);

Reply via email to