From 6e4e0b50005c68cd15dba0300c3fdf65503750fd Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sun, 5 Jul 2009 14:37:40 +0200 Subject: [PATCH] check event size for version 1 If we ever increase the event struct size, then we will need to handle multiple event sizes, so let's define the current event size and check for that so we remember to fix it up when (if ever) we need to change things. --- core.h | 10 ++++++++++ rfkill.c | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/core.h b/core.h index c276b90c57..d1886dfb35 100644 --- a/core.h +++ b/core.h @@ -1,6 +1,16 @@ #ifndef __CORE #define __CORE +#include "rfkill.h" + extern const char rfkill_version[]; +/* + * first version of event size, + * members idx, type, op, soft, hard + */ +#ifndef RFKILL_EVENT_SIZE_V1 +#define RFKILL_EVENT_SIZE_V1 8 +#endif + #endif diff --git a/rfkill.c b/rfkill.c index 6b29144b14..4d4b6b97f7 100644 --- a/rfkill.c +++ b/rfkill.c @@ -49,7 +49,7 @@ static void rfkill_event(void) break; } - if (len != sizeof(event)) { + if (len != RFKILL_EVENT_SIZE_V1) { fprintf(stderr, "Wrong size of RFKILL event\n"); continue; } @@ -137,7 +137,7 @@ static void rfkill_list(void) break; } - if (len != sizeof(event)) { + if (len != RFKILL_EVENT_SIZE_V1) { fprintf(stderr, "Wrong size of RFKILL event\n"); continue; } -- 2.47.3