Skip to content

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

Description

@9iang22

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.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions