diff options
author | Keith Packard <keithp@keithp.com> | 2012-03-21 12:55:09 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-03-21 13:54:42 -0700 |
commit | 9838b7032ea9792bec21af424c53c07078636d21 (patch) | |
tree | b72d0827dac50f0f3b8eab29b3b7639546d735d7 /test | |
parent | 75199129c603fc8567185ac31866c9518193cb78 (diff) |
Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:
-bap
-psl
-T PrivatePtr
-T pmWait
-T _XFUNCPROTOBEGIN
-T _XFUNCPROTOEND
-T _X_EXPORT
The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.
The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.
The comparison was done with this script:
dir1=$1
dir2=$2
for dir in $dir1 $dir2; do
(cd $dir && find . -name '*.o' | while read file; do
dir=`dirname $file`
base=`basename $file .o`
dump=$dir/$base.dump
objdump -d $file > $dump
done)
done
find $dir1 -name '*.dump' | while read dump; do
otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
diff -u $dump $otherdump
done
Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/ddxstubs.c | 48 | ||||
-rw-r--r-- | test/fixes.c | 53 | ||||
-rw-r--r-- | test/input.c | 445 | ||||
-rw-r--r-- | test/list.c | 110 | ||||
-rw-r--r-- | test/misc.c | 10 | ||||
-rw-r--r-- | test/string.c | 13 | ||||
-rw-r--r-- | test/touch.c | 30 | ||||
-rw-r--r-- | test/xfree86.c | 17 | ||||
-rw-r--r-- | test/xi2/protocol-common.c | 92 | ||||
-rw-r--r-- | test/xi2/protocol-common.h | 24 | ||||
-rw-r--r-- | test/xi2/protocol-eventconvert.c | 453 | ||||
-rw-r--r-- | test/xi2/protocol-xigetclientpointer.c | 27 | ||||
-rw-r--r-- | test/xi2/protocol-xigetselectedevents.c | 88 | ||||
-rw-r--r-- | test/xi2/protocol-xipassivegrabdevice.c | 91 | ||||
-rw-r--r-- | test/xi2/protocol-xiquerydevice.c | 339 | ||||
-rw-r--r-- | test/xi2/protocol-xiquerypointer.c | 45 | ||||
-rw-r--r-- | test/xi2/protocol-xiqueryversion.c | 27 | ||||
-rw-r--r-- | test/xi2/protocol-xiselectevents.c | 130 | ||||
-rw-r--r-- | test/xi2/protocol-xisetclientpointer.c | 23 | ||||
-rw-r--r-- | test/xi2/protocol-xiwarppointer.c | 40 | ||||
-rw-r--r-- | test/xi2/xi2.c | 16 | ||||
-rw-r--r-- | test/xkb.c | 17 | ||||
-rw-r--r-- | test/xtest.c | 27 |
23 files changed, 1138 insertions, 1027 deletions
diff --git a/test/ddxstubs.c b/test/ddxstubs.c index baf2a7a50..a214b9637 100644 --- a/test/ddxstubs.c +++ b/test/ddxstubs.c @@ -33,34 +33,52 @@ #include "input.h" #include "mi.h" -void DDXRingBell(int volume, int pitch, int duration) { +void +DDXRingBell(int volume, int pitch, int duration) +{ } -void ProcessInputEvents(void) { +void +ProcessInputEvents(void) +{ mieqProcessInputEvents(); } -void OsVendorInit(void) { +void +OsVendorInit(void) +{ } -void OsVendorFatalError(void) { +void +OsVendorFatalError(void) +{ } -void AbortDDX(enum ExitCode error) { +void +AbortDDX(enum ExitCode error) +{ OsAbort(); } -void ddxUseMsg(void) { +void +ddxUseMsg(void) +{ } -int ddxProcessArgument(int argc, char *argv[], int i) { +int +ddxProcessArgument(int argc, char *argv[], int i) +{ return 0; } -void ddxGiveUp( enum ExitCode error ) { +void +ddxGiveUp(enum ExitCode error) +{ } -Bool LegalModifier(unsigned int key, DeviceIntPtr pDev) { +Bool +LegalModifier(unsigned int key, DeviceIntPtr pDev) +{ return TRUE; } @@ -76,16 +94,20 @@ int darwinMainScreenY = 0; BOOL no_configure_window = FALSE; -void darwinEvents_lock(void) { +void +darwinEvents_lock(void) +{ } -void darwinEvents_unlock(void) { +void +darwinEvents_unlock(void) +{ } #endif #ifdef DDXBEFORERESET void -ddxBeforeReset(void) { +ddxBeforeReset(void) +{ } #endif - diff --git a/test/fixes.c b/test/fixes.c index 8c804ba26..7807c73ce 100644 --- a/test/fixes.c +++ b/test/fixes.c @@ -42,13 +42,12 @@ _fixes_test_direction(struct PointerBarrier *barrier, int d[4], int permitted) blocking = barrier_is_blocking_direction(barrier, dir); assert(blocking); - for (j = 0; j <= BarrierNegativeY; j++) - { - for (i = 0; i <= BarrierNegativeY; i++) - { + for (j = 0; j <= BarrierNegativeY; j++) { + for (i = 0; i <= BarrierNegativeY; i++) { barrier->directions |= 1 << i; blocking = barrier_is_blocking_direction(barrier, dir); - assert((barrier->directions & permitted) == permitted ? !blocking : blocking); + assert((barrier->directions & permitted) == + permitted ? !blocking : blocking); } } @@ -63,14 +62,14 @@ fixes_pointer_barrier_direction_test(void) int y = 100; int directions[8][4] = { - { x, y, x, y + 100}, /* S */ - { x + 50, y, x - 50, y + 100}, /* SW */ - { x + 100, y, x, y}, /* W */ - { x + 100, y + 50, x, y - 50}, /* NW */ - { x, y + 100, x, y}, /* N */ - { x - 50, y + 100, x + 50, y}, /* NE */ - { x, y, x + 100, y}, /* E */ - { x, y - 50, x + 100, y + 50}, /* SE */ + {x, y, x, y + 100}, /* S */ + {x + 50, y, x - 50, y + 100}, /* SW */ + {x + 100, y, x, y}, /* W */ + {x + 100, y + 50, x, y - 50}, /* NW */ + {x, y + 100, x, y}, /* N */ + {x - 50, y + 100, x + 50, y}, /* NE */ + {x, y, x + 100, y}, /* E */ + {x, y - 50, x + 100, y + 50}, /* SE */ }; barrier.x1 = x; @@ -78,20 +77,21 @@ fixes_pointer_barrier_direction_test(void) barrier.y1 = y - 50; barrier.y2 = y + 49; - _fixes_test_direction(&barrier, directions[0], BarrierPositiveY); - _fixes_test_direction(&barrier, directions[1], BarrierPositiveY | BarrierNegativeX); + _fixes_test_direction(&barrier, directions[1], + BarrierPositiveY | BarrierNegativeX); _fixes_test_direction(&barrier, directions[2], BarrierNegativeX); - _fixes_test_direction(&barrier, directions[3], BarrierNegativeY | BarrierNegativeX); + _fixes_test_direction(&barrier, directions[3], + BarrierNegativeY | BarrierNegativeX); _fixes_test_direction(&barrier, directions[4], BarrierNegativeY); - _fixes_test_direction(&barrier, directions[5], BarrierPositiveX | BarrierNegativeY); + _fixes_test_direction(&barrier, directions[5], + BarrierPositiveX | BarrierNegativeY); _fixes_test_direction(&barrier, directions[6], BarrierPositiveX); - _fixes_test_direction(&barrier, directions[7], BarrierPositiveY | BarrierPositiveX); - + _fixes_test_direction(&barrier, directions[7], + BarrierPositiveY | BarrierPositiveX); } - static void fixes_pointer_barriers_test(void) { @@ -123,7 +123,7 @@ fixes_pointer_barriers_test(void) /* across, but outside of y range */ x1 = x + 1; - x2 = x -1; + x2 = x - 1; y1 = y + 100; y2 = y + 100; assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance)); @@ -184,7 +184,6 @@ fixes_pointer_barriers_test(void) y2 = y + 100; assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance)); - /* horizontal barrier */ barrier.x1 = x - 50; barrier.x2 = x + 50; @@ -207,7 +206,7 @@ fixes_pointer_barriers_test(void) x1 = x + 100; x2 = x + 100; y1 = y + 1; - y2 = y -1; + y2 = y - 1; assert(!barrier_is_blocking(&barrier, x1, y1, x2, y2, &distance)); /* across, diagonally */ @@ -268,14 +267,15 @@ fixes_pointer_barriers_test(void) } -static void fixes_pointer_barrier_clamp_test(void) +static void +fixes_pointer_barrier_clamp_test(void) { struct PointerBarrier barrier; int x = 100; int y = 100; - int cx, cy; /* clamped */ + int cx, cy; /* clamped */ /* vert barrier */ barrier.x1 = x; @@ -316,7 +316,8 @@ static void fixes_pointer_barrier_clamp_test(void) assert(cy == barrier.y1); } -int main(int argc, char** argv) +int +main(int argc, char **argv) { fixes_pointer_barriers_test(); diff --git a/test/input.c b/test/input.c index e0291417f..90ab9aea3 100644 --- a/test/input.c +++ b/test/input.c @@ -49,7 +49,8 @@ * * Result: All axes set to default values (usually 0). */ -static void dix_init_valuators(void) +static void +dix_init_valuators(void) { DeviceIntRec dev; ValuatorClassPtr val; @@ -58,9 +59,8 @@ static void dix_init_valuators(void) int i; Atom atoms[MAX_VALUATORS] = { 0 }; - memset(&dev, 0, sizeof(DeviceIntRec)); - dev.type = MASTER_POINTER; /* claim it's a master to stop ptracccel */ + dev.type = MASTER_POINTER; /* claim it's a master to stop ptracccel */ assert(InitValuatorClassDeviceStruct(NULL, 0, atoms, 0, 0) == FALSE); assert(InitValuatorClassDeviceStruct(&dev, num_axes, atoms, 0, Absolute)); @@ -71,8 +71,7 @@ static void dix_init_valuators(void) assert(val->numMotionEvents == 0); assert(val->axisVal); - for (i = 0; i < num_axes; i++) - { + for (i = 0; i < num_axes; i++) { assert(val->axisVal[i] == 0); assert(val->axes->min_value == NO_AXIS_LIMITS); assert(val->axes->max_value == NO_AXIS_LIMITS); @@ -82,39 +81,51 @@ static void dix_init_valuators(void) assert(dev.last.numValuators == num_axes); /* invalid increment */ - assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_VERTICAL, 0.0, SCROLL_FLAG_NONE) == FALSE); + assert(SetScrollValuator + (&dev, 0, SCROLL_TYPE_VERTICAL, 0.0, SCROLL_FLAG_NONE) == FALSE); /* invalid type */ - assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_VERTICAL - 1, 1.0, SCROLL_FLAG_NONE) == FALSE); - assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_HORIZONTAL + 1, 1.0, SCROLL_FLAG_NONE) == FALSE); + assert(SetScrollValuator + (&dev, 0, SCROLL_TYPE_VERTICAL - 1, 1.0, SCROLL_FLAG_NONE) == FALSE); + assert(SetScrollValuator + (&dev, 0, SCROLL_TYPE_HORIZONTAL + 1, 1.0, + SCROLL_FLAG_NONE) == FALSE); /* invalid axisnum */ - assert(SetScrollValuator(&dev, 2, SCROLL_TYPE_HORIZONTAL, 1.0, SCROLL_FLAG_NONE) == FALSE); + assert(SetScrollValuator + (&dev, 2, SCROLL_TYPE_HORIZONTAL, 1.0, SCROLL_FLAG_NONE) == FALSE); /* valid */ - assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_VERTICAL, 3.0, SCROLL_FLAG_NONE) == TRUE); + assert(SetScrollValuator + (&dev, 0, SCROLL_TYPE_VERTICAL, 3.0, SCROLL_FLAG_NONE) == TRUE); axis = &dev.valuator->axes[0]; assert(axis->scroll.increment == 3.0); assert(axis->scroll.type == SCROLL_TYPE_VERTICAL); assert(axis->scroll.flags == 0); /* valid */ - assert(SetScrollValuator(&dev, 1, SCROLL_TYPE_HORIZONTAL, 2.0, SCROLL_FLAG_NONE) == TRUE); + assert(SetScrollValuator + (&dev, 1, SCROLL_TYPE_HORIZONTAL, 2.0, SCROLL_FLAG_NONE) == TRUE); axis = &dev.valuator->axes[1]; assert(axis->scroll.increment == 2.0); assert(axis->scroll.type == SCROLL_TYPE_HORIZONTAL); assert(axis->scroll.flags == 0); /* can add another non-preffered axis */ - assert(SetScrollValuator(&dev, 1, SCROLL_TYPE_VERTICAL, 5.0, SCROLL_FLAG_NONE) == TRUE); - assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_HORIZONTAL, 5.0, SCROLL_FLAG_NONE) == TRUE); + assert(SetScrollValuator + (&dev, 1, SCROLL_TYPE_VERTICAL, 5.0, SCROLL_FLAG_NONE) == TRUE); + assert(SetScrollValuator + (&dev, 0, SCROLL_TYPE_HORIZONTAL, 5.0, SCROLL_FLAG_NONE) == TRUE); /* can overwrite with Preferred */ - assert(SetScrollValuator(&dev, 1, SCROLL_TYPE_VERTICAL, 5.5, SCROLL_FLAG_PREFERRED) == TRUE); + assert(SetScrollValuator + (&dev, 1, SCROLL_TYPE_VERTICAL, 5.5, SCROLL_FLAG_PREFERRED) == TRUE); axis = &dev.valuator->axes[1]; assert(axis->scroll.increment == 5.5); assert(axis->scroll.type == SCROLL_TYPE_VERTICAL); assert(axis->scroll.flags == SCROLL_FLAG_PREFERRED); - assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_HORIZONTAL, 8.8, SCROLL_FLAG_PREFERRED) == TRUE); + assert(SetScrollValuator + (&dev, 0, SCROLL_TYPE_HORIZONTAL, 8.8, + SCROLL_FLAG_PREFERRED) == TRUE); axis = &dev.valuator->axes[0]; assert(axis->scroll.increment == 8.8); assert(axis->scroll.type == SCROLL_TYPE_HORIZONTAL); @@ -122,17 +133,19 @@ static void dix_init_valuators(void) /* can overwrite as none */ assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_NONE, 5.0, - SCROLL_FLAG_NONE) == TRUE); + SCROLL_FLAG_NONE) == TRUE); axis = &dev.valuator->axes[0]; assert(axis->scroll.type == SCROLL_TYPE_NONE); /* can overwrite axis with new settings */ - assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_VERTICAL, 5.0, SCROLL_FLAG_NONE) == TRUE); + assert(SetScrollValuator + (&dev, 0, SCROLL_TYPE_VERTICAL, 5.0, SCROLL_FLAG_NONE) == TRUE); axis = &dev.valuator->axes[0]; assert(axis->scroll.type == SCROLL_TYPE_VERTICAL); assert(axis->scroll.increment == 5.0); assert(axis->scroll.flags == SCROLL_FLAG_NONE); - assert(SetScrollValuator(&dev, 0, SCROLL_TYPE_VERTICAL, 3.0, SCROLL_FLAG_NONE) == TRUE); + assert(SetScrollValuator + (&dev, 0, SCROLL_TYPE_VERTICAL, 3.0, SCROLL_FLAG_NONE) == TRUE); assert(axis->scroll.type == SCROLL_TYPE_VERTICAL); assert(axis->scroll.increment == 3.0); assert(axis->scroll.flags == SCROLL_FLAG_NONE); @@ -140,7 +153,8 @@ static void dix_init_valuators(void) /* just check the known success cases, and that error cases set the client's * error value correctly. */ -static void dix_check_grab_values(void) +static void +dix_check_grab_values(void) { ClientRec client; GrabParameters param; @@ -195,7 +209,6 @@ static void dix_check_grab_values(void) assert(client.errorValue == param.modifiers); assert(client.errorValue == (1 << 13)); - param.modifiers = AnyModifier; param.ownerEvents = TRUE; rc = CheckGrabValues(&client, ¶m); @@ -208,12 +221,12 @@ static void dix_check_grab_values(void) assert(client.errorValue == 3); } - /** * Convert various internal events to the matching core event and verify the * parameters. */ -static void dix_event_to_core(int type) +static void +dix_event_to_core(int type) { DeviceEvent ev; xEvent *core; @@ -249,41 +262,41 @@ static void dix_event_to_core(int type) state = 0; detail = 0; - ev.header = 0xFF; - ev.length = sizeof(DeviceEvent); - ev.time = time; - ev.root_y = x; - ev.root_x = y; + ev.header = 0xFF; + ev.length = sizeof(DeviceEvent); + ev.time = time; + ev.root_y = x; + ev.root_x = y; SetBit(ev.valuators.mask, 0); SetBit(ev.valuators.mask, 1); - ev.root = ROOT_WINDOW_ID; + ev.root = ROOT_WINDOW_ID; ev.corestate = state; ev.detail.key = detail; ev.type = type; ev.detail.key = 0; - rc = EventToCore((InternalEvent*)&ev, &core, &count); + rc = EventToCore((InternalEvent *) &ev, &core, &count); test_event(); x = 1; y = 2; ev.root_x = x; ev.root_y = y; - rc = EventToCore((InternalEvent*)&ev, &core, &count); + rc = EventToCore((InternalEvent *) &ev, &core, &count); test_event(); x = 0x7FFF; y = 0x7FFF; ev.root_x = x; ev.root_y = y; - rc = EventToCore((InternalEvent*)&ev, &core, &count); + rc = EventToCore((InternalEvent *) &ev, &core, &count); test_event(); - x = 0x8000; /* too high */ - y = 0x8000; /* too high */ + x = 0x8000; /* too high */ + y = 0x8000; /* too high */ ev.root_x = x; ev.root_y = y; - rc = EventToCore((InternalEvent*)&ev, &core, &count); + rc = EventToCore((InternalEvent *) &ev, &core, &count); assert(rc == Success); assert(core); assert(count == 1); @@ -296,34 +309,34 @@ static void dix_event_to_core(int type) ev.root_y = y; time = 0; ev.time = time; - rc = EventToCore((InternalEvent*)&ev, &core, &count); + rc = EventToCore((InternalEvent *) &ev, &core, &count); test_event(); detail = 1; ev.detail.key = detail; - rc = EventToCore((InternalEvent*)&ev, &core, &count); + rc = EventToCore((InternalEvent *) &ev, &core, &count); test_event(); - detail = 0xFF; /* highest value */ + detail = 0xFF; /* highest value */ ev.detail.key = detail; - rc = EventToCore((InternalEvent*)&ev, &core, &count); + rc = EventToCore((InternalEvent *) &ev, &core, &count); test_event(); - detail = 0xFFF; /* too big */ + detail = 0xFFF; /* too big */ ev.detail.key = detail; - rc = EventToCore((InternalEvent*)&ev, &core, &count); + rc = EventToCore((InternalEvent *) &ev, &core, &count); assert(rc == BadMatch); - detail = 0xFF; /* too big */ + detail = 0xFF; /* too big */ ev.detail.key = detail; - state = 0xFFFF; /* highest value */ + state = 0xFFFF; /* highest value */ ev.corestate = state; - rc = EventToCore((InternalEvent*)&ev, &core, &count); + rc = EventToCore((InternalEvent *) &ev, &core, &count); test_event(); - state = 0x10000; /* too big */ + state = 0x10000; /* too big */ ev.corestate = state; - rc = EventToCore((InternalEvent*)&ev, &core, &count); + rc = EventToCore((InternalEvent *) &ev, &core, &count); assert(rc == Success); assert(core); assert(count == 1); @@ -333,22 +346,24 @@ static void dix_event_to_core(int type) #undef test_event } -static void dix_event_to_core_fail(int evtype, int expected_rc) +static void +dix_event_to_core_fail(int evtype, int expected_rc) { DeviceEvent ev; xEvent *core; int rc; int count; - ev.header = 0xFF; - ev.length = sizeof(DeviceEvent); + ev.header = 0xFF; + ev.length = sizeof(DeviceEvent); - ev.type = evtype; - rc = EventToCore((InternalEvent*)&ev, &core, &count); + ev.type = evtype; + rc = EventToCore((InternalEvent *) &ev, &core, &count); assert(rc == expected_rc); } -static void dix_event_to_core_conversion(void) +static void +dix_event_to_core_conversion(void) { dix_event_to_core_fail(0, BadImplementation); dix_event_to_core_fail(1, BadImplementation); @@ -370,11 +385,12 @@ _dix_test_xi_convert(DeviceEvent *ev, int expected_rc, int expected_count) int count = 0; int rc; - rc = EventToXI((InternalEvent*)ev, &xi, &count); + rc = EventToXI((InternalEvent *) ev, &xi, &count); assert(rc == expected_rc); assert(count >= expected_count); - if (count > 0){ - deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer*)xi; + if (count > 0) { + deviceKeyButtonPointer *kbp = (deviceKeyButtonPointer *) xi; + assert(kbp->type == IEventBase + ev->type); assert(kbp->detail == ev->detail.key); assert(kbp->time == ev->time); @@ -390,12 +406,12 @@ _dix_test_xi_convert(DeviceEvent *ev, int expected_rc, int expected_count) assert(kbp->same_screen == FALSE); while (--count > 0) { - deviceValuator *v = (deviceValuator*)&xi[count]; + deviceValuator *v = (deviceValuator *) & xi[count]; + assert(v->type == DeviceValuator); assert(v->num_valuators <= 6); } - free(xi); } } @@ -406,9 +422,10 @@ _dix_test_xi_convert(DeviceEvent *ev, int expected_rc, int expected_count) * - right number of events generated * - extra events are valuators */ -static void dix_event_to_xi1_conversion(void) +static void +dix_event_to_xi1_conversion(void) { - DeviceEvent ev = {0}; + DeviceEvent ev = { 0 }; int time; int x, y; int state; @@ -417,16 +434,16 @@ static void dix_event_to_xi1_conversion(void) int deviceid; IEventBase = 80; - DeviceValuator = IEventBase - 1; - DeviceKeyPress = IEventBase + ET_KeyPress; - DeviceKeyRelease = IEventBase + ET_KeyRelease; - DeviceButtonPress = IEventBase + ET_ButtonPress; + DeviceValuator = IEventBase - 1; + DeviceKeyPress = IEventBase + ET_KeyPress; + DeviceKeyRelease = IEventBase + ET_KeyRelease; + DeviceButtonPress = IEventBase + ET_ButtonPress; DeviceButtonRelease = IEventBase + ET_ButtonRelease; - DeviceMotionNotify = IEventBase + ET_Motion; - DeviceFocusIn = IEventBase + ET_FocusIn; - DeviceFocusOut = IEventBase + ET_FocusOut; - ProximityIn = IEventBase + ET_ProximityIn; - ProximityOut = IEventBase + ET_ProximityOut; + DeviceMotionNotify = IEventBase + ET_Motion; + DeviceFocusIn = IEventBase + ET_FocusIn; + DeviceFocusOut = IEventBase + ET_FocusOut; + ProximityIn = IEventBase + ET_ProximityIn; + ProximityOut = IEventBase + ET_ProximityOut; /* EventToXI callocs */ x = 0; @@ -436,39 +453,53 @@ static void dix_event_to_xi1_conversion(void) detail = 0; deviceid = 4; - ev.header = 0xFF; + ev.header = 0xFF; - ev.header = 0xFF; - ev.length = sizeof(DeviceEvent); - ev.time = time; - ev.root_y = x; - ev.root_x = y; + ev.header = 0xFF; + ev.length = sizeof(DeviceEvent); + ev.time = time; + ev.root_y = x; + ev.root_x = y; SetBit(ev.valuators.mask, 0); SetBit(ev.valuators.mask, 1); - ev.root = ROOT_WINDOW_ID; - ev.corestate = state; - ev.detail.key = detail; - ev.deviceid = deviceid; + ev.root = ROOT_WINDOW_ID; + ev.corestate = state; + ev.detail.key = detail; + ev.deviceid = deviceid; /* test all types for bad match */ - ev.type = ET_KeyPress; _dix_test_xi_convert(&ev, Success, 1); - ev.type = ET_KeyRelease; _dix_test_xi_convert(&ev, Success, 1); - ev.type = ET_ButtonPress; _dix_test_xi_convert(&ev, Success, 1); - ev.type = ET_ButtonRelease; _dix_test_xi_convert(&ev, Success, 1); - ev.type = ET_Motion; _dix_test_xi_convert(&ev, Success, 1); - ev.type = ET_ProximityIn; _dix_test_xi_convert(&ev, Success, 1); - ev.type = ET_ProximityOut; _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_KeyPress; + _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_KeyRelease; + _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_ButtonPress; + _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_ButtonRelease; + _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_Motion; + _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_ProximityIn; + _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_ProximityOut; + _dix_test_xi_convert(&ev, Success, 1); /* No axes */ ClearBit(ev.valuators.mask, 0); ClearBit(ev.valuators.mask, 1); - ev.type = ET_KeyPress; _dix_test_xi_convert(&ev, Success, 1); - ev.type = ET_KeyRelease; _dix_test_xi_convert(&ev, Success, 1); - ev.type = ET_ButtonPress; _dix_test_xi_convert(&ev, Success, 1); - ev.type = ET_ButtonRelease; _dix_test_xi_convert(&ev, Success, 1); - ev.type = ET_Motion; _dix_test_xi_convert(&ev, BadMatch, 0); - ev.type = ET_ProximityIn; _dix_test_xi_convert(&ev, BadMatch, 0); - ev.type = ET_ProximityOut; _dix_test_xi_convert(&ev, BadMatch, 0); + ev.type = ET_KeyPress; + _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_KeyRelease; + _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_ButtonPress; + _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_ButtonRelease; + _dix_test_xi_convert(&ev, Success, 1); + ev.type = ET_Motion; + _dix_test_xi_convert(&ev, BadMatch, 0); + ev.type = ET_ProximityIn; + _dix_test_xi_convert(&ev, BadMatch, 0); + ev.type = ET_ProximityOut; + _dix_test_xi_convert(&ev, BadMatch, 0); /* more than 6 axes → 2 valuator events */ SetBit(ev.valuators.mask, 0); @@ -478,14 +509,20 @@ static void dix_event_to_xi1_conversion(void) SetBit(ev.valuators.mask, 4); SetBit(ev.valuators.mask, 5); SetBit(ev.valuators.mask, 6); - ev.type = ET_KeyPress; _dix_test_xi_convert(&ev, Success, 2); - ev.type = ET_KeyRelease; _dix_test_xi_convert(&ev, Success, 2); - ev.type = ET_ButtonPress; _dix_test_xi_convert(&ev, Success, 2); - ev.type = ET_ButtonRelease; _dix_test_xi_convert(&ev, Success, 2); - ev.type = ET_Motion; _dix_test_xi_convert(&ev, Success, 2); - ev.type = ET_ProximityIn; _dix_test_xi_convert(&ev, Success, 2); - ev.type = ET_ProximityOut; _dix_test_xi_convert(&ev, Success, 2); - + ev.type = ET_KeyPress; + _dix_test_xi_convert(&ev, Success, 2); + ev.type = ET_KeyRelease; + _dix_test_xi_convert(&ev, Success, 2); + ev.type = ET_ButtonPress; + _dix_test_xi_convert(&ev, Success, 2); + ev.type = ET_ButtonRelease; + _dix_test_xi_convert(&ev, Success, 2); + ev.type = ET_Motion; + _dix_test_xi_convert(&ev, Success, 2); + ev.type = ET_ProximityIn; + _dix_test_xi_convert(&ev, Success, 2); + ev.type = ET_ProximityOut; + _dix_test_xi_convert(&ev, Success, 2); /* keycode too high */ ev.type = ET_KeyPress; @@ -499,8 +536,8 @@ static void dix_event_to_xi1_conversion(void) _dix_test_xi_convert(&ev, Success, 0); } - -static void xi2_struct_sizes(void) +static void +xi2_struct_sizes(void) { #define compare(req) \ assert(sizeof(req) == sz_##req); @@ -529,8 +566,8 @@ static void xi2_struct_sizes(void) #undef compare } - -static void dix_grab_matching(void) +static void +dix_grab_matching(void) { DeviceIntRec xi_all_devices, xi_all_master_devices, dev1, dev2; GrabRec a, b; @@ -891,36 +928,44 @@ static void dix_grab_matching(void) assert(rc == TRUE); } -static void test_bits_to_byte(int i) +static void +test_bits_to_byte(int i) { - int expected_bytes; - expected_bytes = (i + 7)/8; + int expected_bytes; + + expected_bytes = (i + 7) / 8; - assert(bits_to_bytes(i) >= i/8); - assert((bits_to_bytes(i) * 8) - i <= 7); - assert(expected_bytes == bits_to_bytes(i)); + assert(bits_to_bytes(i) >= i / 8); + assert((bits_to_bytes(i) * 8) - i <= 7); + assert(expected_bytes == bits_to_bytes(i)); } -static void test_bytes_to_int32(int i) +static void +test_bytes_to_int32(int i) { - int expected_4byte; - expected_4byte = (i + 3)/4; + int expected_4byte; + + expected_4byte = (i + 3) / 4; - assert(bytes_to_int32(i) <= i); - assert((bytes_to_int32(i) * 4) - i <= 3); - assert(expected_4byte == bytes_to_int32(i)); + assert(bytes_to_int32(i) <= i); + assert((bytes_to_int32(i) * 4) - i <= 3); + assert(expected_4byte == bytes_to_int32(i)); } -static void test_pad_to_int32(int i) +static void +test_pad_to_int32(int i) { - int expected_bytes; - expected_bytes = ((i + 3)/4) * 4; + int expected_bytes; + + expected_bytes = ((i + 3) / 4) * 4; - assert(pad_to_int32(i) >= i); - assert(pad_to_int32(i) - i <= 3); - assert(expected_bytes == pad_to_int32(i)); + assert(pad_to_int32(i) >= i); + assert(pad_to_int32(i) - i <= 3); + assert(expected_bytes == pad_to_int32(i)); } -static void include_byte_padding_macros(void) + +static void +include_byte_padding_macros(void) { printf("Testing bits_to_bytes()\n"); @@ -969,7 +1014,8 @@ static void include_byte_padding_macros(void) test_pad_to_int32(INT_MAX - 3); } -static void xi_unregister_handlers(void) +static void +xi_unregister_handlers(void) { DeviceIntRec dev; int handler; @@ -985,7 +1031,7 @@ static void xi_unregister_handlers(void) printf("Unlinking from front.\n"); - XIUnregisterPropertyHandler(&dev, 4); /* NOOP */ + XIUnregisterPropertyHandler(&dev, 4); /* NOOP */ assert(dev.properties.handlers->id == 3); XIUnregisterPropertyHandler(&dev, 3); assert(dev.properties.handlers->id == 2); @@ -1000,7 +1046,7 @@ static void xi_unregister_handlers(void) assert(handler == 5); handler = XIRegisterPropertyHandler(&dev, NULL, NULL, NULL); assert(handler == 6); - XIUnregisterPropertyHandler(&dev, 3); /* NOOP */ + XIUnregisterPropertyHandler(&dev, 3); /* NOOP */ assert(dev.properties.handlers->next->next->next == NULL); XIUnregisterPropertyHandler(&dev, 4); assert(dev.properties.handlers->next->next == NULL); @@ -1018,12 +1064,12 @@ static void xi_unregister_handlers(void) XIDeleteAllDeviceProperties(&dev); assert(dev.properties.handlers == NULL); - XIUnregisterPropertyHandler(&dev, 7); /* NOOP */ + XIUnregisterPropertyHandler(&dev, 7); /* NOOP */ } -static void cmp_attr_fields(InputAttributes *attr1, - InputAttributes *attr2) +static void +cmp_attr_fields(InputAttributes * attr1, InputAttributes * attr2) { char **tags1, **tags2; @@ -1031,47 +1077,46 @@ static void cmp_attr_fields(InputAttributes *attr1, assert(attr1 != attr2); assert(attr1->flags == attr2->flags); - if (attr1->product != NULL) - { + if (attr1->product != NULL) { assert(attr1->product != attr2->product); assert(strcmp(attr1->product, attr2->product) == 0); - } else + } + else assert(attr2->product == NULL); - if (attr1->vendor != NULL) - { + if (attr1->vendor != NULL) { assert(attr1->vendor != attr2->vendor); assert(strcmp(attr1->vendor, attr2->vendor) == 0); - } else + } + else assert(attr2->vendor == NULL); - if (attr1->device != NULL) - { + if (attr1->device != NULL) { assert(attr1->device != attr2->device); assert(strcmp(attr1->device, attr2->device) == 0); - } else + } + else assert(attr2->device == NULL); - if (attr1->pnp_id != NULL) - { + if (attr1->pnp_id != NULL) { assert(attr1->pnp_id != attr2->pnp_id); assert(strcmp(attr1->pnp_id, attr2->pnp_id) == 0); - } else + } + else assert(attr2->pnp_id == NULL); - if (attr1->usb_id != NULL) - { + if (attr1->usb_id != NULL) { assert(attr1->usb_id != attr2->usb_id); assert(strcmp(attr1->usb_id, attr2->usb_id) == 0); - } else + } + else assert(attr2->usb_id == NULL); tags1 = attr1->tags; tags2 = attr2->tags; /* if we don't have any tags, skip the tag checking bits */ - if (!tags1) - { + if (!tags1) { assert(!tags2); return; } @@ -1081,8 +1126,7 @@ static void cmp_attr_fields(InputAttributes *attr1, assert(*tags2); /* check for identical content, but duplicated */ - while (*tags1) - { + while (*tags1) { assert(*tags1 != *tags2); assert(strcmp(*tags1, *tags2) == 0); tags1++; @@ -1094,8 +1138,7 @@ static void cmp_attr_fields(InputAttributes *attr1, /* check for not sharing memory */ tags1 = attr1->tags; - while (*tags1) - { + while (*tags1) { tags2 = attr2->tags; while (*tags2) assert(*tags1 != *tags2++); @@ -1104,11 +1147,12 @@ static void cmp_attr_fields(InputAttributes *attr1, } } -static void dix_input_attributes(void) +static void +dix_input_attributes(void) { - InputAttributes orig = {0}; + InputAttributes orig = { 0 }; InputAttributes *new; - char *tags[4] = {"tag1", "tag2", "tag2", NULL}; + char *tags[4] = { "tag1", "tag2", "tag2", NULL }; new = DuplicateInputAttributes(NULL); assert(!new); @@ -1152,7 +1196,8 @@ static void dix_input_attributes(void) FreeInputAttributes(new); } -static void dix_input_valuator_masks(void) +static void +dix_input_valuator_masks(void) { ValuatorMask *mask = NULL, *copy; int nvaluators = MAX_VALUATORS; @@ -1161,8 +1206,7 @@ static void dix_input_valuator_masks(void) int i; int first_val, num_vals; - for (i = 0; i < nvaluators; i++) - { + for (i = 0; i < nvaluators; i++) { valuators[i] = i + 0.5; val_ranged[i] = i; } @@ -1172,8 +1216,7 @@ static void dix_input_valuator_masks(void) assert(valuator_mask_size(mask) == 0); assert(valuator_mask_num_valuators(mask) == 0); - for (i = 0; i < nvaluators; i++) - { + for (i = 0; i < nvaluators; i++) { assert(!valuator_mask_isset(mask, i)); valuator_mask_set_double(mask, i, valuators[i]); assert(valuator_mask_isset(mask, i)); @@ -1183,8 +1226,7 @@ static void dix_input_valuator_masks(void) assert(valuator_mask_num_valuators(mask) == i + 1); } - for (i = 0; i < nvaluators; i++) - { + for (i = 0; i < nvaluators; i++) { assert(valuator_mask_isset(mask, i)); valuator_mask_unset(mask, i); /* we're removing valuators from the front, so size should stay the @@ -1207,19 +1249,18 @@ static void dix_input_valuator_masks(void) valuator_mask_set_range(mask, first_val, num_vals, val_ranged); assert(valuator_mask_size(mask) == first_val + num_vals); assert(valuator_mask_num_valuators(mask) == num_vals); - for (i = 0; i < nvaluators; i++) - { + for (i = 0; i < nvaluators; i++) { double val; - if (i < first_val || i >= first_val + num_vals) - { + + if (i < first_val || i >= first_val + num_vals) { assert(!valuator_mask_isset(mask, i)); assert(!valuator_mask_fetch_double(mask, i, &val)); - } else - { + } + else { assert(valuator_mask_isset(mask, i)); assert(valuator_mask_get(mask, i) == val_ranged[i - first_val]); assert(valuator_mask_get_double(mask, i) == - val_ranged[i - first_val]); + val_ranged[i - first_val]); assert(valuator_mask_fetch_double(mask, i, &val)); assert(val_ranged[i - first_val] == val); } @@ -1229,11 +1270,12 @@ static void dix_input_valuator_masks(void) valuator_mask_copy(copy, mask); assert(mask != copy); assert(valuator_mask_size(mask) == valuator_mask_size(copy)); - assert(valuator_mask_num_valuators(mask) == valuator_mask_num_valuators(copy)); + assert(valuator_mask_num_valuators(mask) == + valuator_mask_num_valuators(copy)); - for (i = 0; i < nvaluators; i++) - { + for (i = 0; i < nvaluators; i++) { double a, b; + assert(valuator_mask_isset(mask, i) == valuator_mask_isset(copy, i)); if (!valuator_mask_isset(mask, i)) @@ -1241,7 +1283,7 @@ static void dix_input_valuator_masks(void) assert(valuator_mask_get(mask, i) == valuator_mask_get(copy, i)); assert(valuator_mask_get_double(mask, i) == - valuator_mask_get_double(copy, i)); + valuator_mask_get_double(copy, i)); assert(valuator_mask_fetch_double(mask, i, &a)); assert(valuator_mask_fetch_double(copy, i, &b)); assert(a == b); @@ -1251,7 +1293,8 @@ static void dix_input_valuator_masks(void) assert(mask == NULL); } -static void dix_valuator_mode(void) +static void +dix_valuator_mode(void) { DeviceIntRec dev; const int num_axes = MAX_VALUATORS; @@ -1259,13 +1302,12 @@ static void dix_valuator_mode(void) Atom atoms[MAX_VALUATORS] = { 0 }; memset(&dev, 0, sizeof(DeviceIntRec)); - dev.type = MASTER_POINTER; /* claim it's a master to stop ptracccel */ + dev.type = MASTER_POINTER; /* claim it's a master to stop ptracccel */ assert(InitValuatorClassDeviceStruct(NULL, 0, atoms, 0, 0) == FALSE); assert(InitValuatorClassDeviceStruct(&dev, num_axes, atoms, 0, Absolute)); - for (i = 0; i < num_axes; i++) - { + for (i = 0; i < num_axes; i++) { assert(valuator_get_mode(&dev, i) == Absolute); valuator_set_mode(&dev, i, Relative); assert(dev.valuator->axes[i].mode == Relative); @@ -1281,17 +1323,17 @@ static void dix_valuator_mode(void) assert(valuator_get_mode(&dev, i) == Relative); } -static void include_bit_test_macros(void) +static void +include_bit_test_macros(void) { uint8_t mask[9] = { 0 }; int i; - for (i = 0; i < sizeof(mask)/sizeof(mask[0]); i++) - { + for (i = 0; i < sizeof(mask) / sizeof(mask[0]); i++) { assert(BitIsOn(mask, i) == 0); SetBit(mask, i); assert(BitIsOn(mask, i) == 1); - assert(!!(mask[i/8] & (1 << (i % 8)))); + assert(! !(mask[i / 8] & (1 << (i % 8)))); assert(CountBits(mask, sizeof(mask)) == 1); ClearBit(mask, i); assert(BitIsOn(mask, i) == 0); @@ -1301,29 +1343,30 @@ static void include_bit_test_macros(void) /** * Ensure that val->axisVal and val->axes are aligned on doubles. */ -static void dix_valuator_alloc(void) +static void +dix_valuator_alloc(void) { ValuatorClassPtr v = NULL; int num_axes = 0; - while (num_axes < 5) - { + while (num_axes < 5) { v = AllocValuatorClass(v, num_axes); assert(v); assert(v->numAxes == num_axes); #if !defined(__i386__) && !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(((void *) v->axisVal - (void *) v) % sizeof(double) == 0); + assert(((void *) v->axes - (void *) v) % sizeof(double) == 0); #endif - num_axes ++; + num_axes++; } free(v); } -static void dix_get_master(void) +static void +dix_get_master(void) { DeviceIntRec vcp, vck; DeviceIntRec ptr, kbd; @@ -1396,8 +1439,8 @@ static void dix_get_master(void) assert(GetMaster(&floating, POINTER_OR_FLOAT) == &floating); } - -static void input_option_test(void) +static void +input_option_test(void) { InputOption *list = NULL; InputOption *opt; @@ -1559,6 +1602,7 @@ static void dix_double_fp_conversion(void) { uint32_t i; + printf("Testing double to FP1616/FP3232 conversions\n"); _test_double_fp16_values(0); @@ -1622,25 +1666,28 @@ dix_double_fp_conversion(void) static uint32_t mieq_test_event_last_processed; static void -mieq_test_event_handler(int screenNum, InternalEvent *ie, DeviceIntPtr dev) { - RawDeviceEvent *e = (RawDeviceEvent *)ie; +mieq_test_event_handler(int screenNum, InternalEvent *ie, DeviceIntPtr dev) +{ + RawDeviceEvent *e = (RawDeviceEvent *) ie; assert(e->type == ET_RawMotion); assert(e->flags > mieq_test_event_last_processed); mieq_test_event_last_processed = e->flags; } -static void _mieq_test_generate_events(uint32_t start, uint32_t count) { +static void +_mieq_test_generate_events(uint32_t start, uint32_t count) +{ count += start; while (start < count) { - RawDeviceEvent e = {0}; + RawDeviceEvent e = { 0 }; e.header = ET_Internal; e.type = ET_RawMotion; e.length = sizeof(e); e.time = GetTimeInMillis(); e.flags = start; - mieqEnqueue(NULL, (InternalEvent*)&e); + mieqEnqueue(NULL, (InternalEvent *) &e); start++; } @@ -1649,7 +1696,8 @@ static void _mieq_test_generate_events(uint32_t start, uint32_t count) { #define mieq_test_generate_events(c) { _mieq_test_generate_events(next, c); next += c; } static void -mieq_test(void) { +mieq_test(void) +{ uint32_t next = 1; mieq_test_event_last_processed = 0; @@ -1696,7 +1744,8 @@ process_input_proc(InternalEvent *ev, DeviceIntPtr device) } static void -dix_enqueue_events(void) { +dix_enqueue_events(void) +{ #define NEVENTS 5 DeviceIntRec dev; InternalEvent ev[NEVENTS]; @@ -1723,8 +1772,7 @@ dix_enqueue_events(void) { /* to reset process_input_proc */ ev[0].any.header = 0xac; - for (i = 0; i < NEVENTS; i++) - { + for (i = 0; i < NEVENTS; i++) { ev[i].any.length = sizeof(*ev); ev[i].any.type = i; EnqueueEvent(&ev[i], &dev); @@ -1740,7 +1788,6 @@ dix_enqueue_events(void) { PlayReleasedEvents(); assert(!xorg_list_is_empty(&syncEvents.pending)); - dev.deviceGrab.sync.frozen = 0; PlayReleasedEvents(); assert(xorg_list_is_empty(&syncEvents.pending)); @@ -1748,8 +1795,8 @@ dix_enqueue_events(void) { inputInfo.devices = NULL; } - -int main(int argc, char** argv) +int +main(int argc, char **argv) { dix_enqueue_events(); dix_double_fp_conversion(); diff --git a/test/list.c b/test/list.c index 14bc74a08..82d232706 100644 --- a/test/list.c +++ b/test/list.c @@ -66,7 +66,7 @@ test_xorg_list_init(void) static void test_xorg_list_add(void) { - struct parent parent = {0}; + struct parent parent = { 0 }; struct child child[3]; struct child *c; @@ -76,22 +76,25 @@ test_xorg_list_add(void) assert(!xorg_list_is_empty(&parent.children)); c = xorg_list_first_entry(&parent.children, struct child, node); + assert(memcmp(c, &child[0], sizeof(struct child)) == 0); /* note: xorg_list_add prepends */ xorg_list_add(&child[1].node, &parent.children); c = xorg_list_first_entry(&parent.children, struct child, node); + assert(memcmp(c, &child[1], sizeof(struct child)) == 0); xorg_list_add(&child[2].node, &parent.children); c = xorg_list_first_entry(&parent.children, struct child, node); + assert(memcmp(c, &child[2], sizeof(struct child)) == 0); }; static void test_xorg_list_append(void) { - struct parent parent = {0}; + struct parent parent = { 0 }; struct child child[3]; struct child *c; int i; @@ -102,20 +105,26 @@ test_xorg_list_append(void) assert(!xorg_list_is_empty(&parent.children)); c = xorg_list_first_entry(&parent.children, struct child, node); + assert(memcmp(c, &child[0], sizeof(struct child)) == 0); c = xorg_list_last_entry(&parent.children, struct child, node); + assert(memcmp(c, &child[0], sizeof(struct child)) == 0); xorg_list_append(&child[1].node, &parent.children); c = xorg_list_first_entry(&parent.children, struct child, node); + assert(memcmp(c, &child[0], sizeof(struct child)) == 0); c = xorg_list_last_entry(&parent.children, struct child, node); + assert(memcmp(c, &child[1], sizeof(struct child)) == 0); xorg_list_append(&child[2].node, &parent.children); c = xorg_list_first_entry(&parent.children, struct child, node); + assert(memcmp(c, &child[0], sizeof(struct child)) == 0); c = xorg_list_last_entry(&parent.children, struct child, node); + assert(memcmp(c, &child[2], sizeof(struct child)) == 0); i = 0; @@ -127,7 +136,7 @@ test_xorg_list_append(void) static void test_xorg_list_del(void) { - struct parent parent = {0}; + struct parent parent = { 0 }; struct child child[3]; struct child *c; @@ -147,6 +156,7 @@ test_xorg_list_del(void) xorg_list_add(&child[1].node, &parent.children); c = xorg_list_first_entry(&parent.children, struct child, node); + assert(memcmp(c, &child[1], sizeof(struct child)) == 0); /* delete first node */ @@ -154,12 +164,14 @@ test_xorg_list_del(void) assert(!xorg_list_is_empty(&parent.children)); assert(xorg_list_is_empty(&child[1].node)); c = xorg_list_first_entry(&parent.children, struct child, node); + assert(memcmp(c, &child[0], sizeof(struct child)) == 0); /* delete last node */ xorg_list_add(&child[1].node, &parent.children); xorg_list_del(&child[0].node); c = xorg_list_first_entry(&parent.children, struct child, node); + assert(memcmp(c, &child[1], sizeof(struct child)) == 0); /* delete list head */ @@ -173,7 +185,7 @@ test_xorg_list_del(void) static void test_xorg_list_for_each(void) { - struct parent parent = {0}; + struct parent parent = { 0 }; struct child child[3]; struct child *c; int i = 0; @@ -194,7 +206,7 @@ test_xorg_list_for_each(void) assert(xorg_list_is_empty(&parent.children)); xorg_list_for_each_entry(c, &parent.children, node) { - assert(0); /* we must not get here */ + assert(0); /* we must not get here */ } } @@ -226,29 +238,27 @@ test_nt_list_append(void) struct foo *foo = calloc(10, sizeof(struct foo)); struct foo *item; - for (item = foo, i = 1; i <= 10; i++, item++) - { - item->a = i; - item->b = i * 2; - nt_list_init(item, next); + for (item = foo, i = 1; i <= 10; i++, item++) { + item->a = i; + item->b = i * 2; + nt_list_init(item, next); - if (item != foo) - nt_list_append(item, foo, struct foo, next); + if (item != foo) + nt_list_append(item, foo, struct foo, next); } /* Test using nt_list_next */ - for (item = foo, i = 1; i <= 10; i++, item = nt_list_next(item, next)) - { - assert(item->a = i); - assert(item->b = i * 2); + for (item = foo, i = 1; i <= 10; i++, item = nt_list_next(item, next)) { + assert(item->a = i); + assert(item->b = i * 2); } /* Test using nt_list_for_each_entry */ i = 1; nt_list_for_each_entry(item, foo, next) { - assert(item->a = i); - assert(item->b = i * 2); - i++; + assert(item->a = i); + assert(item->b = i * 2); + i++; } assert(i == 11); } @@ -264,27 +274,25 @@ test_nt_list_insert(void) foo->b = 20; nt_list_init(foo, next); - for (item = &foo[1], i = 9; i > 0; i--, item++) - { - item->a = i; - item->b = i * 2; - nt_list_init(item, next); - nt_list_insert(item, foo, struct foo, next); + for (item = &foo[1], i = 9; i > 0; i--, item++) { + item->a = i; + item->b = i * 2; + nt_list_init(item, next); + nt_list_insert(item, foo, struct foo, next); } /* Test using nt_list_next */ - for (item = foo, i = 10; i > 0; i--, item = nt_list_next(item, next)) - { - assert(item->a = i); - assert(item->b = i * 2); + for (item = foo, i = 10; i > 0; i--, item = nt_list_next(item, next)) { + assert(item->a = i); + assert(item->b = i * 2); } /* Test using nt_list_for_each_entry */ i = 1; nt_list_for_each_entry(item, foo, next) { - assert(item->a = i); - assert(item->b = i * 2); - i++; + assert(item->a = i); + assert(item->b = i * 2); + i++; } assert(i == 11); } @@ -300,55 +308,58 @@ test_nt_list_delete(void) nt_list_init(empty_list, next); nt_list_del(empty_list, empty_list, struct foo, next); + assert(!empty_list); - for (item = foo, i = 1; i <= 10; i++, item++) - { - item->a = i; - item->b = i * 2; - nt_list_init(item, next); + for (item = foo, i = 1; i <= 10; i++, item++) { + item->a = i; + item->b = i * 2; + nt_list_init(item, next); - if (item != foo) - nt_list_append(item, foo, struct foo, next); + if (item != foo) + nt_list_append(item, foo, struct foo, next); } i = 0; nt_list_for_each_entry(item, foo, next) { - i++; + i++; } assert(i == 10); /* delete last item */ nt_list_del(&foo[9], foo, struct foo, next); + i = 0; nt_list_for_each_entry(item, foo, next) { - assert(item->a != 10); /* element 10 is gone now */ - i++; + assert(item->a != 10); /* element 10 is gone now */ + i++; } - assert(i == 9); /* 9 elements left */ + assert(i == 9); /* 9 elements left */ /* delete second item */ nt_list_del(foo->next, foo, struct foo, next); + assert(foo->next->a == 3); i = 0; nt_list_for_each_entry(item, foo, next) { - assert(item->a != 10); /* element 10 is gone now */ - assert(item->a != 2); /* element 2 is gone now */ - i++; + assert(item->a != 10); /* element 10 is gone now */ + assert(item->a != 2); /* element 2 is gone now */ + i++; } - assert(i == 8); /* 9 elements left */ + assert(i == 8); /* 9 elements left */ item = foo; /* delete first item */ nt_list_del(foo, foo, struct foo, next); + assert(item != foo); assert(item->next == NULL); assert(foo->a == 3); assert(foo->next->a == 4); nt_list_for_each_entry_safe(item, tmp, foo, next) { - nt_list_del(item, foo, struct foo, next); + nt_list_del(item, foo, struct foo, next); } assert(!foo); @@ -357,7 +368,8 @@ test_nt_list_delete(void) free(list); } -int main(int argc, char** argv) +int +main(int argc, char **argv) { test_xorg_list_init(); test_xorg_list_add(); diff --git a/test/misc.c b/test/misc.c index 1f6cb9a94..dd792e692 100644 --- a/test/misc.c +++ b/test/misc.c @@ -31,7 +31,8 @@ ScreenInfo screenInfo; -static void dix_version_compare(void) +static void +dix_version_compare(void) { int rc; @@ -57,7 +58,8 @@ static void dix_version_compare(void) assert(rc < 0); } -static void dix_update_desktop_dimensions(void) +static void +dix_update_desktop_dimensions(void) { int i; int x, y, w, h; @@ -129,7 +131,6 @@ static void dix_update_desktop_dimensions(void) set_screen(3, 0, 3 * h, w, h); assert_dimensions(x, y, w, 4 * h); - /* x overlap */ screenInfo.numScreens = 2; set_screen(0, 0, 0, w2, h2); @@ -154,7 +155,8 @@ static void dix_update_desktop_dimensions(void) assert_dimensions(-w2, -h2, w2, h2); } -int main(int argc, char** argv) +int +main(int argc, char **argv) { dix_version_compare(); dix_update_desktop_dimensions(); diff --git a/test/string.c b/test/string.c index e3a5adb6d..93867e04a 100644 --- a/test/string.c +++ b/test/string.c @@ -37,20 +37,20 @@ #include <string.h> #undef strndup #define strndup my_strndup -char * -strndup(const char *str, size_t n); +char *strndup(const char *str, size_t n); #include "../os/strndup.c" -static void strndup_checks(void) +static void +strndup_checks(void) { - const char *sample="0123456789abcdef"; + const char *sample = "0123456789abcdef"; char *allofit; char *firsthalf = strndup(sample, 8); char *secondhalf = strndup(sample + 8, 8); - assert(strcmp(firsthalf, "01234567") == 0); + assert(strcmp(firsthalf, "01234567") == 0); assert(strcmp(secondhalf, "89abcdef") == 0); free(firsthalf); @@ -61,7 +61,8 @@ static void strndup_checks(void) free(allofit); } -int main(int argc, char** argv) +int +main(int argc, char **argv) { strndup_checks(); diff --git a/test/touch.c b/test/touch.c index 88955cbc1..2ec535b43 100644 --- a/test/touch.c +++ b/test/touch.c @@ -30,7 +30,8 @@ #include "assert.h" #include "scrnintstr.h" -static void touch_grow_queue(void) +static void +touch_grow_queue(void) { DeviceIntRec dev; ValuatorClassRec val; @@ -60,12 +61,13 @@ static void touch_grow_queue(void) assert(TouchBeginDDXTouch(&dev, 1234) == NULL); ProcessWorkQueue(); - new_size = size + size/2 + 1; + new_size = size + size / 2 + 1; assert(dev.last.num_touches == new_size); /* make sure we haven't touched those */ for (i = 0; i < size; i++) { DDXTouchPointInfoPtr t = &dev.last.touches[i]; + assert(t->active == TRUE); assert(t->ddx_id == i); assert(t->client_id == i * 2); @@ -74,13 +76,15 @@ static void touch_grow_queue(void) /* make sure those are zero-initialized */ for (i = size; i < new_size; i++) { DDXTouchPointInfoPtr t = &dev.last.touches[i]; + assert(t->active == FALSE); assert(t->client_id == 0); assert(t->ddx_id == 0); } } -static void touch_find_ddxid(void) +static void +touch_find_ddxid(void) { DeviceIntRec dev; DDXTouchPointInfoPtr ti; @@ -99,12 +103,10 @@ static void touch_find_ddxid(void) inputInfo.devices = &dev; assert(dev.last.touches); - dev.last.touches[0].active = TRUE; dev.last.touches[0].ddx_id = 10; dev.last.touches[0].client_id = 20; - /* existing */ ti = TouchFindByDDXID(&dev, 10, FALSE); assert(ti == &dev.last.touches[0]); @@ -118,7 +120,7 @@ static void touch_find_ddxid(void) ti = TouchFindByDDXID(&dev, 10, FALSE); assert(ti == NULL); - /* create on number 2*/ + /* create on number 2 */ dev.last.touches[0].active = TRUE; ti = TouchFindByDDXID(&dev, 20, TRUE); @@ -148,7 +150,8 @@ static void touch_find_ddxid(void) assert(ti == &dev.last.touches[size]); } -static void touch_begin_ddxtouch(void) +static void +touch_begin_ddxtouch(void) { DeviceIntRec dev; DDXTouchPointInfoPtr ti; @@ -191,7 +194,8 @@ static void touch_begin_ddxtouch(void) last_client_id = ti->client_id; } -static void touch_begin_touch(void) +static void +touch_begin_touch(void) { DeviceIntRec dev; TouchClassRec touch; @@ -231,10 +235,11 @@ static void touch_begin_touch(void) assert(touch.num_touches == 1); } -static void touch_init(void) +static void +touch_init(void) { DeviceIntRec dev; - Atom labels[2] = {0}; + Atom labels[2] = { 0 }; int rc; SpriteInfoRec sprite; ScreenRec screen; @@ -256,9 +261,8 @@ static void touch_init(void) assert(dev.touch); } - - -int main(int argc, char** argv) +int +main(int argc, char **argv) { touch_grow_queue(); touch_find_ddxid(); diff --git a/test/xfree86.c b/test/xfree86.c index 448aa915e..f9892e68e 100644 --- a/test/xfree86.c +++ b/test/xfree86.c @@ -27,7 +27,6 @@ #include <assert.h> - #include "xf86.h" #include "xf86Parser.h" @@ -36,11 +35,8 @@ xfree86_option_list_duplicate(void) { XF86OptionPtr options; XF86OptionPtr duplicate; - const char *o1 = "foo", - *o2 = "bar", - *v1 = "one", - *v2 = "two"; - const char *o_null= "NULL"; + const char *o1 = "foo", *o2 = "bar", *v1 = "one", *v2 = "two"; + const char *o_null = "NULL"; char *val1, *val2; XF86OptionPtr a, b; @@ -78,10 +74,10 @@ static void xfree86_add_comment(void) { char *current = NULL, *comment; - char compare[1024] = {0}; + char compare[1024] = { 0 }; comment = "# foo"; - current = xf86addComment(current, comment); + current = xf86addComment(current, comment); strcpy(compare, comment); strcat(compare, "\n"); @@ -90,7 +86,7 @@ xfree86_add_comment(void) /* this used to overflow */ strcpy(current, "\n"); comment = "foobar\n"; - current = xf86addComment(current, comment); + current = xf86addComment(current, comment); strcpy(compare, "\n#"); strcat(compare, comment); assert(!strcmp(current, compare)); @@ -98,7 +94,8 @@ xfree86_add_comment(void) free(current); } -int main(int argc, char** argv) +int +main(int argc, char **argv) { xfree86_option_list_duplicate(); xfree86_add_comment(); diff --git a/test/xi2/protocol-common.c b/test/xi2/protocol-common.c index 27edfe516..32c056797 100644 --- a/test/xi2/protocol-common.c +++ b/test/xi2/protocol-common.c @@ -26,9 +26,9 @@ #endif #include <stdint.h> -#include "extinit.h" /* for XInputExtensionInit */ +#include "extinit.h" /* for XInputExtensionInit */ #include "exglobals.h" -#include "xkbsrv.h" /* for XkbInitPrivates */ +#include "xkbsrv.h" /* for XkbInitPrivates */ #include "xserver-properties.h" #include <X11/extensions/XI2.h> @@ -44,9 +44,11 @@ void *userdata; extern int CorePointerProc(DeviceIntPtr pDev, int what); extern int CoreKeyboardProc(DeviceIntPtr pDev, int what); -static void fake_init_sprite(DeviceIntPtr dev) +static void +fake_init_sprite(DeviceIntPtr dev) { SpritePtr sprite; + sprite = dev->spriteInfo->sprite; sprite->spriteTraceSize = 10; @@ -73,32 +75,32 @@ TestPointerProc(DeviceIntPtr pDev, int what) #define NAXES 4 BYTE map[NBUTTONS + 1]; int i = 0; - Atom btn_labels[NBUTTONS] = {0}; - Atom axes_labels[NAXES] = {0}; + Atom btn_labels[NBUTTONS] = { 0 }; + Atom axes_labels[NAXES] = { 0 }; switch (what) { case DEVICE_INIT: for (i = 1; i <= NBUTTONS; i++) map[i] = i; - btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); - btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); - btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); - btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP); - btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN); - btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT); - btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT); - /* don't know about the rest */ - - axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); - axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); - axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_VSCROLL); - axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HSCROLL); - - if (!InitPointerDeviceStruct((DevicePtr)pDev, map, NBUTTONS, btn_labels, - (PtrCtrlProcPtr)NoopDDA, - GetMotionHistorySize(), NAXES, axes_labels)) - { + btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); + btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); + btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); + btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP); + btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN); + btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT); + btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT); + /* don't know about the rest */ + + axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); + axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); + axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_VSCROLL); + axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HSCROLL); + + if (!InitPointerDeviceStruct + ((DevicePtr) pDev, map, NBUTTONS, btn_labels, + (PtrCtrlProcPtr) NoopDDA, GetMotionHistorySize(), NAXES, + axes_labels)) { ErrorF("Could not initialize device '%s'. Out of memory.\n", pDev->name); return BadAlloc; @@ -110,7 +112,8 @@ TestPointerProc(DeviceIntPtr pDev, int what) /* protocol-xiquerydevice.c relies on these increment */ SetScrollValuator(pDev, 2, SCROLL_TYPE_VERTICAL, 2.4, SCROLL_FLAG_NONE); - SetScrollValuator(pDev, 3, SCROLL_TYPE_HORIZONTAL, 3.5, SCROLL_FLAG_PREFERRED); + SetScrollValuator(pDev, 3, SCROLL_TYPE_HORIZONTAL, 3.5, + SCROLL_FLAG_PREFERRED); break; case DEVICE_CLOSE: @@ -125,11 +128,13 @@ TestPointerProc(DeviceIntPtr pDev, int what) #undef NBUTTONS #undef NAXES } + /** * Create and init 2 master devices (VCP + VCK) and two slave devices, one * default mouse, one default keyboard. */ -struct devices init_devices(void) +struct devices +init_devices(void) { ClientRec client; struct devices devices; @@ -139,6 +144,7 @@ struct devices init_devices(void) AllocDevicePair(&client, "Virtual core", &devices.vcp, &devices.vck, CorePointerProc, CoreKeyboardProc, TRUE); inputInfo.pointer = devices.vcp; + inputInfo.keyboard = devices.vck; ActivateDevice(devices.vcp, FALSE); ActivateDevice(devices.vck, FALSE); @@ -161,9 +167,9 @@ struct devices init_devices(void) return devices; } - /* Create minimal client, with the given buffer and len as request buffer */ -ClientRec init_client(int len, void *data) +ClientRec +init_client(int len, void *data) { ClientRec client = { 0 }; @@ -181,13 +187,13 @@ ClientRec init_client(int len, void *data) return client; } -void init_window(WindowPtr window, WindowPtr parent, int id) +void +init_window(WindowPtr window, WindowPtr parent, int id) { memset(window, 0, sizeof(*window)); window->drawable.id = id; - if (parent) - { + if (parent) { window->drawable.x = 30; window->drawable.y = 50; window->drawable.width = 100; @@ -202,9 +208,20 @@ extern DevPrivateKeyRec miPointerScreenKeyRec; extern DevPrivateKeyRec miPointerPrivKeyRec; /* Needed for the screen setup, otherwise we crash during sprite initialization */ -static Bool device_cursor_init(DeviceIntPtr dev, ScreenPtr screen) { return TRUE; } -static Bool set_cursor_pos(DeviceIntPtr dev, ScreenPtr screen, int x, int y, Bool event) { return TRUE; } -void init_simple(void) +static Bool +device_cursor_init(DeviceIntPtr dev, ScreenPtr screen) +{ + return TRUE; +} + +static Bool +set_cursor_pos(DeviceIntPtr dev, ScreenPtr screen, int x, int y, Bool event) +{ + return TRUE; +} + +void +init_simple(void) { screenInfo.numScreens = 1; screenInfo.screens[0] = &screen; @@ -219,7 +236,8 @@ void init_simple(void) dixResetPrivates(); InitAtoms(); XkbInitPrivates(); - dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec)); + dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT, + sizeof(XIClientRec)); dixRegisterPrivateKey(&miPointerScreenKeyRec, PRIVATE_SCREEN, 0); dixRegisterPrivateKey(&miPointerPrivKeyRec, PRIVATE_DEVICE, 0); XInputExtensionInit(); @@ -230,10 +248,10 @@ void init_simple(void) devices = init_devices(); } -void __wrap_WriteToClient(ClientPtr client, int len, void *data) +void +__wrap_WriteToClient(ClientPtr client, int len, void *data) { assert(reply_handler != NULL); - (*reply_handler)(client, len, data, userdata); + (*reply_handler) (client, len, data, userdata); } - diff --git a/test/xi2/protocol-common.h b/test/xi2/protocol-common.h index b55f57c05..04a1e8990 100644 --- a/test/xi2/protocol-common.h +++ b/test/xi2/protocol-common.h @@ -53,7 +53,6 @@ extern int BadDevice; (req)->length = (sz_x##type##Req >> 2); \ } - /* Various defines used in the tests. Some tests may use different values * than these defaults */ /* default client index */ @@ -72,10 +71,8 @@ extern int BadDevice; #define SPRITE_X 100 #define SPRITE_Y 200 - /* Various structs used throughout the tests */ - /* The default devices struct, contains one pointer + keyboard and the * matching master devices. Initialize with init_devices() if needed. */ struct devices { @@ -97,20 +94,23 @@ extern struct devices devices; * test-specific userdata, passed into the reply handler. */ extern void *userdata; + /** * The reply handler called from WriteToClient. Set this handler if you need * to check the reply values. */ -void (*reply_handler)(ClientPtr client, int len, char *data, void *userdata); +void (*reply_handler) (ClientPtr client, int len, char *data, void *userdata); /** * The default screen used for the windows. Initialized by init_simple(). */ extern ScreenRec screen; + /** * Semi-initialized root window. initialized by init(). */ extern WindowRec root; + /** * Semi-initialized top-level window. initialized by init(). */ @@ -122,16 +122,19 @@ extern WindowRec window; * Usually not needed if you call ::init_simple. */ struct devices init_devices(void); + /** * Init a mostly zeroed out client with default values for index and mask. */ ClientRec init_client(int request_len, void *request_data); + /** * Init a mostly zeroed out window with the given window ID. * Usually not needed if you call ::init_simple which sets up root and * window. */ void init_window(WindowPtr window, WindowPtr parent, int id); + /** * Create a very simple setup that provides the minimum values for most * tests, including a screen, the root and client window and the default @@ -141,13 +144,14 @@ void init_simple(void); /* Declarations for various overrides in the test files. */ void __wrap_WriteToClient(ClientPtr client, int len, void *data); -int __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len, unsigned char* mask); -int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access); -int __real_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access); +int __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len, + unsigned char *mask); +int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, + Mask access); +int __real_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, + Mask access); Bool __wrap_AddResource(XID id, RESTYPE type, pointer value); int __wrap_dixLookupClient(ClientPtr *c, XID id, ClientPtr client, Mask access); int __real_dixLookupClient(ClientPtr *c, XID id, ClientPtr client, Mask access); - -#endif /* PROTOCOL_COMMON_H */ - +#endif /* PROTOCOL_COMMON_H */ diff --git a/test/xi2/protocol-eventconvert.c b/test/xi2/protocol-eventconvert.c index bf1493c05..1188e8b25 100644 --- a/test/xi2/protocol-eventconvert.c +++ b/test/xi2/protocol-eventconvert.c @@ -33,8 +33,8 @@ #include "inpututils.h" #include <X11/extensions/XI2proto.h> -static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, - BOOL swap) +static void +test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent * out, BOOL swap) { int i; unsigned char *ptr; @@ -44,8 +44,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, int len; uint32_t flagmask = 0; - if (swap) - { + if (swap) { swaps(&out->sequenceNumber); swapl(&out->length); swaps(&out->evtype); @@ -56,14 +55,14 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, swapl(&out->flags); } - assert(out->type == GenericEvent); - assert(out->extension == 0); /* IReqCode defaults to 0 */ + assert(out->extension == 0); /* IReqCode defaults to 0 */ assert(out->evtype == GetXI2Type(in->type)); assert(out->time == in->time); assert(out->detail == in->detail.button); assert(out->deviceid == in->deviceid); - assert(out->valuators_len >= bytes_to_int32(bits_to_bytes(sizeof(in->valuators.mask)))); + assert(out->valuators_len >= + bytes_to_int32(bits_to_bytes(sizeof(in->valuators.mask)))); switch (in->type) { case ET_RawMotion: @@ -76,14 +75,13 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, } assert((out->flags & ~flagmask) == 0); - ptr = (unsigned char*)&out[1]; + ptr = (unsigned char *) &out[1]; bits_set = 0; - for (i = 0; out->valuators_len && i < sizeof(in->valuators.mask) * 8; i++) - { + for (i = 0; out->valuators_len && i < sizeof(in->valuators.mask) * 8; i++) { if (i >= MAX_VALUATORS) - assert (!XIMaskIsSet(in->valuators.mask, i)); - assert (XIMaskIsSet(in->valuators.mask, i) == XIMaskIsSet(ptr, i)); + assert(!XIMaskIsSet(in->valuators.mask, i)); + assert(XIMaskIsSet(in->valuators.mask, i) == XIMaskIsSet(ptr, i)); if (XIMaskIsSet(in->valuators.mask, i)) bits_set++; } @@ -96,21 +94,21 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, nvals = 0; - for (i = 0; out->valuators_len && i < MAX_VALUATORS; i++) - { - assert (XIMaskIsSet(in->valuators.mask, i) == XIMaskIsSet(ptr, i)); - if (XIMaskIsSet(in->valuators.mask, i)) - { + for (i = 0; out->valuators_len && i < MAX_VALUATORS; i++) { + assert(XIMaskIsSet(in->valuators.mask, i) == XIMaskIsSet(ptr, i)); + if (XIMaskIsSet(in->valuators.mask, i)) { FP3232 vi, vo; - value = (FP3232*)(((unsigned char*)&out[1]) + out->valuators_len * 4); + + value = + (FP3232 *) (((unsigned char *) &out[1]) + + out->valuators_len * 4); value += nvals; vi = double_to_fp3232(in->valuators.data[i]); vo.integral = value->integral; vo.frac = value->frac; - if (swap) - { + if (swap) { swapl(&vo.integral); swapl(&vo.frac); } @@ -124,8 +122,7 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, vo.integral = raw_value->integral; vo.frac = raw_value->frac; - if (swap) - { + if (swap) { swapl(&vo.integral); swapl(&vo.frac); } @@ -138,25 +135,27 @@ static void test_values_XIRawEvent(RawDeviceEvent *in, xXIRawEvent *out, } } -static void test_XIRawEvent(RawDeviceEvent *in) +static void +test_XIRawEvent(RawDeviceEvent *in) { xXIRawEvent *out, *swapped; int rc; - rc = EventToXI2((InternalEvent*)in, (xEvent**)&out); + rc = EventToXI2((InternalEvent *) in, (xEvent **) &out); assert(rc == Success); test_values_XIRawEvent(in, out, FALSE); swapped = calloc(1, sizeof(xEvent) + out->length * 4); - XI2EventSwap((xGenericEvent*)out, (xGenericEvent*)swapped); + XI2EventSwap((xGenericEvent *) out, (xGenericEvent *) swapped); test_values_XIRawEvent(in, swapped, TRUE); free(out); free(swapped); } -static void test_convert_XIFocusEvent(void) +static void +test_convert_XIFocusEvent(void) { xEvent *out; DeviceEvent in; @@ -164,29 +163,29 @@ static void test_convert_XIFocusEvent(void) in.header = ET_Internal; in.type = ET_Enter; - rc = EventToXI2((InternalEvent*)&in, &out); + rc = EventToXI2((InternalEvent *) &in, &out); assert(rc == Success); assert(out == NULL); in.header = ET_Internal; in.type = ET_FocusIn; - rc = EventToXI2((InternalEvent*)&in, &out); + rc = EventToXI2((InternalEvent *) &in, &out); assert(rc == Success); assert(out == NULL); in.header = ET_Internal; in.type = ET_FocusOut; - rc = EventToXI2((InternalEvent*)&in, &out); + rc = EventToXI2((InternalEvent *) &in, &out); assert(rc == BadImplementation); in.header = ET_Internal; in.type = ET_Leave; - rc = EventToXI2((InternalEvent*)&in, &out); + rc = EventToXI2((InternalEvent *) &in, &out); assert(rc == BadImplementation); } - -static void test_convert_XIRawEvent(void) +static void +test_convert_XIRawEvent(void) { RawDeviceEvent in; int i; @@ -244,15 +243,13 @@ static void test_convert_XIRawEvent(void) in.deviceid = ~0 & 0xFF; test_XIRawEvent(&in); - for (i = 0; i < MAX_VALUATORS; i++) - { + for (i = 0; i < MAX_VALUATORS; i++) { XISetMask(in.valuators.mask, i); test_XIRawEvent(&in); XIClearMask(in.valuators.mask, i); } - for (i = 0; i < MAX_VALUATORS; i++) - { + for (i = 0; i < MAX_VALUATORS; i++) { XISetMask(in.valuators.mask, i); in.valuators.data[i] = i + (i * 0.0010); @@ -261,15 +258,14 @@ static void test_convert_XIRawEvent(void) XIClearMask(in.valuators.mask, i); } - for (i = 0; i < MAX_VALUATORS; i++) - { + for (i = 0; i < MAX_VALUATORS; i++) { XISetMask(in.valuators.mask, i); test_XIRawEvent(&in); } } -static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out, - BOOL swap) +static void +test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent * out, BOOL swap) { int buttons, valuators; int i; @@ -301,7 +297,7 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out, swapl(&out->flags); } - assert(out->extension == 0); /* IReqCode defaults to 0 */ + assert(out->extension == 0); /* IReqCode defaults to 0 */ assert(out->evtype == GetXI2Type(in->type)); assert(out->time == in->time); assert(out->detail == in->detail.button); @@ -311,17 +307,17 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out, assert(out->sourceid == in->sourceid); switch (in->type) { - case ET_ButtonPress: - case ET_Motion: - case ET_ButtonRelease: - flagmask = XIPointerEmulated; - break; - case ET_KeyPress: - flagmask = XIKeyRepeat; - break; - default: - flagmask = 0; - break; + case ET_ButtonPress: + case ET_Motion: + case ET_ButtonRelease: + flagmask = XIPointerEmulated; + break; + case ET_KeyPress: + flagmask = XIKeyRepeat; + break; + default: + flagmask = 0; + break; } assert((out->flags & ~flagmask) == 0); @@ -339,27 +335,24 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out, assert(out->group.locked_group == in->group.locked); assert(out->group.effective_group == in->group.effective); - assert(out->event_x == 0); /* set in FixUpEventFromWindow */ - assert(out->event_y == 0); /* set in FixUpEventFromWindow */ + assert(out->event_x == 0); /* set in FixUpEventFromWindow */ + assert(out->event_y == 0); /* set in FixUpEventFromWindow */ assert(out->root_x == FP1616(in->root_x, in->root_x_frac)); assert(out->root_y == FP1616(in->root_y, in->root_y_frac)); buttons = 0; - for (i = 0; i < bits_to_bytes(sizeof(in->buttons)); i++) - { - if (XIMaskIsSet(in->buttons, i)) - { + for (i = 0; i < bits_to_bytes(sizeof(in->buttons)); i++) { + if (XIMaskIsSet(in->buttons, i)) { assert(out->buttons_len >= bytes_to_int32(bits_to_bytes(i))); buttons++; } } - ptr = (unsigned char*)&out[1]; + ptr = (unsigned char *) &out[1]; for (i = 0; i < sizeof(in->buttons) * 8; i++) assert(XIMaskIsSet(in->buttons, i) == XIMaskIsSet(ptr, i)); - valuators = 0; for (i = 0; i < MAX_VALUATORS; i++) if (XIMaskIsSet(in->valuators.mask, i)) @@ -368,10 +361,9 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out, assert(out->valuators_len >= bytes_to_int32(bits_to_bytes(valuators))); ptr += out->buttons_len * 4; - values = (FP3232*)(ptr + out->valuators_len * 4); + values = (FP3232 *) (ptr + out->valuators_len * 4); for (i = 0; i < sizeof(in->valuators.mask) * 8 || - i < (out->valuators_len * 4) * 8; i++) - { + i < (out->valuators_len * 4) * 8; i++) { if (i >= MAX_VALUATORS) assert(!XIMaskIsSet(in->valuators.mask, i) && !XIMaskIsSet(ptr, i)); else if (i > sizeof(in->valuators.mask) * 8) @@ -379,23 +371,19 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out, else if (i > out->valuators_len * 4 * 8) assert(!XIMaskIsSet(in->valuators.mask, i)); else { - assert(XIMaskIsSet(in->valuators.mask, i) == - XIMaskIsSet(ptr, i)); + assert(XIMaskIsSet(in->valuators.mask, i) == XIMaskIsSet(ptr, i)); - if (XIMaskIsSet(ptr, i)) - { + if (XIMaskIsSet(ptr, i)) { FP3232 vi, vo; vi = double_to_fp3232(in->valuators.data[i]); vo = *values; - if (swap) - { + if (swap) { swapl(&vo.integral); swapl(&vo.frac); } - assert(vi.integral == vo.integral); assert(vi.frac == vo.frac); values++; @@ -404,25 +392,27 @@ static void test_values_XIDeviceEvent(DeviceEvent *in, xXIDeviceEvent *out, } } -static void test_XIDeviceEvent(DeviceEvent *in) +static void +test_XIDeviceEvent(DeviceEvent *in) { xXIDeviceEvent *out, *swapped; int rc; - rc = EventToXI2((InternalEvent*)in, (xEvent**)&out); + rc = EventToXI2((InternalEvent *) in, (xEvent **) &out); assert(rc == Success); test_values_XIDeviceEvent(in, out, FALSE); swapped = calloc(1, sizeof(xEvent) + out->length * 4); - XI2EventSwap((xGenericEvent*)out, (xGenericEvent*)swapped); + XI2EventSwap((xGenericEvent *) out, (xGenericEvent *) swapped); test_values_XIDeviceEvent(in, swapped, TRUE); free(out); free(swapped); } -static void test_convert_XIDeviceEvent(void) +static void +test_convert_XIDeviceEvent(void) { DeviceEvent in; int i; @@ -432,23 +422,23 @@ static void test_convert_XIDeviceEvent(void) in.header = ET_Internal; in.type = ET_Motion; in.length = sizeof(DeviceEvent); - in.time = 0; - in.deviceid = 1; - in.sourceid = 2; - in.root = 3; - in.root_x = 4; - in.root_x_frac = 5; - in.root_y = 6; - in.root_y_frac = 7; - in.detail.button = 8; - in.mods.base = 9; - in.mods.latched = 10; - in.mods.locked = 11; - in.mods.effective = 11; - in.group.base = 12; - in.group.latched = 13; - in.group.locked = 14; - in.group.effective = 15; + in.time = 0; + in.deviceid = 1; + in.sourceid = 2; + in.root = 3; + in.root_x = 4; + in.root_x_frac = 5; + in.root_y = 6; + in.root_y_frac = 7; + in.detail.button = 8; + in.mods.base = 9; + in.mods.latched = 10; + in.mods.locked = 11; + in.mods.effective = 11; + in.group.base = 12; + in.group.latched = 13; + in.group.locked = 14; + in.group.effective = 15; test_XIDeviceEvent(&in); @@ -599,28 +589,24 @@ static void test_convert_XIDeviceEvent(void) in.mods.effective = ~0 & 0xFF; test_XIDeviceEvent(&in); - for (i = 0; i < sizeof(in.buttons) * 8; i++) - { + for (i = 0; i < sizeof(in.buttons) * 8; i++) { XISetMask(in.buttons, i); test_XIDeviceEvent(&in); XIClearMask(in.buttons, i); } - for (i = 0; i < sizeof(in.buttons) * 8; i++) - { + for (i = 0; i < sizeof(in.buttons) * 8; i++) { XISetMask(in.buttons, i); test_XIDeviceEvent(&in); } - for (i = 0; i < MAX_VALUATORS; i++) - { + for (i = 0; i < MAX_VALUATORS; i++) { XISetMask(in.valuators.mask, i); test_XIDeviceEvent(&in); XIClearMask(in.valuators.mask, i); } - for (i = 0; i < MAX_VALUATORS; i++) - { + for (i = 0; i < MAX_VALUATORS; i++) { XISetMask(in.valuators.mask, i); in.valuators.data[i] = i + (i * 0.0020); @@ -628,22 +614,20 @@ static void test_convert_XIDeviceEvent(void) XIClearMask(in.valuators.mask, i); } - for (i = 0; i < MAX_VALUATORS; i++) - { + for (i = 0; i < MAX_VALUATORS; i++) { XISetMask(in.valuators.mask, i); test_XIDeviceEvent(&in); } } -static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in, - xXIDeviceChangedEvent *out, - BOOL swap) +static void +test_values_XIDeviceChangedEvent(DeviceChangedEvent *in, + xXIDeviceChangedEvent * out, BOOL swap) { int i, j; unsigned char *ptr; - if (swap) - { + if (swap) { swaps(&out->sequenceNumber); swapl(&out->length); swaps(&out->evtype); @@ -654,114 +638,106 @@ static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in, } assert(out->type == GenericEvent); - assert(out->extension == 0); /* IReqCode defaults to 0 */ + assert(out->extension == 0); /* IReqCode defaults to 0 */ assert(out->evtype == GetXI2Type(in->type)); assert(out->time == in->time); assert(out->deviceid == in->deviceid); assert(out->sourceid == in->sourceid); - ptr = (unsigned char*)&out[1]; - for (i = 0; i < out->num_classes; i++) - { - xXIAnyInfo* any = (xXIAnyInfo*)ptr; + ptr = (unsigned char *) &out[1]; + for (i = 0; i < out->num_classes; i++) { + xXIAnyInfo *any = (xXIAnyInfo *) ptr; - if (swap) - { + if (swap) { swaps(&any->length); swaps(&any->type); swaps(&any->sourceid); } - switch(any->type) + switch (any->type) { + case XIButtonClass: { - case XIButtonClass: - { - xXIButtonInfo *b = (xXIButtonInfo*)any; - Atom *names; - - if (swap) - { - swaps(&b->num_buttons); - } - - assert(b->length == - bytes_to_int32(sizeof(xXIButtonInfo)) + - bytes_to_int32(bits_to_bytes(b->num_buttons)) + - b->num_buttons); - assert(b->num_buttons == in->buttons.num_buttons); - - names = (Atom*)((char*)&b[1] + - pad_to_int32(bits_to_bytes(b->num_buttons))); - for (j = 0; j < b->num_buttons; j++) - { - if (swap) - { - swapl(&names[j]); - } - assert(names[j] == in->buttons.names[j]); - } - } - break; - case XIKeyClass: - { - xXIKeyInfo *k = (xXIKeyInfo*)any; - uint32_t *kc; - - if (swap) - { - swaps(&k->num_keycodes); - } - - assert(k->length == - bytes_to_int32(sizeof(xXIKeyInfo)) + - k->num_keycodes); - assert(k->num_keycodes == in->keys.max_keycode - - in->keys.min_keycode + 1); - - kc = (uint32_t*)&k[1]; - for (j = 0; j < k->num_keycodes; j++) - { - if (swap) - { - swapl(&kc[j]); - } - assert(kc[j] >= in->keys.min_keycode); - assert(kc[j] <= in->keys.max_keycode); - } + xXIButtonInfo *b = (xXIButtonInfo *) any; + Atom *names; + + if (swap) { + swaps(&b->num_buttons); + } + + assert(b->length == + bytes_to_int32(sizeof(xXIButtonInfo)) + + bytes_to_int32(bits_to_bytes(b->num_buttons)) + + b->num_buttons); + assert(b->num_buttons == in->buttons.num_buttons); + + names = (Atom *) ((char *) &b[1] + + pad_to_int32(bits_to_bytes(b->num_buttons))); + for (j = 0; j < b->num_buttons; j++) { + if (swap) { + swapl(&names[j]); } - break; - case XIValuatorClass: - { - xXIValuatorInfo *v = (xXIValuatorInfo*)any; - assert(v->length == - bytes_to_int32(sizeof(xXIValuatorInfo))); + assert(names[j] == in->buttons.names[j]); + } + } + break; + case XIKeyClass: + { + xXIKeyInfo *k = (xXIKeyInfo *) any; + uint32_t *kc; + if (swap) { + swaps(&k->num_keycodes); + } + + assert(k->length == + bytes_to_int32(sizeof(xXIKeyInfo)) + k->num_keycodes); + assert(k->num_keycodes == in->keys.max_keycode - + in->keys.min_keycode + 1); + + kc = (uint32_t *) & k[1]; + for (j = 0; j < k->num_keycodes; j++) { + if (swap) { + swapl(&kc[j]); } + assert(kc[j] >= in->keys.min_keycode); + assert(kc[j] <= in->keys.max_keycode); + } + } + break; + case XIValuatorClass: + { + xXIValuatorInfo *v = (xXIValuatorInfo *) any; + + assert(v->length == bytes_to_int32(sizeof(xXIValuatorInfo))); + + } + break; + case XIScrollClass: + { + xXIScrollInfo *s = (xXIScrollInfo *) any; + + assert(s->length == bytes_to_int32(sizeof(xXIScrollInfo))); + + assert(s->sourceid == in->sourceid); + assert(s->number < in->num_valuators); + switch (s->type) { + case XIScrollTypeVertical: + assert(in->valuators[s->number].scroll.type == + SCROLL_TYPE_VERTICAL); break; - case XIScrollClass: - { - xXIScrollInfo *s = (xXIScrollInfo*)any; - assert(s->length == - bytes_to_int32(sizeof(xXIScrollInfo))); - - assert(s->sourceid == in->sourceid); - assert(s->number < in->num_valuators); - switch(s->type) - { - case XIScrollTypeVertical: - assert(in->valuators[s->number].scroll.type == SCROLL_TYPE_VERTICAL); - break; - case XIScrollTypeHorizontal: - assert(in->valuators[s->number].scroll.type == SCROLL_TYPE_HORIZONTAL); - break; - } - if (s->flags & XIScrollFlagPreferred) - assert(in->valuators[s->number].scroll.flags & SCROLL_FLAG_PREFERRED); - } - default: - printf("Invalid class type.\n\n"); - assert(1); + case XIScrollTypeHorizontal: + assert(in->valuators[s->number].scroll.type == + SCROLL_TYPE_HORIZONTAL); break; + } + if (s->flags & XIScrollFlagPreferred) + assert(in->valuators[s->number].scroll. + flags & SCROLL_FLAG_PREFERRED); + } + default: + printf("Invalid class type.\n\n"); + assert(1); + break; } ptr += any->length * 4; @@ -769,25 +745,27 @@ static void test_values_XIDeviceChangedEvent(DeviceChangedEvent *in, } -static void test_XIDeviceChangedEvent(DeviceChangedEvent *in) +static void +test_XIDeviceChangedEvent(DeviceChangedEvent *in) { xXIDeviceChangedEvent *out, *swapped; int rc; - rc = EventToXI2((InternalEvent*)in, (xEvent**)&out); + rc = EventToXI2((InternalEvent *) in, (xEvent **) &out); assert(rc == Success); test_values_XIDeviceChangedEvent(in, out, FALSE); swapped = calloc(1, sizeof(xEvent) + out->length * 4); - XI2EventSwap((xGenericEvent*)out, (xGenericEvent*)swapped); + XI2EventSwap((xGenericEvent *) out, (xGenericEvent *) swapped); test_values_XIDeviceChangedEvent(in, swapped, TRUE); free(out); free(swapped); } -static void test_convert_XIDeviceChangedEvent(void) +static void +test_convert_XIDeviceChangedEvent(void) { DeviceChangedEvent in; int i; @@ -796,12 +774,14 @@ static void test_convert_XIDeviceChangedEvent(void) in.header = ET_Internal; in.type = ET_DeviceChanged; in.length = sizeof(DeviceChangedEvent); - in.time = 0; - in.deviceid = 1; - in.sourceid = 2; - in.masterid = 3; - in.num_valuators = 4; - in.flags = DEVCHANGE_SLAVE_SWITCH | DEVCHANGE_POINTER_EVENT | DEVCHANGE_KEYBOARD_EVENT; + in.time = 0; + in.deviceid = 1; + in.sourceid = 2; + in.masterid = 3; + in.num_valuators = 4; + in.flags = + DEVCHANGE_SLAVE_SWITCH | DEVCHANGE_POINTER_EVENT | + DEVCHANGE_KEYBOARD_EVENT; for (i = 0; i < MAX_BUTTONS; i++) in.buttons.names[i] = i + 10; @@ -859,8 +839,8 @@ static void test_convert_XIDeviceChangedEvent(void) in.keys.max_keycode = 1 << 8; test_XIDeviceChangedEvent(&in); - in.keys.max_keycode = 0xFFFC; /* highest range, above that the length - field gives up */ + in.keys.max_keycode = 0xFFFC; /* highest range, above that the length + field gives up */ test_XIDeviceChangedEvent(&in); in.keys.min_keycode = 1 << 8; @@ -880,8 +860,7 @@ static void test_convert_XIDeviceChangedEvent(void) in.num_valuators = MAX_VALUATORS; test_XIDeviceChangedEvent(&in); - for (i = 0; i < MAX_VALUATORS; i++) - { + for (i = 0; i < MAX_VALUATORS; i++) { in.valuators[i].min = 0; in.valuators[i].max = 0; test_XIDeviceChangedEvent(&in); @@ -917,11 +896,9 @@ static void test_convert_XIDeviceChangedEvent(void) static void test_values_XITouchOwnershipEvent(TouchOwnershipEvent *in, - xXITouchOwnershipEvent *out, - BOOL swap) + xXITouchOwnershipEvent * out, BOOL swap) { - if (swap) - { + if (swap) { swaps(&out->sequenceNumber); swapl(&out->length); swaps(&out->evtype); @@ -936,7 +913,7 @@ test_values_XITouchOwnershipEvent(TouchOwnershipEvent *in, } assert(out->type == GenericEvent); - assert(out->extension == 0); /* IReqCode defaults to 0 */ + assert(out->extension == 0); /* IReqCode defaults to 0 */ assert(out->evtype == GetXI2Type(in->type)); assert(out->time == in->time); assert(out->deviceid == in->deviceid); @@ -951,13 +928,13 @@ test_XITouchOwnershipEvent(TouchOwnershipEvent *in) xXITouchOwnershipEvent *out, *swapped; int rc; - rc = EventToXI2((InternalEvent*)in, (xEvent**)&out); + rc = EventToXI2((InternalEvent *) in, (xEvent **) &out); assert(rc == Success); test_values_XITouchOwnershipEvent(in, out, FALSE); swapped = calloc(1, sizeof(xEvent) + out->length * 4); - XI2EventSwap((xGenericEvent*)out, (xGenericEvent*)swapped); + XI2EventSwap((xGenericEvent *) out, (xGenericEvent *) swapped); test_values_XITouchOwnershipEvent(in, swapped, TRUE); free(out); free(swapped); @@ -970,47 +947,45 @@ test_convert_XITouchOwnershipEvent(void) long i; memset(&in, 0, sizeof(in)); - in.header = ET_Internal; - in.type = ET_TouchOwnership; - in.length = sizeof(in); - in.time = 0; - in.deviceid = 1; - in.sourceid = 2; - in.touchid = 0; - in.reason = 0; - in.resource = 0; - in.flags = 0; + in.header = ET_Internal; + in.type = ET_TouchOwnership; + in.length = sizeof(in); + in.time = 0; + in.deviceid = 1; + in.sourceid = 2; + in.touchid = 0; + in.reason = 0; + in.resource = 0; + in.flags = 0; test_XITouchOwnershipEvent(&in); - in.flags = XIAcceptTouch; + in.flags = XIAcceptTouch; test_XITouchOwnershipEvent(&in); - in.flags = XIRejectTouch; + in.flags = XIRejectTouch; test_XITouchOwnershipEvent(&in); - for (i = 1; i <= 0xFFFF; i <<= 1) - { + for (i = 1; i <= 0xFFFF; i <<= 1) { in.deviceid = i; test_XITouchOwnershipEvent(&in); } - for (i = 1; i <= 0xFFFF; i <<= 1) - { + for (i = 1; i <= 0xFFFF; i <<= 1) { in.sourceid = i; test_XITouchOwnershipEvent(&in); } - for (i = 1; ; i <<= 1) - { + for (i = 1;; i <<= 1) { in.touchid = i; test_XITouchOwnershipEvent(&in); - if (i == ((long)1 << 31)) - break; + if (i == ((long) 1 << 31)) + break; } } -int main(int argc, char** argv) +int +main(int argc, char **argv) { test_convert_XIRawEvent(); test_convert_XIFocusEvent(); diff --git a/test/xi2/protocol-xigetclientpointer.c b/test/xi2/protocol-xigetclientpointer.c index aec58908d..28eb8d32a 100644 --- a/test/xi2/protocol-xigetclientpointer.c +++ b/test/xi2/protocol-xigetclientpointer.c @@ -49,13 +49,14 @@ struct { static ClientRec client_window; static ClientRec client_request; -int __wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access) +int +__wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, + Mask access) { if (rid == ROOT_WINDOW_ID) return BadWindow; - if (rid == CLIENT_WINDOW_ID) - { + if (rid == CLIENT_WINDOW_ID) { *pClient = &client_window; return Success; } @@ -63,13 +64,12 @@ int __wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask a return __real_dixLookupClient(pClient, rid, client, access); } - -static void reply_XIGetClientPointer(ClientPtr client, int len, char *data, void *userdata) +static void +reply_XIGetClientPointer(ClientPtr client, int len, char *data, void *userdata) { - xXIGetClientPointerReply *rep = (xXIGetClientPointerReply*)data; + xXIGetClientPointerReply *rep = (xXIGetClientPointerReply *) data; - if (client->swapped) - { + if (client->swapped) { swapl(&rep->length); swaps(&rep->sequenceNumber); swaps(&rep->deviceid); @@ -82,7 +82,9 @@ static void reply_XIGetClientPointer(ClientPtr client, int len, char *data, void assert(rep->deviceid == test_data.dev->id); } -static void request_XIGetClientPointer(ClientPtr client, xXIGetClientPointerReq* req, int error) +static void +request_XIGetClientPointer(ClientPtr client, xXIGetClientPointerReq * req, + int error) { int rc; @@ -105,7 +107,8 @@ static void request_XIGetClientPointer(ClientPtr client, xXIGetClientPointerReq* } -static void test_XIGetClientPointer(void) +static void +test_XIGetClientPointer(void) { xXIGetClientPointerReq request; @@ -113,7 +116,6 @@ static void test_XIGetClientPointer(void) request.win = CLIENT_WINDOW_ID; - reply_handler = reply_XIGetClientPointer; client_request = init_client(request.length, &request); @@ -149,7 +151,8 @@ static void test_XIGetClientPointer(void) request_XIGetClientPointer(&client_request, &request, Success); } -int main(int argc, char** argv) +int +main(int argc, char **argv) { init_simple(); client_window = init_client(0, NULL); diff --git a/test/xi2/protocol-xigetselectedevents.c b/test/xi2/protocol-xigetselectedevents.c index a78fb2655..fc33aa554 100644 --- a/test/xi2/protocol-xigetselectedevents.c +++ b/test/xi2/protocol-xigetselectedevents.c @@ -42,20 +42,21 @@ #include <X11/extensions/XI2proto.h> #include "inputstr.h" #include "windowstr.h" -#include "extinit.h" /* for XInputExtensionInit */ +#include "extinit.h" /* for XInputExtensionInit */ #include "scrnintstr.h" #include "xiselectev.h" #include "exevents.h" #include "protocol-common.h" -static void reply_XIGetSelectedEvents(ClientPtr client, int len, char *data, void *userdata); -static void reply_XIGetSelectedEvents_data(ClientPtr client, int len, char *data, void *userdata); - +static void reply_XIGetSelectedEvents(ClientPtr client, int len, char *data, + void *userdata); +static void reply_XIGetSelectedEvents_data(ClientPtr client, int len, + char *data, void *userdata); struct { int num_masks_expected; - unsigned char mask[MAXDEVICES][XI2LASTEVENT]; /* intentionally bigger */ + unsigned char mask[MAXDEVICES][XI2LASTEVENT]; /* intentionally bigger */ int mask_len; } test_data; @@ -64,14 +65,14 @@ struct { * fake client window. If the requested ID is neither of those wanted, * return whatever the real dixLookupWindow does. */ -int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access) +int +__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access) { - if (id == root.drawable.id) - { + if (id == root.drawable.id) { *win = &root; return Success; - } else if (id == window.drawable.id) - { + } + else if (id == window.drawable.id) { *win = &window; return Success; } @@ -80,17 +81,18 @@ int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access } /* AddResource is called from XISetSEventMask, we don't need this */ -Bool __wrap_AddResource(XID id, RESTYPE type, pointer value) +Bool +__wrap_AddResource(XID id, RESTYPE type, pointer value) { return TRUE; } -static void reply_XIGetSelectedEvents(ClientPtr client, int len, char *data, void *userdata) +static void +reply_XIGetSelectedEvents(ClientPtr client, int len, char *data, void *userdata) { - xXIGetSelectedEventsReply *rep = (xXIGetSelectedEventsReply*)data; + xXIGetSelectedEventsReply *rep = (xXIGetSelectedEventsReply *) data; - if (client->swapped) - { + if (client->swapped) { swapl(&rep->length); swaps(&rep->sequenceNumber); swaps(&rep->num_masks); @@ -103,39 +105,41 @@ static void reply_XIGetSelectedEvents(ClientPtr client, int len, char *data, voi reply_handler = reply_XIGetSelectedEvents_data; } -static void reply_XIGetSelectedEvents_data(ClientPtr client, int len, char *data, void *userdata) +static void +reply_XIGetSelectedEvents_data(ClientPtr client, int len, char *data, + void *userdata) { int i; xXIEventMask *mask; unsigned char *bitmask; - mask = (xXIEventMask*)data; - for (i = 0; i < test_data.num_masks_expected; i++) - { - if (client->swapped) - { + mask = (xXIEventMask *) data; + for (i = 0; i < test_data.num_masks_expected; i++) { + if (client->swapped) { swaps(&mask->deviceid); swaps(&mask->mask_len); } assert(mask->deviceid < 6); - assert(mask->mask_len <= (((XI2LASTEVENT + 8)/8) + 3)/4) ; + assert(mask->mask_len <= (((XI2LASTEVENT + 8) / 8) + 3) / 4); - bitmask = (unsigned char*)&mask[1]; + bitmask = (unsigned char *) &mask[1]; assert(memcmp(bitmask, - test_data.mask[mask->deviceid], - mask->mask_len * 4) == 0); + test_data.mask[mask->deviceid], mask->mask_len * 4) == 0); - mask = (xXIEventMask*)((char*)mask + mask->mask_len * 4 + sizeof(xXIEventMask)); + mask = + (xXIEventMask *) ((char *) mask + mask->mask_len * 4 + + sizeof(xXIEventMask)); } - } -static void request_XIGetSelectedEvents(xXIGetSelectedEventsReq* req, int error) +static void +request_XIGetSelectedEvents(xXIGetSelectedEventsReq * req, int error) { int rc; ClientRec client; + client = init_client(req->length, req); reply_handler = reply_XIGetSelectedEvents; @@ -151,7 +155,8 @@ static void request_XIGetSelectedEvents(xXIGetSelectedEventsReq* req, int error) assert(rc == error); } -static void test_XIGetSelectedEvents(void) +static void +test_XIGetSelectedEvents(void) { int i, j; xXIGetSelectedEventsReq request; @@ -174,42 +179,37 @@ static void test_XIGetSelectedEvents(void) request.win = CLIENT_WINDOW_ID; request_XIGetSelectedEvents(&request, Success); - memset(test_data.mask, 0, - sizeof(test_data.mask)); + memset(test_data.mask, 0, sizeof(test_data.mask)); printf("Testing for valid masks\n"); - memset(&dev, 0, sizeof(dev)); /* dev->id is enough for XISetEventMask */ + memset(&dev, 0, sizeof(dev)); /* dev->id is enough for XISetEventMask */ request.win = ROOT_WINDOW_ID; /* devices 6 - MAXDEVICES don't exist, they mustn't be included in the * reply even if a mask is set */ - for (j = 0; j < MAXDEVICES; j++) - { + for (j = 0; j < MAXDEVICES; j++) { test_data.num_masks_expected = min(j + 1, devices.num_devices + 2); dev.id = j; mask = test_data.mask[j]; /* bits one-by-one */ - for (i = 0; i < XI2LASTEVENT; i++) - { + for (i = 0; i < XI2LASTEVENT; i++) { SetBit(mask, i); - XISetEventMask(&dev, &root, &client, (i + 8)/8, mask); + XISetEventMask(&dev, &root, &client, (i + 8) / 8, mask); request_XIGetSelectedEvents(&request, Success); ClearBit(mask, i); } /* all valid mask bits */ - for (i = 0; i < XI2LASTEVENT; i++) - { + for (i = 0; i < XI2LASTEVENT; i++) { SetBit(mask, i); - XISetEventMask(&dev, &root, &client, (i + 8)/8, mask); + XISetEventMask(&dev, &root, &client, (i + 8) / 8, mask); request_XIGetSelectedEvents(&request, Success); } } printf("Testing removing all masks\n"); /* Unset all masks one-by-one */ - for (j = MAXDEVICES - 1; j >= 0; j--) - { + for (j = MAXDEVICES - 1; j >= 0; j--) { if (j < devices.num_devices + 2) test_data.num_masks_expected--; @@ -223,7 +223,8 @@ static void test_XIGetSelectedEvents(void) } } -int main(int argc, char** argv) +int +main(int argc, char **argv) { init_simple(); @@ -231,4 +232,3 @@ int main(int argc, char** argv) return 0; } - diff --git a/test/xi2/protocol-xipassivegrabdevice.c b/test/xi2/protocol-xipassivegrabdevice.c index b405556be..53c65bda6 100644 --- a/test/xi2/protocol-xipassivegrabdevice.c +++ b/test/xi2/protocol-xipassivegrabdevice.c @@ -41,26 +41,29 @@ #include "protocol-common.h" static ClientRec client_request; + #define N_MODS 7 -static uint32_t modifiers[N_MODS] = {1, 2, 3, 4, 5, 6, 7}; +static uint32_t modifiers[N_MODS] = { 1, 2, 3, 4, 5, 6, 7 }; struct test_data { int num_modifiers; } testdata; -int __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device, - int button, GrabParameters *param, enum InputLevel grabtype, +int __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev, + DeviceIntPtr modifier_device, int button, + GrabParameters *param, enum InputLevel grabtype, GrabMask *mask); -static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len, char *data, void *userdata); +static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len, + char *data, void *userdata); -int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access) +int +__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access) { - if (id == root.drawable.id) - { + if (id == root.drawable.id) { *win = &root; return Success; - } else if (id == window.drawable.id) - { + } + else if (id == window.drawable.id) { *win = &window; return Success; } @@ -68,9 +71,11 @@ int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access return __real_dixLookupWindow(win, id, client, access); } -int __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_device, - int button, GrabParameters *param, enum InputLevel grabtype, - GrabMask *mask) +int +__wrap_GrabButton(ClientPtr client, DeviceIntPtr dev, + DeviceIntPtr modifier_device, int button, + GrabParameters *param, enum InputLevel grabtype, + GrabMask *mask) { /* Fail every odd modifier */ if (param->modifiers % 2) @@ -79,12 +84,12 @@ int __wrap_GrabButton(ClientPtr client, DeviceIntPtr dev, DeviceIntPtr modifier_ return Success; } -static void reply_XIPassiveGrabDevice(ClientPtr client, int len, char *data, void *userdata) +static void +reply_XIPassiveGrabDevice(ClientPtr client, int len, char *data, void *userdata) { - xXIPassiveGrabDeviceReply *rep = (xXIPassiveGrabDeviceReply*)data; + xXIPassiveGrabDeviceReply *rep = (xXIPassiveGrabDeviceReply *) data; - if (client->swapped) - { + if (client->swapped) { swaps(&rep->sequenceNumber); swapl(&rep->length); swaps(&rep->num_modifiers); @@ -100,14 +105,15 @@ static void reply_XIPassiveGrabDevice(ClientPtr client, int len, char *data, voi reply_handler = reply_XIPassiveGrabDevice_data; } -static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len, char *data, void *userdata) +static void +reply_XIPassiveGrabDevice_data(ClientPtr client, int len, char *data, + void *userdata) { int i; - xXIGrabModifierInfo *mods = (xXIGrabModifierInfo*)data; + xXIGrabModifierInfo *mods = (xXIGrabModifierInfo *) data; - for (i = 0; i < testdata.num_modifiers; i++, mods++) - { + for (i = 0; i < testdata.num_modifiers; i++, mods++) { if (client->swapped) swapl(&mods->modifiers); @@ -115,7 +121,7 @@ static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len, char *data * above */ assert(mods->modifiers > 0); assert(mods->modifiers <= 7); - assert(mods->modifiers % 2 == 1); /* because we fail odd ones */ + assert(mods->modifiers % 2 == 1); /* because we fail odd ones */ assert(mods->status != Success); assert(mods->pad0 == 0); assert(mods->pad1 == 0); @@ -124,7 +130,9 @@ static void reply_XIPassiveGrabDevice_data(ClientPtr client, int len, char *data reply_handler = reply_XIPassiveGrabDevice; } -static void request_XIPassiveGrabDevice(ClientPtr client, xXIPassiveGrabDeviceReq* req, int error, int errval) +static void +request_XIPassiveGrabDevice(ClientPtr client, xXIPassiveGrabDeviceReq * req, + int error, int errval) { int rc; int modifiers; @@ -146,9 +154,9 @@ static void request_XIPassiveGrabDevice(ClientPtr client, xXIPassiveGrabDeviceRe swaps(&req->num_modifiers); swaps(&req->mask_len); - while(modifiers--) - { - CARD32 *mod = ((CARD32*)(req + 1)) + modifiers; + while (modifiers--) { + CARD32 *mod = ((CARD32 *) (req + 1)) + modifiers; + swapl(mod); } @@ -159,11 +167,12 @@ static void request_XIPassiveGrabDevice(ClientPtr client, xXIPassiveGrabDeviceRe assert(client_request.errorValue == errval); } -static unsigned char *data[4096]; /* the request buffer */ -static void test_XIPassiveGrabDevice(void) +static unsigned char *data[4096]; /* the request buffer */ +static void +test_XIPassiveGrabDevice(void) { int i; - xXIPassiveGrabDeviceReq *request = (xXIPassiveGrabDeviceReq*)data; + xXIPassiveGrabDeviceReq *request = (xXIPassiveGrabDeviceReq *) data; unsigned char *mask; request_init(request, XIPassiveGrabDevice); @@ -175,34 +184,38 @@ static void test_XIPassiveGrabDevice(void) printf("Testing invalid device\n"); request->deviceid = 12; - request_XIPassiveGrabDevice(&client_request, request, BadDevice, request->deviceid); + request_XIPassiveGrabDevice(&client_request, request, BadDevice, + request->deviceid); request->deviceid = XIAllMasterDevices; printf("Testing invalid grab types\n"); - for (i = XIGrabtypeTouchBegin + 1; i < 0xFF; i++) - { + for (i = XIGrabtypeTouchBegin + 1; i < 0xFF; i++) { request->grab_type = i; - request_XIPassiveGrabDevice(&client_request, request, BadValue, request->grab_type); + request_XIPassiveGrabDevice(&client_request, request, BadValue, + request->grab_type); } printf("Testing invalid grab type + detail combinations\n"); request->grab_type = XIGrabtypeEnter; request->detail = 1; - request_XIPassiveGrabDevice(&client_request, request, BadValue, request->detail); + request_XIPassiveGrabDevice(&client_request, request, BadValue, + request->detail); request->grab_type = XIGrabtypeFocusIn; - request_XIPassiveGrabDevice(&client_request, request, BadValue, request->detail); + request_XIPassiveGrabDevice(&client_request, request, BadValue, + request->detail); request->detail = 0; printf("Testing invalid masks\n"); - mask = (unsigned char*)&request[1]; + mask = (unsigned char *) &request[1]; request->mask_len = bytes_to_int32(XI2LASTEVENT + 1); request->length += request->mask_len; SetBit(mask, XI2LASTEVENT + 1); - request_XIPassiveGrabDevice(&client_request, request, BadValue, XI2LASTEVENT + 1); + request_XIPassiveGrabDevice(&client_request, request, BadValue, + XI2LASTEVENT + 1); ClearBit(mask, XI2LASTEVENT + 1); @@ -217,11 +230,13 @@ static void test_XIPassiveGrabDevice(void) /* some modifiers */ request->num_modifiers = N_MODS; request->length += N_MODS; - memcpy((uint32_t*)(request + 1) + request->mask_len, modifiers, sizeof(modifiers)); + memcpy((uint32_t *) (request + 1) + request->mask_len, modifiers, + sizeof(modifiers)); request_XIPassiveGrabDevice(&client_request, request, Success, 0); } -int main(int argc, char** argv) +int +main(int argc, char **argv) { init_simple(); diff --git a/test/xi2/protocol-xiquerydevice.c b/test/xi2/protocol-xiquerydevice.c index 569aea93a..5e59e8084 100644 --- a/test/xi2/protocol-xiquerydevice.c +++ b/test/xi2/protocol-xiquerydevice.c @@ -53,17 +53,19 @@ struct test_data { int num_devices_in_reply; }; -static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void *userdata); -static void reply_XIQueryDevice(ClientPtr client, int len, char* data, void *userdata); +static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, + void *userdata); +static void reply_XIQueryDevice(ClientPtr client, int len, char *data, + void *userdata); /* reply handling for the first bytes that constitute the reply */ -static void reply_XIQueryDevice(ClientPtr client, int len, char* data, void *userdata) +static void +reply_XIQueryDevice(ClientPtr client, int len, char *data, void *userdata) { - xXIQueryDeviceReply *rep = (xXIQueryDeviceReply*)data; - struct test_data *querydata = (struct test_data*)userdata; + xXIQueryDeviceReply *rep = (xXIQueryDeviceReply *) data; + struct test_data *querydata = (struct test_data *) userdata; - if (client->swapped) - { + if (client->swapped) { swapl(&rep->length); swaps(&rep->sequenceNumber); swaps(&rep->num_devices); @@ -83,19 +85,18 @@ static void reply_XIQueryDevice(ClientPtr client, int len, char* data, void *use } /* reply handling for the trailing bytes that constitute the device info */ -static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void *userdata) +static void +reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void *userdata) { int i, j; - struct test_data *querydata = (struct test_data*)userdata; + struct test_data *querydata = (struct test_data *) userdata; DeviceIntPtr dev; - xXIDeviceInfo *info = (xXIDeviceInfo*)data; + xXIDeviceInfo *info = (xXIDeviceInfo *) data; xXIAnyInfo *any; - for (i = 0; i < querydata->num_devices_in_reply; i++) - { - if (client->swapped) - { + for (i = 0; i < querydata->num_devices_in_reply; i++) { + if (client->swapped) { swaps(&info->deviceid); swaps(&info->attachment); swaps(&info->use); @@ -106,179 +107,173 @@ static void reply_XIQueryDevice_data(ClientPtr client, int len, char *data, void if (querydata->which_device > XIAllMasterDevices) assert(info->deviceid == querydata->which_device); - assert(info->deviceid >= 2); /* 0 and 1 is reserved */ - - - switch(info->deviceid) - { - case 2: /* VCP */ - dev = devices.vcp; - assert(info->use == XIMasterPointer); - assert(info->attachment == devices.vck->id); - assert(info->num_classes == 3); /* 2 axes + button */ - break; - case 3: /* VCK */ - dev = devices.vck; - assert(info->use == XIMasterKeyboard); - assert(info->attachment == devices.vcp->id); - assert(info->num_classes == 1); - break; - case 4: /* mouse */ - dev = devices.mouse; - assert(info->use == XISlavePointer); - assert(info->attachment == devices.vcp->id); - assert(info->num_classes == 7); /* 4 axes + button + 2 scroll*/ - break; - case 5: /* keyboard */ - dev = devices.kbd; - assert(info->use == XISlaveKeyboard); - assert(info->attachment == devices.vck->id); - assert(info->num_classes == 1); - break; - - default: - /* We shouldn't get here */ - assert(0); - break; + assert(info->deviceid >= 2); /* 0 and 1 is reserved */ + + switch (info->deviceid) { + case 2: /* VCP */ + dev = devices.vcp; + assert(info->use == XIMasterPointer); + assert(info->attachment == devices.vck->id); + assert(info->num_classes == 3); /* 2 axes + button */ + break; + case 3: /* VCK */ + dev = devices.vck; + assert(info->use == XIMasterKeyboard); + assert(info->attachment == devices.vcp->id); + assert(info->num_classes == 1); + break; + case 4: /* mouse */ + dev = devices.mouse; + assert(info->use == XISlavePointer); + assert(info->attachment == devices.vcp->id); + assert(info->num_classes == 7); /* 4 axes + button + 2 scroll */ + break; + case 5: /* keyboard */ + dev = devices.kbd; + assert(info->use == XISlaveKeyboard); + assert(info->attachment == devices.vck->id); + assert(info->num_classes == 1); + break; + + default: + /* We shouldn't get here */ + assert(0); + break; } assert(info->enabled == dev->enabled); assert(info->name_len == strlen(dev->name)); - assert(strncmp((char*)&info[1], dev->name, info->name_len) == 0); + assert(strncmp((char *) &info[1], dev->name, info->name_len) == 0); - any = (xXIAnyInfo*)((char*)&info[1] + ((info->name_len + 3)/4) * 4); - for (j = 0; j < info->num_classes; j++) - { - if (client->swapped) - { + any = + (xXIAnyInfo *) ((char *) &info[1] + ((info->name_len + 3) / 4) * 4); + for (j = 0; j < info->num_classes; j++) { + if (client->swapped) { swaps(&any->type); swaps(&any->length); swaps(&any->sourceid); } - switch(info->deviceid) + switch (info->deviceid) { + case 3: /* VCK and kbd have the same properties */ + case 5: + { + int k; + xXIKeyInfo *ki = (xXIKeyInfo *) any; + XkbDescPtr xkb = devices.vck->key->xkbInfo->desc; + uint32_t *kc; + + if (client->swapped) + swaps(&ki->num_keycodes); + + assert(any->type == XIKeyClass); + assert(ki->num_keycodes == + (xkb->max_key_code - xkb->min_key_code + 1)); + assert(any->length == (2 + ki->num_keycodes)); + + kc = (uint32_t *) & ki[1]; + for (k = 0; k < ki->num_keycodes; k++, kc++) { + if (client->swapped) + swapl(kc); + + assert(*kc >= xkb->min_key_code); + assert(*kc <= xkb->max_key_code); + } + break; + } + case 4: { - case 3: /* VCK and kbd have the same properties */ - case 5: - { - int k; - xXIKeyInfo *ki = (xXIKeyInfo*)any; - XkbDescPtr xkb = devices.vck->key->xkbInfo->desc; - uint32_t *kc; - - if (client->swapped) - swaps(&ki->num_keycodes); - - assert(any->type == XIKeyClass); - assert(ki->num_keycodes == (xkb->max_key_code - xkb->min_key_code + 1)); - assert(any->length == (2 + ki->num_keycodes)); - - kc = (uint32_t*)&ki[1]; - for (k = 0; k < ki->num_keycodes; k++, kc++) - { - if (client->swapped) - swapl(kc); - - assert(*kc >= xkb->min_key_code); - assert(*kc <= xkb->max_key_code); - } - break; + assert(any->type == XIButtonClass || + any->type == XIValuatorClass || + any->type == XIScrollClass); + + if (any->type == XIScrollClass) { + xXIScrollInfo *si = (xXIScrollInfo *) any; + + if (client->swapped) { + swaps(&si->number); + swaps(&si->scroll_type); + swapl(&si->increment.integral); + swapl(&si->increment.frac); } - case 4: - { - assert(any->type == XIButtonClass || - any->type == XIValuatorClass || - any->type == XIScrollClass); - - if (any->type == XIScrollClass) - { - xXIScrollInfo *si = (xXIScrollInfo*)any; - - if (client->swapped) - { - swaps(&si->number); - swaps(&si->scroll_type); - swapl(&si->increment.integral); - swapl(&si->increment.frac); - } - assert(si->length == 6); - assert(si->number == 2 || si->number == 3); - if (si->number == 2) { - assert(si->scroll_type == XIScrollTypeVertical); - assert(!si->flags); - } - if (si->number == 3) { - assert(si->scroll_type == XIScrollTypeHorizontal); - assert(si->flags & XIScrollFlagPreferred); - assert(!(si->flags & ~XIScrollFlagPreferred)); - } - - assert(si->increment.integral == si->number); - /* protocol-common.c sets up increments of 2.4 and 3.5 */ - assert(si->increment.frac > 0.3 * (1ULL << 32)); - assert(si->increment.frac < 0.6 * (1ULL << 32)); - } - + assert(si->length == 6); + assert(si->number == 2 || si->number == 3); + if (si->number == 2) { + assert(si->scroll_type == XIScrollTypeVertical); + assert(!si->flags); } - /* fall through */ - case 2: /* VCP and mouse have the same properties except for scroll */ - { - if (info->deviceid == 2 ) /* VCP */ - assert(any->type == XIButtonClass || - any->type == XIValuatorClass); - - if (any->type == XIButtonClass) - { - int len; - xXIButtonInfo *bi = (xXIButtonInfo*)any; - - if (client->swapped) - swaps(&bi->num_buttons); - - assert(bi->num_buttons == devices.vcp->button->numButtons); - - len = 2 + bi->num_buttons + bytes_to_int32(bits_to_bytes(bi->num_buttons)); - assert(bi->length == len); - } else if (any->type == XIValuatorClass) - { - xXIValuatorInfo *vi = (xXIValuatorInfo*)any; - - if (client->swapped) - { - swaps(&vi->number); - swapl(&vi->label); - swapl(&vi->min.integral); - swapl(&vi->min.frac); - swapl(&vi->max.integral); - swapl(&vi->max.frac); - swapl(&vi->resolution); - } - - assert(vi->length == 11); - assert(vi->number >= 0 && vi->number < 4); - if (info->deviceid == 2) /* VCP */ - assert(vi->number < 2); - - assert(vi->mode == XIModeRelative); - /* device was set up as relative, so standard - * values here. */ - assert(vi->min.integral == -1); - assert(vi->min.frac == 0); - assert(vi->max.integral == -1); - assert(vi->max.frac == 0); - assert(vi->resolution == 0); - } + if (si->number == 3) { + assert(si->scroll_type == XIScrollTypeHorizontal); + assert(si->flags & XIScrollFlagPreferred); + assert(!(si->flags & ~XIScrollFlagPreferred)); } - break; + + assert(si->increment.integral == si->number); + /* protocol-common.c sets up increments of 2.4 and 3.5 */ + assert(si->increment.frac > 0.3 * (1ULL << 32)); + assert(si->increment.frac < 0.6 * (1ULL << 32)); + } + } - any = (xXIAnyInfo*)(((char*)any) + any->length * 4); + /* fall through */ + case 2: /* VCP and mouse have the same properties except for scroll */ + { + if (info->deviceid == 2) /* VCP */ + assert(any->type == XIButtonClass || + any->type == XIValuatorClass); + + if (any->type == XIButtonClass) { + int len; + xXIButtonInfo *bi = (xXIButtonInfo *) any; + + if (client->swapped) + swaps(&bi->num_buttons); + + assert(bi->num_buttons == devices.vcp->button->numButtons); + + len = + 2 + bi->num_buttons + + bytes_to_int32(bits_to_bytes(bi->num_buttons)); + assert(bi->length == len); + } + else if (any->type == XIValuatorClass) { + xXIValuatorInfo *vi = (xXIValuatorInfo *) any; + + if (client->swapped) { + swaps(&vi->number); + swapl(&vi->label); + swapl(&vi->min.integral); + swapl(&vi->min.frac); + swapl(&vi->max.integral); + swapl(&vi->max.frac); + swapl(&vi->resolution); + } + + assert(vi->length == 11); + assert(vi->number >= 0 && vi->number < 4); + if (info->deviceid == 2) /* VCP */ + assert(vi->number < 2); + + assert(vi->mode == XIModeRelative); + /* device was set up as relative, so standard + * values here. */ + assert(vi->min.integral == -1); + assert(vi->min.frac == 0); + assert(vi->max.integral == -1); + assert(vi->max.frac == 0); + assert(vi->resolution == 0); + } + } + break; + } + any = (xXIAnyInfo *) (((char *) any) + any->length * 4); } - info = (xXIDeviceInfo*)any; + info = (xXIDeviceInfo *) any; } } -static void request_XIQueryDevice(struct test_data *querydata, - int deviceid, int error) +static void +request_XIQueryDevice(struct test_data *querydata, int deviceid, int error) { int rc; ClientRec client; @@ -309,7 +304,8 @@ static void request_XIQueryDevice(struct test_data *querydata, assert(client.errorValue == deviceid); } -static void test_XIQueryDevice(void) +static void +test_XIQueryDevice(void) { int i; xXIQueryDeviceReq request; @@ -332,12 +328,12 @@ static void test_XIQueryDevice(void) for (i = 6; i <= 0xFFFF; i++) request_XIQueryDevice(&data, i, BadDevice); - reply_handler = NULL; } -int main(int argc, char** argv) +int +main(int argc, char **argv) { init_simple(); @@ -345,4 +341,3 @@ int main(int argc, char** argv) return 0; } - diff --git a/test/xi2/protocol-xiquerypointer.c b/test/xi2/protocol-xiquerypointer.c index 65346ab5d..4756a6b2e 100644 --- a/test/xi2/protocol-xiquerypointer.c +++ b/test/xi2/protocol-xiquerypointer.c @@ -49,20 +49,19 @@ static struct { WindowPtr win; } test_data; - /* dixLookupWindow requires a lot of setup not necessary for this test. * Simple wrapper that returns either one of the fake root window or the * fake client window. If the requested ID is neither of those wanted, * return whatever the real dixLookupWindow does. */ -int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access) +int +__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access) { - if (id == root.drawable.id) - { + if (id == root.drawable.id) { *win = &root; return Success; - } else if (id == window.drawable.id) - { + } + else if (id == window.drawable.id) { *win = &window; return Success; } @@ -70,17 +69,16 @@ int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access return __real_dixLookupWindow(win, id, client, access); } -static void reply_XIQueryPointer(ClientPtr client, int len, char *data, - void *userdata) +static void +reply_XIQueryPointer(ClientPtr client, int len, char *data, void *userdata) { - xXIQueryPointerReply *rep = (xXIQueryPointerReply*)data; + xXIQueryPointerReply *rep = (xXIQueryPointerReply *) data; SpritePtr sprite; if (!rep->repType) return; - if (client->swapped) - { + if (client->swapped) { swapl(&rep->length); swaps(&rep->sequenceNumber); swapl(&rep->root); @@ -101,13 +99,12 @@ static void reply_XIQueryPointer(ClientPtr client, int len, char *data, assert((rep->root_x >> 16) == sprite->hot.x); assert((rep->root_y >> 16) == sprite->hot.y); - if (test_data.win == &root) - { + if (test_data.win == &root) { assert(rep->root_x == rep->win_x); assert(rep->root_y == rep->win_y); assert(rep->child == window.drawable.id); - } else - { + } + else { int x, y; x = sprite->hot.x - window.drawable.x; @@ -118,18 +115,19 @@ static void reply_XIQueryPointer(ClientPtr client, int len, char *data, assert(rep->child == None); } - assert(rep->same_screen == xTrue); reply_handler = reply_XIQueryPointer_data; } -static void reply_XIQueryPointer_data(ClientPtr client, int len, char *data, void *userdata) +static void +reply_XIQueryPointer_data(ClientPtr client, int len, char *data, void *userdata) { reply_handler = reply_XIQueryPointer; } -static void request_XIQueryPointer(ClientPtr client, xXIQueryPointerReq* req, int error) +static void +request_XIQueryPointer(ClientPtr client, xXIQueryPointerReq * req, int error) { int rc; @@ -149,7 +147,8 @@ static void request_XIQueryPointer(ClientPtr client, xXIQueryPointerReq* req, in assert(client_request.errorValue == req->deviceid); } -static void test_XIQueryPointer(void) +static void +test_XIQueryPointer(void) { int i; xXIQueryPointerReq request; @@ -182,12 +181,11 @@ static void test_XIQueryPointer(void) request_XIQueryPointer(&client_request, &request, BadDevice); test_data.dev = devices.mouse; - devices.mouse->master = NULL; /* Float, kind-of */ + devices.mouse->master = NULL; /* Float, kind-of */ request.deviceid = devices.mouse->id; request_XIQueryPointer(&client_request, &request, Success); - for (i = devices.kbd->id + 1; i <= 0xFFFF; i++) - { + for (i = devices.kbd->id + 1; i <= 0xFFFF; i++) { request.deviceid = i; request_XIQueryPointer(&client_request, &request, BadDevice); } @@ -204,7 +202,8 @@ static void test_XIQueryPointer(void) request_XIQueryPointer(&client_request, &request, Success); } -int main(int argc, char** argv) +int +main(int argc, char **argv) { init_simple(); diff --git a/test/xi2/protocol-xiqueryversion.c b/test/xi2/protocol-xiqueryversion.c index d60d16b9d..3d50fa888 100644 --- a/test/xi2/protocol-xiqueryversion.c +++ b/test/xi2/protocol-xiqueryversion.c @@ -41,7 +41,7 @@ #include <X11/Xproto.h> #include <X11/extensions/XI2proto.h> #include "inputstr.h" -#include "extinit.h" /* for XInputExtensionInit */ +#include "extinit.h" /* for XInputExtensionInit */ #include "scrnintstr.h" #include "xiqueryversion.h" @@ -56,14 +56,14 @@ struct test_data { int minor_server; }; -static void reply_XIQueryVersion(ClientPtr client, int len, char* data, void *userdata) +static void +reply_XIQueryVersion(ClientPtr client, int len, char *data, void *userdata) { - xXIQueryVersionReply *rep = (xXIQueryVersionReply*)data; - struct test_data *versions = (struct test_data*)userdata; + xXIQueryVersionReply *rep = (xXIQueryVersionReply *) data; + struct test_data *versions = (struct test_data *) userdata; unsigned int sver, cver, ver; - if (client->swapped) - { + if (client->swapped) { swapl(&rep->length); swaps(&rep->sequenceNumber); swaps(&rep->major_version); @@ -88,7 +88,8 @@ static void reply_XIQueryVersion(ClientPtr client, int len, char* data, void *us * * Test is run normal, then for a swapped client. */ -static void request_XIQueryVersion(int smaj, int smin, int cmaj, int cmin, int error) +static void +request_XIQueryVersion(int smaj, int smin, int cmaj, int cmin, int error) { int rc; struct test_data versions; @@ -97,7 +98,7 @@ static void request_XIQueryVersion(int smaj, int smin, int cmaj, int cmin, int e request_init(&request, XIQueryVersion); client = init_client(request.length, &request); - userdata = (void*)&versions; + userdata = (void *) &versions; /* Change the server to support smaj.smin */ XIVersion.major_version = smaj; @@ -126,7 +127,8 @@ static void request_XIQueryVersion(int smaj, int smin, int cmaj, int cmin, int e /* Client version less than 2.0 must return BadValue, all other combinations * Success */ -static void test_XIQueryVersion(void) +static void +test_XIQueryVersion(void) { reply_handler = reply_XIQueryVersion; @@ -159,9 +161,9 @@ static void test_XIQueryVersion(void) for (smaj = 2; smaj <= 0xFFFF; smaj++) for (smin = 0; smin <= 0xFFFF; smin++) for (cmin = 0; cmin <= 0xFFFF; cmin++) - for (cmaj = 0; cmaj <= 0xFFFF; cmaj++) - { + for (cmaj = 0; cmaj <= 0xFFFF; cmaj++) { int error = (cmaj < 2) ? BadValue : Success; + request_XIQueryVersion(smaj, smin, cmaj, cmin, error); } @@ -170,7 +172,8 @@ static void test_XIQueryVersion(void) reply_handler = NULL; } -int main(int argc, char** argv) +int +main(int argc, char **argv) { init_simple(); diff --git a/test/xi2/protocol-xiselectevents.c b/test/xi2/protocol-xiselectevents.c index 0390858b1..4daba8775 100644 --- a/test/xi2/protocol-xiselectevents.c +++ b/test/xi2/protocol-xiselectevents.c @@ -53,15 +53,17 @@ #include <X11/extensions/XI2proto.h> #include "inputstr.h" #include "windowstr.h" -#include "extinit.h" /* for XInputExtensionInit */ +#include "extinit.h" /* for XInputExtensionInit */ #include "scrnintstr.h" #include "xiselectev.h" #include "protocol-common.h" -static unsigned char *data[4096 * 20]; /* the request data buffer */ +static unsigned char *data[4096 * 20]; /* the request data buffer */ -int __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len, unsigned char* mask) +int +__wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len, + unsigned char *mask) { return Success; } @@ -71,14 +73,14 @@ int __wrap_XISetEventMask(DeviceIntPtr dev, WindowPtr win, int len, unsigned cha * fake client window. If the requested ID is neither of those wanted, * return whatever the real dixLookupWindow does. */ -int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access) +int +__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access) { - if (id == root.drawable.id) - { + if (id == root.drawable.id) { *win = &root; return Success; - } else if (id == window.drawable.id) - { + } + else if (id == window.drawable.id) { *win = &window; return Success; } @@ -86,20 +88,19 @@ int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access return __real_dixLookupWindow(win, id, client, access); } - -static void request_XISelectEvent(xXISelectEventsReq *req, int error) +static void +request_XISelectEvent(xXISelectEventsReq * req, int error) { int i; int rc; ClientRec client; xXIEventMask *mask, *next; - req->length = (sz_xXISelectEventsReq/4); - mask = (xXIEventMask*)&req[1]; - for (i = 0; i < req->num_masks; i++) - { - req->length += sizeof(xXIEventMask)/4 + mask->mask_len; - mask = (xXIEventMask*)((char*)&mask[1] + mask->mask_len * 4); + req->length = (sz_xXISelectEventsReq / 4); + mask = (xXIEventMask *) & req[1]; + for (i = 0; i < req->num_masks; i++) { + req->length += sizeof(xXIEventMask) / 4 + mask->mask_len; + mask = (xXIEventMask *) ((char *) &mask[1] + mask->mask_len * 4); } client = init_client(req->length, req); @@ -109,10 +110,9 @@ static void request_XISelectEvent(xXISelectEventsReq *req, int error) client.swapped = TRUE; - mask = (xXIEventMask*)&req[1]; - for (i = 0; i < req->num_masks; i++) - { - next = (xXIEventMask*)((char*)&mask[1] + mask->mask_len * 4); + mask = (xXIEventMask *) & req[1]; + for (i = 0; i < req->num_masks; i++) { + next = (xXIEventMask *) ((char *) &mask[1] + mask->mask_len * 4); swaps(&mask->deviceid); swaps(&mask->mask_len); mask = next; @@ -125,41 +125,41 @@ static void request_XISelectEvent(xXISelectEventsReq *req, int error) assert(rc == error); } -static void _set_bit(unsigned char *bits, int bit) +static void +_set_bit(unsigned char *bits, int bit) { SetBit(bits, bit); - if (bit >= XI_TouchBegin && bit <= XI_TouchOwnership) - { + if (bit >= XI_TouchBegin && bit <= XI_TouchOwnership) { SetBit(bits, XI_TouchBegin); SetBit(bits, XI_TouchUpdate); SetBit(bits, XI_TouchEnd); } } -static void _clear_bit(unsigned char *bits, int bit) +static void +_clear_bit(unsigned char *bits, int bit) { ClearBit(bits, bit); - if (bit >= XI_TouchBegin && bit <= XI_TouchOwnership) - { + if (bit >= XI_TouchBegin && bit <= XI_TouchOwnership) { ClearBit(bits, XI_TouchBegin); ClearBit(bits, XI_TouchUpdate); ClearBit(bits, XI_TouchEnd); } } -static void request_XISelectEvents_masks(xXISelectEventsReq *req) +static void +request_XISelectEvents_masks(xXISelectEventsReq * req) { int i, j; xXIEventMask *mask; - int nmasks = (XI2LASTEVENT + 7)/8; + int nmasks = (XI2LASTEVENT + 7) / 8; unsigned char *bits; - mask = (xXIEventMask*)&req[1]; + mask = (xXIEventMask *) & req[1]; req->win = ROOT_WINDOW_ID; /* if a clients submits more than 100 masks, consider it insane and untested */ - for (i = 1; i <= 1000; i++) - { + for (i = 1; i <= 1000; i++) { req->num_masks = i; mask->deviceid = XIAllDevices; @@ -174,11 +174,10 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req) * Test setting each valid mask bit, while leaving unneeded bits 0. * -> Success */ - bits = (unsigned char*)&mask[1]; - mask->mask_len = (nmasks + 3)/4 * 10; + bits = (unsigned char *) &mask[1]; + mask->mask_len = (nmasks + 3) / 4 * 10; memset(bits, 0, mask->mask_len * 4); - for (j = 0; j <= XI2LASTEVENT; j++) - { + for (j = 0; j <= XI2LASTEVENT; j++) { _set_bit(bits, j); request_XISelectEvent(req, Success); _clear_bit(bits, j); @@ -189,12 +188,11 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req) * Test setting all valid mask bits, while leaving unneeded bits 0. * -> Success */ - bits = (unsigned char*)&mask[1]; - mask->mask_len = (nmasks + 3)/4 * 10; + bits = (unsigned char *) &mask[1]; + mask->mask_len = (nmasks + 3) / 4 * 10; memset(bits, 0, mask->mask_len * 4); - for (j = 0; j <= XI2LASTEVENT; j++) - { + for (j = 0; j <= XI2LASTEVENT; j++) { _set_bit(bits, j); request_XISelectEvent(req, Success); } @@ -203,12 +201,11 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req) * mask is larger than needed for XI2LASTEVENT. If any unneeded bit * is set -> BadValue */ - bits = (unsigned char*)&mask[1]; - mask->mask_len = (nmasks + 3)/4 * 10; + bits = (unsigned char *) &mask[1]; + mask->mask_len = (nmasks + 3) / 4 * 10; memset(bits, 0, mask->mask_len * 4); - for (j = XI2LASTEVENT + 1; j < mask->mask_len * 4; j++) - { + for (j = XI2LASTEVENT + 1; j < mask->mask_len * 4; j++) { _set_bit(bits, j); request_XISelectEvent(req, BadValue); _clear_bit(bits, j); @@ -217,11 +214,10 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req) /* Test 4: * Mask len is a sensible length, only valid bits are set -> Success */ - bits = (unsigned char*)&mask[1]; - mask->mask_len = (nmasks + 3)/4; + bits = (unsigned char *) &mask[1]; + mask->mask_len = (nmasks + 3) / 4; memset(bits, 0, mask->mask_len * 4); - for (j = 0; j <= XI2LASTEVENT; j++) - { + for (j = 0; j <= XI2LASTEVENT; j++) { _set_bit(bits, j); request_XISelectEvent(req, Success); } @@ -230,14 +226,13 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req) * HierarchyChanged bit is BadValue for devices other than * XIAllDevices */ - bits = (unsigned char*)&mask[1]; - mask->mask_len = (nmasks + 3)/4; + bits = (unsigned char *) &mask[1]; + mask->mask_len = (nmasks + 3) / 4; memset(bits, 0, mask->mask_len * 4); SetBit(bits, XI_HierarchyChanged); mask->deviceid = XIAllDevices; request_XISelectEvent(req, Success); - for (j = 1; j < devices.num_devices; j++) - { + for (j = 1; j < devices.num_devices; j++) { mask->deviceid = j; request_XISelectEvent(req, BadValue); } @@ -245,28 +240,31 @@ static void request_XISelectEvents_masks(xXISelectEventsReq *req) /* Test 6: * All bits set minus hierarchy changed bit -> Success */ - bits = (unsigned char*)&mask[1]; - mask->mask_len = (nmasks + 3)/4; + bits = (unsigned char *) &mask[1]; + mask->mask_len = (nmasks + 3) / 4; memset(bits, 0, mask->mask_len * 4); for (j = 0; j <= XI2LASTEVENT; j++) _set_bit(bits, j); _clear_bit(bits, XI_HierarchyChanged); - for (j = 1; j < 6; j++) - { + for (j = 1; j < 6; j++) { mask->deviceid = j; request_XISelectEvent(req, Success); } - mask = (xXIEventMask*)((char*)mask + sizeof(xXIEventMask) + mask->mask_len * 4); + mask = + (xXIEventMask *) ((char *) mask + sizeof(xXIEventMask) + + mask->mask_len * 4); } } -static void test_XISelectEvents(void) +static void +test_XISelectEvents(void) { int i; xXIEventMask *mask; xXISelectEventsReq *req; - req = (xXISelectEventsReq*)data; + + req = (xXISelectEventsReq *) data; request_init(req, XISelectEvents); @@ -313,16 +311,15 @@ static void test_XISelectEvents(void) req->num_masks = 1; printf("Triggering bogus mask length error\n"); - mask = (xXIEventMask*)&req[1]; + mask = (xXIEventMask *) & req[1]; mask->deviceid = 0; mask->mask_len = 0xFFFF; request_XISelectEvent(req, BadLength); /* testing various device ids */ printf("Testing existing device ids.\n"); - for (i = 0; i < 6; i++) - { - mask = (xXIEventMask*)&req[1]; + for (i = 0; i < 6; i++) { + mask = (xXIEventMask *) & req[1]; mask->deviceid = i; mask->mask_len = 1; req->win = ROOT_WINDOW_ID; @@ -331,11 +328,10 @@ static void test_XISelectEvents(void) } printf("Testing non-existing device ids.\n"); - for (i = 6; i <= 0xFFFF; i++) - { + for (i = 6; i <= 0xFFFF; i++) { req->win = ROOT_WINDOW_ID; req->num_masks = 1; - mask = (xXIEventMask*)&req[1]; + mask = (xXIEventMask *) & req[1]; mask->deviceid = i; mask->mask_len = 1; request_XISelectEvent(req, BadDevice); @@ -344,7 +340,8 @@ static void test_XISelectEvents(void) request_XISelectEvents_masks(req); } -int main(int argc, char** argv) +int +main(int argc, char **argv) { init_simple(); @@ -352,4 +349,3 @@ int main(int argc, char** argv) return 0; } - diff --git a/test/xi2/protocol-xisetclientpointer.c b/test/xi2/protocol-xisetclientpointer.c index d9620e336..51db4ac69 100644 --- a/test/xi2/protocol-xisetclientpointer.c +++ b/test/xi2/protocol-xisetclientpointer.c @@ -40,7 +40,7 @@ #include <X11/extensions/XI2proto.h> #include "inputstr.h" #include "windowstr.h" -#include "extinit.h" /* for XInputExtensionInit */ +#include "extinit.h" /* for XInputExtensionInit */ #include "scrnintstr.h" #include "xisetclientpointer.h" #include "exevents.h" @@ -50,13 +50,14 @@ static ClientRec client_window; static ClientRec client_request; -int __wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask access) +int +__wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, + Mask access) { if (rid == ROOT_WINDOW_ID) return BadWindow; - if (rid == CLIENT_WINDOW_ID) - { + if (rid == CLIENT_WINDOW_ID) { *pClient = &client_window; return Success; } @@ -64,9 +65,11 @@ int __wrap_dixLookupClient(ClientPtr *pClient, XID rid, ClientPtr client, Mask a return __real_dixLookupClient(pClient, rid, client, access); } -static void request_XISetClientPointer(xXISetClientPointerReq* req, int error) +static void +request_XISetClientPointer(xXISetClientPointerReq * req, int error) { int rc; + client_request = init_client(req->length, req); rc = ProcXISetClientPointer(&client_request); @@ -87,7 +90,8 @@ static void request_XISetClientPointer(xXISetClientPointerReq* req, int error) } -static void test_XISetClientPointer(void) +static void +test_XISetClientPointer(void) { int i; xXISetClientPointerReq request; @@ -113,8 +117,7 @@ static void test_XISetClientPointer(void) assert(client_window.clientPtr->id == 2); printf("Testing BadDevice error for all other devices.\n"); - for (i = 4; i <= 0xFFFF; i++) - { + for (i = 4; i <= 0xFFFF; i++) { request.deviceid = i; request_XISetClientPointer(&request, BadDevice); } @@ -132,8 +135,8 @@ static void test_XISetClientPointer(void) } - -int main(int argc, char** argv) +int +main(int argc, char **argv) { init_simple(); client_window = init_client(0, NULL); diff --git a/test/xi2/protocol-xiwarppointer.c b/test/xi2/protocol-xiwarppointer.c index 2b40f63f9..c279ac413 100644 --- a/test/xi2/protocol-xiwarppointer.c +++ b/test/xi2/protocol-xiwarppointer.c @@ -48,14 +48,14 @@ static int expected_y = SPRITE_Y; * fake client window. If the requested ID is neither of those wanted, * return whatever the real dixLookupWindow does. */ -int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access) +int +__wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access) { - if (id == root.drawable.id) - { + if (id == root.drawable.id) { *win = &root; return Success; - } else if (id == window.drawable.id) - { + } + else if (id == window.drawable.id) { *win = &window; return Success; } @@ -66,17 +66,17 @@ int __wrap_dixLookupWindow(WindowPtr *win, XID id, ClientPtr client, Mask access /** * This function overrides the one in the screen rec. */ -static Bool ScreenSetCursorPosition(DeviceIntPtr dev, ScreenPtr screen, - int x, int y, Bool generateEvent) +static Bool +ScreenSetCursorPosition(DeviceIntPtr dev, ScreenPtr screen, + int x, int y, Bool generateEvent) { assert(x == expected_x); assert(y == expected_y); return TRUE; } - -static void request_XIWarpPointer(ClientPtr client, xXIWarpPointerReq* req, - int error) +static void +request_XIWarpPointer(ClientPtr client, xXIWarpPointerReq * req, int error) { int rc; @@ -87,8 +87,7 @@ static void request_XIWarpPointer(ClientPtr client, xXIWarpPointerReq* req, assert(client->errorValue == req->deviceid); else if (rc == BadWindow) assert(client->errorValue == req->dst_win || - client->errorValue == req->src_win); - + client->errorValue == req->src_win); client->swapped = TRUE; @@ -109,12 +108,13 @@ static void request_XIWarpPointer(ClientPtr client, xXIWarpPointerReq* req, assert(client->errorValue == req->deviceid); else if (rc == BadWindow) assert(client->errorValue == req->dst_win || - client->errorValue == req->src_win); + client->errorValue == req->src_win); client->swapped = FALSE; } -static void test_XIWarpPointer(void) +static void +test_XIWarpPointer(void) { int i; ClientRec client_request; @@ -143,12 +143,11 @@ static void test_XIWarpPointer(void) request.deviceid = devices.kbd->id; request_XIWarpPointer(&client_request, &request, BadDevice); - devices.mouse->master = NULL; /* Float, kind-of */ + devices.mouse->master = NULL; /* Float, kind-of */ request.deviceid = devices.mouse->id; request_XIWarpPointer(&client_request, &request, Success); - for (i = devices.kbd->id + 1; i <= 0xFFFF; i++) - { + for (i = devices.kbd->id + 1; i <= 0xFFFF; i++) { request.deviceid = i; request_XIWarpPointer(&client_request, &request, BadDevice); } @@ -161,10 +160,10 @@ static void test_XIWarpPointer(void) request_XIWarpPointer(&client_request, &request, Success); request.src_win = root.drawable.id; - request.dst_win = 0xFFFF; /* invalid window */ + request.dst_win = 0xFFFF; /* invalid window */ request_XIWarpPointer(&client_request, &request, BadWindow); - request.src_win = 0xFFFF; /* invalid window */ + request.src_win = 0xFFFF; /* invalid window */ request.dst_win = root.drawable.id; request_XIWarpPointer(&client_request, &request, BadWindow); @@ -200,7 +199,8 @@ static void test_XIWarpPointer(void) /* FIXME: src_x/y checks */ } -int main(int argc, char** argv) +int +main(int argc, char **argv) { init_simple(); screen.SetCursorPosition = ScreenSetCursorPosition; diff --git a/test/xi2/xi2.c b/test/xi2/xi2.c index 5143caff8..6ee705293 100644 --- a/test/xi2/xi2.c +++ b/test/xi2/xi2.c @@ -30,10 +30,10 @@ #include "inputstr.h" #include "assert.h" -static void xi2mask_test(void) +static void +xi2mask_test(void) { - XI2Mask *xi2mask = NULL, - *mergemask = NULL; + XI2Mask *xi2mask = NULL, *mergemask = NULL; unsigned char *mask; DeviceIntRec dev; int i; @@ -51,12 +51,14 @@ static void xi2mask_test(void) /* ensure zeros */ for (i = 0; i < xi2mask_num_masks(xi2mask); i++) { const unsigned char *m = xi2mask_get_one_mask(xi2mask, i); + assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0); } /* set various bits */ for (i = 0; i < xi2mask_num_masks(xi2mask); i++) { const unsigned char *m; + xi2mask_set(xi2mask, i, i); dev.id = i; @@ -71,6 +73,7 @@ static void xi2mask_test(void) /* ensure zeros one-by-one */ for (i = 0; i < xi2mask_num_masks(xi2mask); i++) { const unsigned char *m = xi2mask_get_one_mask(xi2mask, i); + assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) != 0); xi2mask_zero(xi2mask, i); assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0); @@ -83,11 +86,13 @@ static void xi2mask_test(void) for (i = 0; i < xi2mask_num_masks(xi2mask); i++) { const unsigned char *m = xi2mask_get_one_mask(xi2mask, i); + assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0); } for (i = 0; i < xi2mask_num_masks(xi2mask); i++) { const unsigned char *m; + SetBit(mask, i); xi2mask_set_one_mask(xi2mask, i, mask, xi2mask_mask_size(xi2mask)); m = xi2mask_get_one_mask(xi2mask, i); @@ -105,6 +110,7 @@ static void xi2mask_test(void) xi2mask_merge(xi2mask, mergemask); for (i = 0; i < xi2mask_num_masks(mergemask); i++) { const unsigned char *m = xi2mask_get_one_mask(xi2mask, i); + SetBit(mask, i); SetBit(mask, i * 2); assert(memcmp(mask, m, xi2mask_mask_size(xi2mask)) == 0); @@ -120,8 +126,8 @@ static void xi2mask_test(void) free(mask); } - -int main(int argc, char** argv) +int +main(int argc, char **argv) { xi2mask_test(); diff --git a/test/xkb.c b/test/xkb.c index 421153cd1..955e72dff 100644 --- a/test/xkb.c +++ b/test/xkb.c @@ -55,12 +55,12 @@ * * Result: RMLVO defaults are the same as obtained. */ -static void xkb_get_rules_test(void) +static void +xkb_get_rules_test(void) { - XkbRMLVOSet rmlvo = { NULL}; + XkbRMLVOSet rmlvo = { NULL }; XkbGetRulesDflts(&rmlvo); - assert(rmlvo.rules); assert(rmlvo.model); assert(rmlvo.layout); @@ -79,7 +79,8 @@ static void xkb_get_rules_test(void) * Compare obtained ruleset with the built-in defaults. * Result: RMLVO defaults are the same as obtained. */ -static void xkb_set_rules_test(void) +static void +xkb_set_rules_test(void) { XkbRMLVOSet rmlvo = { .rules = "test-rules", @@ -107,7 +108,6 @@ static void xkb_set_rules_test(void) assert(strcmp(rmlvo.options, rmlvo_new.options) == 0); } - /** * Get the default RMLVO set. * Set the default RMLVO set. @@ -116,7 +116,8 @@ static void xkb_set_rules_test(void) * * Result: RMLVO set obtained is the same as previously set. */ -static void xkb_set_get_rules_test(void) +static void +xkb_set_get_rules_test(void) { /* This test failed before XkbGetRulesDftlts changed to strdup. We test this twice because the first time using XkbGetRulesDflts we obtain @@ -158,8 +159,8 @@ static void xkb_set_get_rules_test(void) assert(strcmp(rmlvo.options, rmlvo_backup.options) == 0); } - -int main(int argc, char** argv) +int +main(int argc, char **argv) { xkb_set_get_rules_test(); xkb_get_rules_test(); diff --git a/test/xtest.c b/test/xtest.c index 2ab46505f..aeca669d8 100644 --- a/test/xtest.c +++ b/test/xtest.c @@ -40,9 +40,14 @@ extern DeviceIntPtr xtestpointer, xtestkeyboard; /* Needed for the screen setup, otherwise we crash during sprite initialization */ -static Bool device_cursor_init(DeviceIntPtr dev, ScreenPtr screen) { return TRUE; } +static Bool +device_cursor_init(DeviceIntPtr dev, ScreenPtr screen) +{ + return TRUE; +} -static void xtest_init_devices(void) +static void +xtest_init_devices(void) { ScreenRec screen; @@ -68,8 +73,10 @@ static void xtest_init_devices(void) assert(IsXTestDevice(xtestpointer, NULL)); assert(IsXTestDevice(xtestkeyboard, NULL)); assert(IsXTestDevice(xtestpointer, inputInfo.pointer)); + assert(IsXTestDevice(xtestkeyboard, inputInfo.keyboard)); assert(GetXTestDevice(inputInfo.pointer) == xtestpointer); + assert(GetXTestDevice(inputInfo.keyboard) == xtestkeyboard); } @@ -77,7 +84,8 @@ static void xtest_init_devices(void) * Each xtest devices has a property attached marking it. This property * cannot be changed. */ -static void xtest_properties(void) +static void +xtest_properties(void) { int rc; char value = 1; @@ -93,21 +101,20 @@ static void xtest_properties(void) assert(prop != NULL); rc = XIChangeDeviceProperty(xtestpointer, xtest_prop, - XA_INTEGER, 8, PropModeReplace, 1, &value, FALSE); + XA_INTEGER, 8, PropModeReplace, 1, &value, + FALSE); assert(rc == BadAccess); rc = XIChangeDeviceProperty(xtestkeyboard, xtest_prop, - XA_INTEGER, 8, PropModeReplace, 1, &value, FALSE); + XA_INTEGER, 8, PropModeReplace, 1, &value, + FALSE); assert(rc == BadAccess); } - - -int main(int argc, char** argv) +int +main(int argc, char **argv) { xtest_init_devices(); xtest_properties(); return 0; } - - |