On 2024/06/09 5:20, Phil Dennis-Jordan wrote:
Both hw/input/hid.c and hw/usb/dev-wacom.c define identical versions (aside from code formatting) of a clamping function, int_clamp(). (marked inline) To avoid duplication and to enable further re-use, this change moves the function into qemu/cutils.h.
Wht about replacing int_clamp(a, b, c) with MIN(MAX(a, b), c)? MIN(MAX(a, b), c) has a few advantages:
- It works with any integer types (so you can replace even uint_clamp() in hw/display/vga.c) - It makes clear that b is the minimum value and c is the maximum value while it is not with int_clamp() - It is already used in other places.