marcinbor85/microshell

[BUG] Argument format error in xxd command (ush_cmd_xxd.c)

Closed this issue · 0 comments

Compiling with arm-none-eabi GCC 8.3.1 (target is RP2040) - in the hex printing routine of ush_cmd_xxd.c there is a size mismatch of the formatted string and the item passed to sprintf().

Build output:

src/commands/ush_cmd_xxd.c: In function 'ush_buildin_cmd_xxd_service':
src/commands/ush_cmd_xxd.c:80:64: error: format '%X' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int' [-Werror=format=]
                          sprintf(self->desc->output_buffer, "%08X: ", (uint32_t)self->process_index_item);
                                                              ~~~^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                              %08lX

As shown above the error can be fixed by using %08lX (long) format rather than %08X. I think perhaps this issue does not arise when compiling for POSIX, but does on ARM?