Skip to content

flexible-array-like struct used in the middle of another struct whose array field seems to be unused (static analyzer report) #84251

@Snape3058

Description

@Snape3058

(Report of a static analyzer, may be incorrect)

struct girq_regs has a trailing array field of length one

/** @brief GIRQ registers. Total size = 20(0x14) bytes */
struct girq_regs {
volatile uint32_t SRC;
volatile uint32_t EN_SET;
volatile uint32_t RESULT;
volatile uint32_t EN_CLR;
uint32_t RSVD1[1];
};

which seems to be a flexible array, and used in the middle of other structs and arrays (struct ecia_named_regs and struct ecia_regs below this).

As mentioned in the comments above its definition, it seems not intended to be a flexible array. And the array field RSVD1 is not used as an array (according to the grep results).

If it is intended to be a flexible array struct, it is suggested to use the unsized declaration.
If it is actually an unused placeholder or not a flexible array struct, it would be better to declare field RSVD1 as a normal field (as suggested in https://people.kernel.org/kees/bounded-flexible-arrays-in-c).

report ids: 250106-1641:7-25

Metadata

Metadata

Assignees

Labels

StalebugThe issue is a bug, or the PR is fixing a bugplatform: Microchip MECMicrochip MEC Platformpriority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions