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>
This commit is contained in:
Thierry Reding 2014-02-19 17:16:48 +01:00 committed by Peter Hutterer
parent 9368bdec1d
commit 31b0be69e5

View File

@ -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++;
}