summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/usb/hid-logitech-dj.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/hw/usb/hid-logitech-dj.c b/hw/usb/hid-logitech-dj.c
index c421b6639f..87291ae5b0 100644
--- a/hw/usb/hid-logitech-dj.c
+++ b/hw/usb/hid-logitech-dj.c
@@ -28,6 +28,8 @@
#include "hw/input/hid.h"
#include "hw/usb/hid-logitech-dj.h"
+#define COMPILE_ASSERT(cond) typedef char _compile_assert[1 - 2 * !(cond)]
+
/* Report IDs */
enum {
HIDPP_SHORT = 0x10, /* 7 bytes */
@@ -39,6 +41,11 @@ enum {
/* returns the expected length of the report or 0 if invalid */
static unsigned msg_report_length(HidppMsg *msg)
{
+ COMPILE_ASSERT(sizeof(HidppMsgShort) == 7);
+ COMPILE_ASSERT(sizeof(HidppMsgLong) == 20);
+ COMPILE_ASSERT(sizeof(DjMsgShort) == 15);
+ COMPILE_ASSERT(sizeof(DjMsgLong) == 32);
+
switch (msg->report_id) {
case HIDPP_SHORT: return 7;
case HIDPP_LONG: return 20;