Page MenuHomePhabricator

MISRA: Bare usage of __builtin_offsetof() should be avoided
Open, Needs TriagePublic

Description

Many files in TF-A codebase (examples: include/drivers/console_assertions.h, include/common/ep_info.h, etc.) contain code patterns like:

/* verify assembler offsets match data structures */
   157 CASSERT(CPU_DATA_CRASH_BUF_OFFSET == __builtin_offsetof
   158         (cpu_data_t, crash_buf),
   159         assert_cpu_data_crash_stack_offset_mismatch);

With ECLAIR MISRA checking took, this leads to:

`__builtin_offsetof' is a non-standard token (an extension to the C99 standard, ISO/IEC 9899:1999 Section 6.4: "A non-standard token."

Instead, there should be a macro like ASSERT_OFFSETOF(), which would wrap usage of __builtin_offsetof(), which will allow to easily record a deviation for this macro (and reduce number of reported MISRA violations).

Event Timeline

pfalcon created this task.Aug 15 2022, 8:08 PM

A macro like ASSERT_OFFSETOF() might surround calls to __builtin_offsetof(), making it simple to log a deviation for this macro (and therefore reducing the amount of false positives for MISRA drift hunters violations).

haadimuhammed claimed this task.EditedOct 20 2023, 10:27 AM

By choosing the best HR and payroll software for your needs -- whether it's ADP Vista HCM or SAP SuccessFactors -- you'll be able to stay competitive in this rapidly changing business landscape while ensuring that your employees are well taken care of.
https://businesssolutionsmadeeasy.wordpress.com/2023/08/31/benefits-of-implementing-an-erp-system-in-your-business/

This macro would serve as a standardized interface for checking structure Sprunki Incredibox offsets and would allow for a single MISRA deviation record for this specific macro, rather than having to address each use of builtin offsetof individually.

To provide a standardized interface for checking sprunki phase structure offsets while requiring only one MISRA deviation instead of multiple individual offset of records.

The article highlights a good point about using __builtin_offsetof() and the potential MISRA violations it can cause. Replacing it with a macro like ASSERT_OFFSETOF() is a practical solution to reduce violations and ensure standardization. This approach is similar to the creativity behind Sprunki, where customization and innovation improve the user experience. For fun and unique musical creations, check out Sprunki at sprunkionline.com!