Skip to content

Suppress MISRA violations for static helper variables#372

Merged
AniruddhaKanhere merged 1 commit into
FreeRTOS:mainfrom
AniruddhaKanhere:ConvenienceMacrosWithMISRA
Apr 28, 2026
Merged

Suppress MISRA violations for static helper variables#372
AniruddhaKanhere merged 1 commit into
FreeRTOS:mainfrom
AniruddhaKanhere:ConvenienceMacrosWithMISRA

Conversation

@AniruddhaKanhere
Copy link
Copy Markdown
Member

@AniruddhaKanhere AniruddhaKanhere commented Apr 28, 2026

The static const uint8_t variables that back the MQTT_PROP_VALIDATE_* convenience macros get a private copy in every translation unit that includes core_mqtt_serializer.h. A TU that does not use a particular MQTT_PROP_VALIDATE_* macro leaves the corresponding variable unreferenced, which Coverity flags as MISRA Rule 2.2 (dead code) and Rule 2.8 (unused file-scope object definition).

Add coverity[misra_c_2012_rule_2_2_violation] and
coverity[misra_c_2012_rule_2_8_violation] suppressions above each static const declaration, with links to MISRA.md. Add Rule 2.2 and Rule 2.8 sections to MISRA.md documenting the rationale: the variables exist so the address-of operator in the macros produces a valid const uint8_t *, and the portable-to-C90 alternative (compound literals) is not viable.

Description

Test Steps

Checklist:

  • I have tested my changes. No regression in existing tests.
  • I have modified and/or added unit-tests to cover the code changes in this Pull Request.

Related Issue

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

…L constants

The static const uint8_t variables that back the MQTT_PROP_VALIDATE_*
convenience macros get a private copy in every translation unit that
includes core_mqtt_serializer.h. A TU that does not use a particular
MQTT_PROP_VALIDATE_* macro leaves the corresponding variable unreferenced,
which Coverity flags as MISRA Rule 2.2 (dead code) and Rule 2.8 (unused
file-scope object definition).

Add coverity[misra_c_2012_rule_2_2_violation] and
coverity[misra_c_2012_rule_2_8_violation] suppressions above each static
const declaration, with links to MISRA.md. Add Rule 2.2 and Rule 2.8
sections to MISRA.md documenting the rationale: the variables exist so
the address-of operator in the macros produces a valid const uint8_t *,
and the portable-to-C90 alternative (compound literals) is not viable.
@AniruddhaKanhere AniruddhaKanhere force-pushed the ConvenienceMacrosWithMISRA branch from 375e5de to 176b6bf Compare April 28, 2026 22:40
@AniruddhaKanhere AniruddhaKanhere enabled auto-merge (squash) April 28, 2026 22:42
@AniruddhaKanhere AniruddhaKanhere changed the title Suppress MISRA C:2012 Rule 2.2 and Rule 2.8 for MQTT_PACKET_TYPE_*_VA… Suppress MISRA violations for static helper variables Apr 28, 2026
@AniruddhaKanhere AniruddhaKanhere merged commit 04845c6 into FreeRTOS:main Apr 28, 2026
20 of 22 checks passed
@AniruddhaKanhere AniruddhaKanhere deleted the ConvenienceMacrosWithMISRA branch May 7, 2026 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants