Skip to content

Commit

Permalink
gdbstub: Ignore indexing warning with -Warray-bounds
Browse files Browse the repository at this point in the history
The current implementation can raise a warning as the compiler sees
an attempt to index an array with a size of zero. This can be fixed by
giving `gdb_mem_num_regions` a default value of zero, but this gets
flagged by CI checks. Disable the warning around the array access.

Signed-off-by: Robert Zieba <[email protected]>
  • Loading branch information
GRobertZieba authored and nashif committed Mar 27, 2024
1 parent 0bcf71e commit 6049bbf
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion subsys/debug/gdbstub.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ static bool not_first_start;
/* Empty memory region array */
__weak const struct gdb_mem_region gdb_mem_region_array[0];

/* Number of memory regions, default to 0 */
/* Number of memory regions */
__weak const size_t gdb_mem_num_regions;

/**
Expand All @@ -55,6 +55,12 @@ __weak const size_t gdb_mem_num_regions;
* @return Pointer to the memory region description if found.
* NULL if not found.
*/
#if defined(__GNUC__)
#pragma GCC diagnostic push
/* Required due to gdb_mem_region_array having a default size of zero. */
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif

static inline const
struct gdb_mem_region *find_memory_region(const uintptr_t addr, const size_t len)
{
Expand All @@ -76,6 +82,10 @@ struct gdb_mem_region *find_memory_region(const uintptr_t addr, const size_t len
return ret;
}

#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif

bool gdb_mem_can_read(const uintptr_t addr, const size_t len, uint8_t *align)
{
bool ret = false;
Expand Down

0 comments on commit 6049bbf

Please sign in to comment.