summaryrefslogtreecommitdiff
path: root/net/batman-adv
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2011-05-19 21:43:08 +0200
committerSven Eckelmann <sven@narfation.org>2011-05-30 07:39:35 +0200
commit0bb857511b6a1572ad15dfd7f23d79587d7e2781 (patch)
tree6eb43658148c45033ba4f57f7ccb02add30262d9 /net/batman-adv
parentf5d33d37786af139cecde5af831d64a671bb756b (diff)
downloadlinux-3.10-0bb857511b6a1572ad15dfd7f23d79587d7e2781.tar.gz
linux-3.10-0bb857511b6a1572ad15dfd7f23d79587d7e2781.tar.bz2
linux-3.10-0bb857511b6a1572ad15dfd7f23d79587d7e2781.zip
batman-adv: Check type of x and y in seq_(before|after)
seq_before and seq_after depend on the fact that both sequence numbers have the same type and thus the same bitwidth. We can ensure that by compile time checking using a compare between the pointer to the temporary buffers which were created using the typeof of both parameters. For example gcc would create a warning like "warning: comparison of distinct pointer types lacks a cast". Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/main.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 80be5ad4fc9..610eaf0759a 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -194,8 +194,11 @@ static inline int compare_eth(const void *data1, const void *data2)
* - before adding more than 127 to the starting value - it is a predecessor,
* - when adding 128 - it is neither a predecessor nor a successor,
* - after adding more than 127 to the starting value - it is a successor */
-#define seq_before(x, y) ({typeof(x) _dummy = (x - y); \
- _dummy > smallest_signed_int(_dummy); })
+#define seq_before(x, y) ({typeof(x) _d1 = (x); \
+ typeof(y) _d2 = (y); \
+ typeof(x) _dummy = (_d1 - _d2); \
+ (void) (&_d1 == &_d2); \
+ _dummy > smallest_signed_int(_dummy); })
#define seq_after(x, y) seq_before(y, x)
#endif /* _NET_BATMAN_ADV_MAIN_H_ */