Skip to content

Conversation

djiatsaf-st
Copy link
Contributor

@djiatsaf-st djiatsaf-st commented Oct 9, 2025

Corrected the format specifier in LOG_DBG to match the actual type of UMP_GROUP(ump), which returns an unsigned long. Changed '%X' to '%lX' to avoid -Wformat warnings.

To reproduce :

west build -p -b nucleo_g0b1re/stm32g0b1xx samples/subsys/usb/midi -T sample.usb_device_next.midi

Log message :

warning: format '%X' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int'

LOG_DBG("Send MT=%X group=%X", UMP_MT(ump), UMP_GROUP(ump));
      |                                   ~^
      |                                    |
      |                                    unsigned int
      |                                   %lX

@zephyrbot zephyrbot added area: USB Universal Serial Bus size: XS A PR changing only a single line of code labels Oct 9, 2025
Corrected the format specifier in LOG_DBG to match
the actual type of UMP_GROUP(ump), which returns an unsigned long.
Changed '%X' to '%lX' to avoid -Wformat warnings.

Signed-off-by: Fabrice DJIATSA <[email protected]>
Copy link

sonarqubecloud bot commented Oct 9, 2025

uint32_t word;

LOG_DBG("Send MT=%X group=%X", UMP_MT(ump), UMP_GROUP(ump));
LOG_DBG("Send MT=%X group=%lX", UMP_MT(ump), UMP_GROUP(ump));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What type is UMP_GROUP? Wouldn't PRIx32 be better here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the log message, UMP_GROUP is a long unsigned int.

I also tested with PRIx32 using this instruction:

LOG_DBG("Send MT=0x%" PRIx32 " group=0x%" PRIx32, (uint32_t)UMP_MT(ump), (uint32_t)UMP_GROUP(ump));

It builds successfully, but I am not sure if this format is appropriate for printing it.

Copy link
Contributor

@tmon-nordic tmon-nordic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#97297 resolves the underlying issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: USB Universal Serial Bus size: XS A PR changing only a single line of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants