Skip to content
Commit 25e68037 authored by Milind Paranjpe's avatar Milind Paranjpe Committed by David Leach
Browse files

drivers: flash: Eliminate warning when compiling with GCC



Address the issue mentioned in zephyrproject-rtos#7412

Using printf() with "%x" to print an off_t value produces the
following warning:

format '%x' expects 'unsigned int', argument has type 'long int'
  228 |  LOG_DBG("Erasing sector at 0x%08x", offset);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~
      |                                      |
      |                                      off_t {aka long int}

In newlib off_t is long. Even though both int and long are 4 bytes wide
in the architecture in use, GCC wants to see "%lx" to printf() a long.
Using "%"PRIx32 still produces the same warning because PRIx32
(from inttypes.h) still expands to simply an "x" and not "lx".

PR zephyrproject-rtos#40004 has solved this by casting offset to
ssize_t. The same solution is emulated here.

Signed-off-by: default avatarMilind Paranjpe <milind@whisper.ai>
parent d1761582
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment