Skip to content

doxygen: fix build error #10599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 12, 2025
Merged

Conversation

unicornx
Copy link
Contributor

@unicornx unicornx commented Aug 11, 2025

导致问题的 commit:b084503b6d "[kernel] add UP scheduler critical switch flag."

这个提交会导致 doxygen build 产生告警,导致失败:

include/rtthread.h:658: warning: argument 'lock' from the argument list of rt_spin_unlock has multiple @param documentation sections 
include/rtthread.h:660: warning: argument 'lock' from the argument list of rt_spin_unlock_irqrestore has multiple @param documentation sections 
include/rtthread.h:660: warning: argument 'level' from the argument list of rt_spin_unlock_irqrestore has multiple @param documentation sections

原因分析:
src/cpu_up.csrc/cpu_mp.c 定义了两套完全相同的函数,因为目前 documentation/Doxyfile 中的 INPUT 参数会将 ./src 下的文件全部加入编译,这导致 src/cpu_up.csrc/cpu_mp.c 都会参与 doxygen 的编译,Doxygen 在处理它们的过程中如果发现这同名函数的 doxygen 注释不同的话会自动进行合并操作,导致形成多个 param 的告警。

以前这两个文件中的 API 注释都是相同的,目前看上去如果注释相同,doxygen 在编译时的合并不会有问题,所以一直以来没有问题,但 b084503 的修改在修改注释时只改了 src/cpu_up.c 中的 rt_spin_unlockrt_spin_unlock_irqrestore 的注释,但没有改 src/cpu_mp.c 中对应函数的注释,从而导致问题。

另外 b084503 中的修改还有一个不好的地方在于 Doxygen 的 @brief 建议只写一行的,多行不是建议的写法。

解决方案:
针对 @brief 只写一行的要求,这个问题解决比较简单,将多加的内容作为 @note 列出即可。

对于 warning 的解决:比较完美的解决方案暂时没有想好。一种可行的做法就是如果内核中这种一套 API 两套实现的情况,原则上 API 的 doxygen 注释应该只写一份就好了。所以一种可行的做法是只在一个文件,譬如 src/cpu_up.c 中写 doxygen 注释,而另一个文件 src/cpu_mp.c 中的 doxygen 注释不写。
还有一种解决方案是将 API 的注释写到 include/rtthread.h 中去(只有一份),但是目前 include/rtthread.h 这个文件本身已经很大了,如果再将注释加进去会更难看。

最终我采用的是临时的解决方案,就是确保同一个 API 的 doxygen 注释在 src/cpu_up.csrc/cpu_mp.c 中一样(这也是以前的做法)。这样 doxygen 编译不会有告警,而且其自动合并后只有一份在 html 中。

更好的解决方案以后再考虑吧。

fixed: b084503 "[kernel] add UP scheduler critical switch flag."

After this commit, doxygen build with warning:
include/rtthread.h:658: warning: argument 'lock' from the argument list of rt_spin_unlock has multiple @param documentation sections
include/rtthread.h:660: warning: argument 'lock' from the argument list of rt_spin_unlock_irqrestore has multiple @param documentation sections
include/rtthread.h:660: warning: argument 'level' from the argument list of rt_spin_unlock_irqrestore has multiple @param documentation sections

Rootcasue analysis:
src/cpu_up.c and src/cpu_mp.c define two identical functions.
Because the INPUT parameter in the documentation/Doxyfile currently
compiles all source files under ./src, i.e both of them, Doxygen
automatically merges the Doxygen comments for identically named
functions if it finds the content of doxygen comments different,
resulting in multiple @param.

Previously, the API comments in both files were identical, so there
was no problem. However, the b084503 change only modified the
comments in src/cpu_up.c but not in src/cpu_mp.c, causing problems.

Another drawback of the b084503 change is that Doxygen recommends
a single line for the @brief; multiple lines are not recommended.

Solution:
Given the requirement for a single line for the @brief, this issue
is relatively simple to resolve: simply list the extra content as @note.

Regarding the warning: A perfect solution has not yet been found.
One possible approach is to write a single Doxygen comment for a kernel
API with two implementations. This approach involves writing Doxygen
comments in only one file, such as src/cpu_up.c , while omitting them
in src/cpu_mp.c .

Another solution is to add API comments to include/rtthread.h , but the
RT-Thread include/rtthread.h file is already quite large, and adding
comments there would be even more cumbersome.

A temporary solution currently in use is to ensure that the Doxygen
comments for the same API are identical in both src/cpu_up.c and
src/cpu_mp.c . This ensures that Doxygen compilation does not
generate warnings, and the files are automatically merged into a
single file in the HTML document.

Signed-off-by: Chen Wang <[email protected]>
@github-actions github-actions bot added the Kernel PR has src relate code label Aug 11, 2025
Copy link

📌 Code Review Assignment

🏷️ Tag: kernel

Reviewers: @GorrayLi @ReviewSun @hamburger-os @lianux-mm @wdfk-prog @xu18838022837

Changed Files (Click to expand)
  • src/cpu_mp.c
  • src/cpu_up.c

📊 Current Review Status (Last Updated: 2025-08-11 22:17 CST)


📝 Review Instructions

  1. 维护者可以通过单击此处来刷新审查状态: 🔄 刷新状态
    Maintainers can refresh the review status by clicking here: 🔄 Refresh Status

  2. 确认审核通过后评论 LGTM/lgtm
    Comment LGTM/lgtm after confirming approval

  3. PR合并前需至少一位维护者确认
    PR must be confirmed by at least one maintainer before merging

ℹ️ 刷新CI状态操作需要具备仓库写入权限。
ℹ️ Refresh CI status operation requires repository Write permission.

@Rbb666 Rbb666 merged commit 715334f into RT-Thread:master Aug 12, 2025
63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Kernel PR has src relate code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants