Repository navigation
Conversation
Fix -Wformat warnings in arm_gic_dump_type() and arm_gic_dump() for both GICv2 (gic.c) and GICv3 (gicv3.c): - %p with rt_uint32_t physical address -> 0x%08x (non-pointer passed to %p is undefined behavior) - %d with unsigned int / unsigned long -> %u (signed/unsigned mismatch) - Add explicit (unsigned int) cast for GIC version extracted with 0xfUL These warnings appear when compiling Cortex-A BSPs with -Wall -Wformat.
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
This branch has not been deployed
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.
Fix -Wformat warnings in arm_gic_dump_type() and arm_gic_dump() for both GICv2 (gic.c) and GICv3 (gicv3.c):
These warnings appear when compiling Cortex-A BSPs with -Wall -Wformat.
拉取/合并请求描述:(PR description)
为什么提交这份PR (why to submit this PR)
在
libcpu/arm/cortex-a/gic.c和gicv3.c的 GIC 信息打印函数中,存在 4 类格式说明符与参数类型不匹配的问题,使用-Wall -Wformat编译 Cortex-A BSP 时会产生警告:%p用于rt_uint32_t类型的物理地址(dist_hw_base)—— 向%p传入非指针是未定义行为(UB)%d用于unsigned long类型的 GIC 版本号 —— 符号不匹配%d用于unsigned int类型的_gic_max_irq—— 符号不匹配%d用于unsigned int类型的中断号k—— 符号不匹配There are 4 types of format specifier mismatches in the GIC dump functions of
libcpu/arm/cortex-a/gic.candgicv3.c, producing-Wformatwarnings when compiling Cortex-A BSPs:%pused withrt_uint32_tphysical address — passing non-pointer to%pis undefined behavior%dused withunsigned longGIC version — signed/unsigned mismatch%dused withunsigned int_gic_max_irq— signed/unsigned mismatch%dused withunsigned intIRQ numberk— signed/unsigned mismatch你的解决方案是什么 (what is your solution)
%p→0x%08x,%d→%u(2处), 增加(unsigned int)cast%d→%u%p→0x%08x,%d→%u(2处), 增加(unsigned int)cast%d→%u仅修改格式说明符,不改变任何运行时逻辑。
%p→0x%08x同时修复了未定义行为。Only format specifiers are changed; no runtime logic is modified. The
%p→0x%08xchange also fixes undefined behavior.请提供验证的bsp和config (provide the config and bsp)
当前拉取/合并请求的状态 Intent for your PR
代码质量 Code Quality:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up