This change consolidates multiple return statements in the profil() function
into a single exit point by inverting the parameter validation condition and
restructuring error handling to reduce cyclomatic complexity and comply with MISRA HIS.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
To skip the style issue:
Error: /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/phy62xx/irq.c:194:5: error: Mixed case identifier found
Error: /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/phy62xx/irq.c:196:5: error: Mixed case identifier found
Error: /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/phy62xx/irq.c:199:5: error: Mixed case identifier found
Error: /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/phy62xx/phyplus_wdt.c:61:28: error: Mixed case identifier found
Error: /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/phy62xx/phyplus_wdt.c:104:2: error: Mixed case identifier found
Error: /home/runner/work/nuttx/nuttx/nuttx/arch/arm/src/phy62xx/phyplus_wdt.c:162:50: error: Mixed case identifier found
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
The benefits of doing this are:
1. It makes the code logic clearer, with different resources protected by different locks.
2. It improves system responsiveness and avoids contention issues caused by acquiring the same large lock.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
Replace critical_section with spinlock.
The benefits of doing this are:
1. It makes the code logic clearer, with different resources protected by different locks.
2. It improves system responsiveness and avoids contention issues caused by acquiring the same large lock.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
The benefits of doing this are:
1. It makes the code logic clearer, with different resources protected by different locks.
2. It improves system responsiveness and avoids contention issues caused by acquiring the same large lock.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
Replace critical_section with spinlock or mutex.
The benefits of doing this are:
1. It makes the code logic clearer, with different resources protected by different locks.
2. It improves system responsiveness and avoids contention issues caused by acquiring the same large lock.
Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
Fix violations of MISRA C:2012 Rule 10.4 (operand of unsigned and signed)
in cancellation point handling code.
Changed all CANCEL_FLAG_* macro definitions and their usage to use unsigned
literals (1u instead of 1) to ensure consistent unsigned arithmetic when
performing bitwise operations. This eliminates mixed signed/unsigned operand
violations in:
- CANCEL_FLAG_NONCANCELABLE
- CANCEL_FLAG_CANCEL_ASYNC
- CANCEL_FLAG_CANCEL_PENDING
The changes affect cancellation point entry/exit logic, cancellation state
management, and cancellation type handling across both kernel and libc
implementations.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
This commit updates the NSH documentation about redirection syntax.
This documentation update corresponds to the stderr redirection feature
added in nuttx-apps PR #3378.
Signed-off-by: fangpeina <fangpeina@xiaomi.com>
Add missing else branches to handle spinlock operations when no valid spinlock
pointer is available. This fixes a regression in IRQ save/restore operations
introduced by a previous refactoring of the spinlock control logic.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Fix violations of MISRA C:2012 Rule 10.4 (essential type operand of
unsigned and signed) in posix_spawn attribute handling code.
Changed all POSIX_SPAWN_* flag macro definitions to use unsigned literals
(1u instead of 1) to ensure consistent unsigned arithmetic when performing
bitwise operations. This eliminates mixed signed/unsigned operand violations
in the following flags:
- POSIX_SPAWN_RESETIDS
- POSIX_SPAWN_SETPGROUP
- POSIX_SPAWN_SETSCHEDPARAM
- POSIX_SPAWN_SETSCHEDULER
- POSIX_SPAWN_SETSIGDEF
- POSIX_SPAWN_SETSIGMASK
- POSIX_SPAWN_SETSID
Updated all flag checking comparisons in spawn_execattrs() to compare
against 0u instead of 0 for consistency.
Signed-off-by: fangxinyong <fangxinyong@xiaomi.com>
This change consolidates multiple return statements in nxsched_get_param()
into a single exit point and restructures the error handling path to reduce
cyclomatic complexity and comply with MISRA HIS coding standards.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit added the guard timer for hrtimer.
The guard timer uses a small memory footprint, offering two main advantages:
- Reduced branches checking for an empty hrtimer queue, simplifying code implementation and improving the performance.
- Additional health monitoring allows the system to enter a safe state in case of time acquisition errors, and supports custom error handling callback functions.
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
If there are no timers in the hrtimer queue, we should cancel the timers to avoid unnecessary timer interruptions. Since we currently do not have a timer cancellation interface, we can achieve cancellation by setting the timer to its maximum value.
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
Determining whether a red-black tree node is the left-mode node using `RB_LEFT(hrtimer, node) == NULL` is functionally incorrect. This is because the left node of any leaf node can also be NULL. For example, in the following rbtree:
5
/ \
3 7
\
4
the left node of the right-most node 7 would also be NULL.
To avoid extra performance overhead to find the left-most node when the
rb-tree changed, this commit used `g_cached_first` to cache the
left-most node.
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit fixed the overflow check and renamed the period to delay, since the callback return value is the next delay not the period.
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
When a hrtimer is removed and then re-enqueued, if the removed hrtimer is the head node and the re-enqueued node is not the head node, the hardware timer still needs to be reset. This patch fixes this issue and simplifies the enqueuing.
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit simplified the rbtree in hrtimer and provided better
branchless compare function.
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit renamed the hrtimer_is_armed to hrtimer_is_pending, which is
more accurate in the semamtic, and simplify it.
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit inlined the `hrtimer_start` to allow the compiler to optimize at least 1 branch in
hrtimer_start.
Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
since the judgment for network card selection was changed from IS_UP to
IS_RUNNING, drivers that lack carrier_on need to add the carrier_on
operation; otherwise, network access issues will occur.
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
Mark __stack_chk_guard and __stack_chk_fail as weak symbols to prevent linker
conflicts when multiple definitions of these stack protection symbols exist
across different compilation units.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
This change consolidates multiple return statements in down_read_trylock() into
a single exit point and replaces goto with if-else structure to reduce cyclomatic
complexity and comply with MISRA HIS coding standards.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
This change replaces goto-based control flow with structured if-else blocks
in the down_read() function to comply with MISRA HIS coding standards while
maintaining identical functional behavior.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
This change consolidates multiple return statements in init_rwsem() into a
single exit point by inverting error conditions and restructuring nested
if-else blocks for MISRA HIS compliance.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
<nuttx/irq.h> will use the macros defined in <arch/chip/irq.h>, so the include order should be after it
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
Currently, the SCTLR register is only used to switch the thread MTE state and has no other uses. Because saving this register is special, it will take a long time after testing, so the default saving behavior is deleted.
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
Refactor heap pointer storage by moving us_heap field from userspace_s
to the nested userspace_data_s structure, enabling future extensibility
of user-space data without modifying the core userspace_s interface across
all board-specific implementations.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Reduce multiple return statements and simplify control flow by inverting the
condition check and moving all critical monitoring operations into a single
conditional block. This improves code maintainability and addresses the
Coverity HIS_metric_violation (RETURN) defect.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
INT32_C(x) is currently defined as x ## ll on Xtensa, which
produces a long long int constant. However, int32_t is
defined as long int on this architecture.
This mismatch can break C++ template overload resolution
and causes build failures in downstream projects such as PX4.
Fix the macro by using x ## l so INT32_C expands to the same
underlying type as int32_t.
Signed-off-by: Adwait Godbole <adwaitngodbole@gmail.com>
Fix a compilation error in stm32f10xxf30xx_flash.c where the variable
`page` is used without being declared in up_progmem_write().
The issue appears when STM32_FLASH_DUAL_BANK is enabled.
The page is now derived locally from the flash base address and
page size macros, avoiding any dependency on PROGMEM helpers when
selecting the flash bank.
Signed-off-by: Adwait Godbole <adwaitngodbole@gmail.com>
Move the board-specific phy initialization from early boot into ifup phase. The
board specific phy initialization may need to implement delays, or bus
communication, for example via i2c bus.
These OS services are not necessarily available yet in arm64_netinitialize, and
PHY initialization is not necessary until the driver actually starts using it.
In addition, this allows the board to reset the ethernet phy at every ifup,
if needed for error recover.
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
The function is for any ethernet interface, given as paramter to the function,
it is not for ENET1 only. The correct name is already used
in the code, but the Kconfig had it wrong.
Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
Add TX/RX timestamp tracking for rpmsg_port to enable latency
measurement and debugging:
- Add rpmsg_port_get_timestamp() to retrieve buffer timestamps
- Add rpmsg_port_update_timestamp() to record timestamps at TX/RX time
- Integrate timestamp recording in rpmsg_port_spi and rpmsg_port_spi_slave
- Reserve space for rpmsg_timestamp_s in buffer size calculations
Signed-off-by: liaoao <liaoao@xiaomi.com>
Add rpmsg_get_timestamp() API to get the TX/RX timestamps of an rpmsg
buffer. This is useful for latency measurement and debugging purposes.
The new rpmsg_timestamp_s structure contains:
- tx_nsec: timestamp when the buffer was transmitted
- rx_nsec: timestamp when the buffer was received
Signed-off-by: liaoao <liaoao@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Add explicit type casts to uint32_t for time conversion macro divisors to
comply with MISRA C-2012 Rules 10.1, 10.3, 11.1, 11.3, and 11.4. This fixes
Coverity warnings and improves type safety in clock_time2ticks_floor and related
time conversion operations.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Add USEC2MSEC macro to provide a convenient and consistent interface for
converting microseconds to milliseconds, complementing the existing SEC, USEC,
and NSEC conversion macros and improving code readability.
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Extract the core waitid logic into a separate waittcb() helper function to reduce the
cyclomatic complexity of the main waitid() function. This improves code maintainability,
reduces nested conditions, and enhances code clarity while preserving all functionality.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Replace all goto statements with structured control flow using while loops and
conditional blocks. Consolidate early returns into a single error-handling path
for better code structure and MISRA HIS standards compliance.
Signed-off-by: hujun5 <hujun5@xiaomi.com>
Update the Signal Interfaces documentation to include all
signals with configurable default actions and group them
by behavior for improved readability.
This reflects the current implementation in
sched/signal/sig_default.c.
Signed-off-by: Adwait Godbole <adwaitngodbole@gmail.com>