Skip to content

fix[arm][cortex-m4]: clarify MPU permission expressions - #11769

Open
wdfk-prog wants to merge 1 commit into
RT-Thread:masterfrom
wdfk-prog:fix/cortex-m4-mpu-parentheses
Open

fix[arm][cortex-m4]: clarify MPU permission expressions#11769
wdfk-prog wants to merge 1 commit into
RT-Thread:masterfrom
wdfk-prog:fix/cortex-m4-mpu-parentheses

Conversation

@wdfk-prog

@wdfk-prog wdfk-prog commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Pull Request Description (PR description)

Why is this PR needed

The Cortex-M4 MPU data-permission macros combine & and | in the same parenthesized expression. GCC emits -Wparentheses warnings when these macros are expanded, including by the hardware stack guard and memory-protection paths.

What is your solution

Add explicit parentheses around the AP mask expression before OR-ing MPU_RASR_XN_Msk for all six Cortex-M4 data-permission macros.

This is a warning-only cleanup: operator grouping is made explicit without changing the resulting MPU RASR permission/XN bits, public interfaces, or runtime behavior.

Verification

  • Reproduced 6 -Wparentheses warnings with the original expressions using GCC.
  • Verified the updated expressions produce 0 -Wparentheses warnings in the same focused compile check.
  • git diff --check equivalent passed for the intended patch.
  • Full-scope three-pass static review completed with generic-correctness, arm-cortex, and systematic-debugging; no actionable findings.
  • No full RT-Thread BSP build or target-board runtime test was executed for this warning-only macro change.

Intent for your PR

  • This PR is a draft intended to get feedback during code review
  • This PR is mature and ready to be integrated into the repository

Code Quality

  • I have carefully checked the diff between this PR and the previous code
  • The style guide is followed, including spacing, naming, and related conventions
  • Redundant code has been removed, including #if 0 blocks and commented-out dead code
  • All modifications are justified and do not affect other software components or BSPs
  • I have added comments where the code is difficult to understand
  • The code in this PR is of high quality
  • I used formatting tools such as formatting to ensure compliance with the RT-Thread coding style
  • If this PR adds a new BSP, I have added the CI check entry to .github/ALL_BSP_COMPILE.json

@github-actions

Copy link
Copy Markdown

👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread!

为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。
To ensure your code complies with RT-Thread's coding style, please run the code formatting workflow by following the steps below (If the formatting of CI fails to run).


🛠 操作步骤 | Steps

  1. 前往 Actions 页面 | Go to the Actions page
    点击进入工作流 → | Click to open workflow →

  2. 点击 Run workflow | Click Run workflow

  • Use workflow from 保持默认分支(通常为 master
    Keep the default branch (usually master) in Use workflow from
  • branch 输入框填写 PR 分支 fix/cortex-m4-mpu-parentheses
    Enter PR branch fix/cortex-m4-mpu-parentheses in the branch field
  • 设置需排除的文件/目录(目录请以"/"结尾)
    Set files/directories to exclude (directories should end with "/")
  1. 等待工作流完成 | Wait for the workflow to complete
    格式化后的代码将作为独立提交推送至你的分支。
    The formatting changes will be pushed to your branch as a separate commit.

完成后,提交将自动更新至 fix/cortex-m4-mpu-parentheses 分支,关联的 Pull Request 也会同步更新。
Once completed, commits will be pushed to the fix/cortex-m4-mpu-parentheses branch automatically, and the related Pull Request will be updated.

如有问题欢迎联系我们,再次感谢您的贡献!💐
If you have any questions, feel free to reach out. Thanks again for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant