Skip to content

audio: midi: implicit cast to unsigned long result from UMP_xxx() macros #97298

@etienne-lms

Description

@etienne-lms

Describe the bug

Commit 4b04b74 changed some UMP_xxx() to use BIT_MASK() instead of hard coded mask values. This ends in casting the macro result to unsigned long and trigger build warnings/errors. The value masked is of type uint32_t and hence previously was of unsigned int range.

See for example #97293 (comment)

Note that commit 5e83d22 adds other UMP_xxx() macros that do also generate unsigned long values for the same reasons.

Regression

  • This is a regression.

Steps to reproduce

west build  -b stm32h7s78_dk/stm32h7s7xx samples/subsys/usb/midi -T sample.usb_device_next.midi

Relevant log output

In file included from /__w/zephyr/zephyr/include/zephyr/logging/log.h:11,
                 from /__w/zephyr/zephyr/include/zephyr/usb/usbd.h:24,
                 from /__w/zephyr/zephyr/subsys/usb/device_next/class/usbd_midi2.c:13:
/__w/zephyr/zephyr/subsys/usb/device_next/class/usbd_midi2.c: In function 'usbd_midi_send':
/__w/zephyr/zephyr/subsys/usb/device_next/class/usbd_midi2.c:472:17: error: format '%X' expects argument of type 'unsigned int', but argument 3 has type 'long unsigned int' [-Werror=format=]
  472 |         LOG_DBG("Send MT=%X group=%X", UMP_MT(ump), UMP_GROUP(ump));
      |                 ^~~~~~~~~~~~~~~~~~~~~
/__w/zephyr/zephyr/include/zephyr/logging/log_core.h:315:50: note: in definition of macro 'Z_LOG2'
  315 |                         z_log_printf_arg_checker(__VA_ARGS__);                                     \
      |                                                  ^~~~~~~~~~~
/__w/zephyr/zephyr/include/zephyr/logging/log.h:93:22: note: in expansion of macro 'Z_LOG'
   93 | #define LOG_DBG(...) Z_LOG(LOG_LEVEL_DBG, __VA_ARGS__)
      |                      ^~~~~
/__w/zephyr/zephyr/subsys/usb/device_next/class/usbd_midi2.c:472:9: note: in expansion of macro 'LOG_DBG'
  472 |         LOG_DBG("Send MT=%X group=%X", UMP_MT(ump), UMP_GROUP(ump));
      |         ^~~~~~~
/__w/zephyr/zephyr/subsys/usb/device_next/class/usbd_midi2.c:472:36: note: format string is defined here
  472 |         LOG_DBG("Send MT=%X group=%X", UMP_MT(ump), UMP_GROUP(ump));
      |                                   ~^
      |                                    |
      |                                    unsigned int
      |                                   %lX
cc1: all warnings being treated as errors

Impact

Annoyance – Minor irritation; no significant impact on usability or functionality.

Environment

No response

Additional Context

No response

Metadata

Metadata

Labels

RegressionSomething, which was working, does not anymorearea: AudiobugThe issue is a bug, or the PR is fixing a bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions