]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
check event size for version 1
authorJohannes Berg <johannes@sipsolutions.net>
Sun, 5 Jul 2009 12:37:40 +0000 (14:37 +0200)
committerJohannes Berg <johannes@sipsolutions.net>
Sun, 5 Jul 2009 12:37:40 +0000 (14:37 +0200)
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
rfkill.c

diff --git a/core.h b/core.h
index c276b90c57ec05ced3b9f31d6b0e90c07f251a96..d1886dfb3584208185057cd881413be71d417488 100644 (file)
--- 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
index 6b29144b14afbdaffd5b55aa9861898608680b5a..4d4b6b97f7edbd4bf73c5b6e54c761cd6f729e78 100644 (file)
--- 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;
                }