summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2014-02-19 17:16:48 +0100
committerPeter Hutterer <peter.hutterer@who-t.net>2014-02-20 11:38:56 +1000
commit31b0be69e5eea3d1c82d6610bd37bbdb4dca779c (patch)
tree4542423a3d327025149614f7f72c734a1baefc18 /test
parent9368bdec1d37127e97411b684f0b1fce5ee97907 (diff)
test/input: Fix alignment assertion for doubles
The code previously tried to compute the offset of a field in the valuator by subtracting the address of the valuator from the _value_ of the field (rather than the field's address). The correct way to do it would have been (note the &'s): assert(((void *) &v->axisVal - (void *) v) % sizeof(double) == 0); assert(((void *) &v->axes - (void *) v) % sizeof(double) == 0); That's essentially what the offsetof() macro does. Using offsetof() has the added benefit of not using void pointer arithmetic and therefore silencing a warning on some compilers. Signed-off-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'test')
-rw-r--r--test/input.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/input.c b/test/input.c
index 5813e6dc9..9b5db8991 100644
--- a/test/input.c
+++ b/test/input.c
@@ -1390,8 +1390,8 @@ dix_valuator_alloc(void)
assert(v->numAxes == num_axes);
#if !defined(__i386__) && !defined(__m68k__) && !defined(__sh__)
/* must be double-aligned on 64 bit */
- assert(((void *) v->axisVal - (void *) v) % sizeof(double) == 0);
- assert(((void *) v->axes - (void *) v) % sizeof(double) == 0);
+ assert(offsetof(struct _ValuatorClassRec, axisVal) % sizeof(double) == 0);
+ assert(offsetof(struct _ValuatorClassRec, axes) % sizeof(double) == 0);
#endif
num_axes++;
}