[BUG] MISRA C 2012 Rule 9.3 violation in SMP configuration: xYieldPendings is partially initialized

未关闭
#1,491 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

@20000419 已经在做这个了。

开始于 2026年9月22日。

  • #1493 来自 @某人 —— 已关闭,未合并
  • #1498 来自 @20000419 —— 未关闭

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
18/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
c

调研方向

The array is declared in tasks.c near line 510 as xYieldPendings[ configNUMBER_OF_CORES ] = { pdFALSE }. Before editing, read open PR #1498 and closed PR #1493 to see what was tried and whether the work is already covered. Done means the initializer is changed to { 0 } or MISRA.md gets a documented deviation, as the issue proposes.

由索引模型根据 Issue 内容生成。

描述

bug

Describe the bug
In the SMP configuration (configNUMBER_OF_CORES > 1), tasks.c:510 declares:

    PRIVILEGED_DATA STATIC volatile BaseType_t xYieldPendings[ configNUMBER_OF_CORES ] = { pdFALSE };

The array has configNUMBER_OF_CORES elements, but the initializer list has a single
element, so the remaining elements are only implicitly zero-initialized. This is a violation of MISRA C:2012 Rule 9.3 (Required): "Arrays shall not be partially initialized".
PR #973 fixed the same pattern for the same rule in portable/Common/mpu_wrappers_v2.c (= { NULL } → = { 0 }). pdFALSE is ( ( BaseType_t ) 0 ) (include/projdefs.h:52), so this is the same class.

Expected behavior
No Rule 9.3 violation. Proposed change (no behavior change, keeps all cores
zero-initialized).

PRIVILEGED_DATA STATIC volatile BaseType_t xYieldPendings[ configNUMBER_OF_CORES ] = { 0 };

Alternatively, add a documented deviation in MISRA.md if the implicit zero-initialization is intentional and preferred as-is.

主要语言
C
星标
4.6k
派生
1.6k
平均合并
2 天 22 小时
30 天内合并 PR
4

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

FreeRTOS/FreeRTOS-Kernel 的其他 Issue

查看 FreeRTOS/FreeRTOS-Kernel 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。