Repository navigation
Conversation
CV-Bowen
requested review from
GUIDINGLI,
xiaoxiang781216 and
yamt
as code owners
December 2, 2026 14:44
xiaoxiang781216
approved these changes
Dec 2, 2026
GUIDINGLI
approved these changes
Dec 2, 2026
MISRA-C 2012 Rule 15.5 asks for a single point of exit. Make mempool_deinit() return once at the end, carrying -EBUSY in ret. Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
Use unsigned constants when comparing unsigned values and cast the negated semaphore count explicitly when storing it in nwaiter. Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
MISRA-C 2012 Rule 15.5 asks for a single point of exit. Make mempool_init() return once at the end, carrying -ENOMEM in ret. Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
MISRA-C 2012 Rule 15.5 asks for a single point of exit. Make mempool_allocate() return once at the end and replace the goto retry with a do-while loop. Signed-off-by: wangzhi16 <wangzhi16@xiaomi.com>
CV-Bowen
force-pushed
the
up/P234-mempool-misra
branch
from
December 2, 2026 16:12
ad0602d to
1475622
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
MISRA-C cleanups in
mm/mempool/mempool.c, the first of a series thatbrings the mempool MISRA/Coverity fixes in. No functional change intended.
mm/mempool: Complies with MISRA-C single-input single-output rule.(x3):mempool_deinit(),mempool_init()andmempool_allocate()now have asingle
returnat the end; the early returns becomeret/if (ret >= 0)/ ado { } while (retry)loop in place ofgoto retry.mm/mempool: follow MISRA-C 2012 11.4: unsigned constants (0u) incomparisons with unsigned values, and an explicit cast for
info->nwaiter, inmempool.c,mempool.h,malloc.h,mm_malloc.c,mm_memdump.candfs_procfsproc.c.The code is current master's:
mempool_can_wait(), the backtrace hooksand the expandable-pool count in
mempool_navail()are kept as they are,only the control flow and literals change.
Impact
-EBUSY/-ENOMEMreturnsand the wait/retry in
mempool_allocate().Testing
Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU
Toolchain 12.2.Rel1) 12.2.1
mempool cases:
sim:nshplusnsh> cmocka --suite cmocka_mm_test --skip test_nuttx_mm11test_nuttx_mm10(init / allocate / navail / release / deinit, including-EBUSY) andtest_nuttx_mm12(info / info_task / memdump) run thechanged functions.
cmocka_mm_test
test_nuttx_mm11(mempool_multiple) is skipped because it asserts thesame way on current master without this PR:
This PR does not touch
mempool_multiple.c.Regression: sim:rpserver/rpproxy and qemu-armv8a:rpserver/rpproxy boot
and pass the rpmsg cases (dump, ping, rpmsgfs; 15/15). qemu-armv8a was
built with LIBC_ENVPATH and BINFMT_CHECKEXEC disabled, which current
master needs for nxinit to start nsh there; unrelated to this change.
checkpatch passes on all commits.