From 1007540ac02dffe4335be22fd01ca3ed7a64baef Mon Sep 17 00:00:00 2001 From: NRK Date: Tue, 25 Oct 2022 14:17:49 +0600 Subject: [PATCH 1/4] remove unused variable --- xbanish.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/xbanish.c b/xbanish.c index e15f620..64a7358 100644 --- a/xbanish.c +++ b/xbanish.c @@ -564,11 +564,8 @@ void set_alarm(XSyncAlarm *alarm, XSyncTestType test) { XSyncAlarmAttributes attr; - XSyncValue value; unsigned int flags; - XSyncQueryCounter(dpy, idler_counter, &value); - attr.trigger.counter = idler_counter; attr.trigger.test_type = test; attr.trigger.value_type = XSyncRelative; From 26806dd19b1d16bf0f02cfcb3978b012bd26e7a1 Mon Sep 17 00:00:00 2001 From: NRK Date: Tue, 25 Oct 2022 14:20:07 +0600 Subject: [PATCH 2/4] set XSyncCAValueType in flags value_type was being set in `attr` but it wasn't set in `flags`. --- xbanish.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xbanish.c b/xbanish.c index 64a7358..0ae4237 100644 --- a/xbanish.c +++ b/xbanish.c @@ -573,7 +573,8 @@ set_alarm(XSyncAlarm *alarm, XSyncTestType test) (unsigned long)(timeout * 1000) >> 32); XSyncIntToValue(&attr.delta, 0); - flags = XSyncCACounter | XSyncCATestType | XSyncCAValue | XSyncCADelta; + flags = XSyncCACounter | XSyncCATestType | XSyncCAValueType | + XSyncCAValue | XSyncCADelta; if (*alarm) XSyncDestroyAlarm(dpy, *alarm); From 56b5d9588bf7a0c1a390c860003c60772e357d76 Mon Sep 17 00:00:00 2001 From: NRK Date: Tue, 25 Oct 2022 14:22:22 +0600 Subject: [PATCH 3/4] use XSyncChangeAlarm instead of destroying and creating --- xbanish.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xbanish.c b/xbanish.c index 0ae4237..93d6c25 100644 --- a/xbanish.c +++ b/xbanish.c @@ -576,10 +576,10 @@ set_alarm(XSyncAlarm *alarm, XSyncTestType test) flags = XSyncCACounter | XSyncCATestType | XSyncCAValueType | XSyncCAValue | XSyncCADelta; - if (*alarm) - XSyncDestroyAlarm(dpy, *alarm); - - *alarm = XSyncCreateAlarm(dpy, flags, &attr); + if (*alarm == None) + *alarm = XSyncCreateAlarm(dpy, flags, &attr); + else + XSyncChangeAlarm(dpy, *alarm, flags, &attr); } void From 2c89b4e631f972410167566ac1c506ac0b2291f3 Mon Sep 17 00:00:00 2001 From: NRK Date: Tue, 25 Oct 2022 14:25:16 +0600 Subject: [PATCH 4/4] ensure multiplication takes place in unsigned long the cast here seems dobious. the multiplication will take place in `unsigned int` and the cast only affects the _result_ and not the multiplication itself. which means that the high 32bits will remain zero and the shift will thus always produce zero as well. use UL suffix on the integer constant to ensure that the multiplication itself happens at `unsigned long`. --- xbanish.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xbanish.c b/xbanish.c index 93d6c25..bfc3bd8 100644 --- a/xbanish.c +++ b/xbanish.c @@ -569,8 +569,8 @@ set_alarm(XSyncAlarm *alarm, XSyncTestType test) attr.trigger.counter = idler_counter; attr.trigger.test_type = test; attr.trigger.value_type = XSyncRelative; - XSyncIntsToValue(&attr.trigger.wait_value, timeout * 1000, - (unsigned long)(timeout * 1000) >> 32); + XSyncIntsToValue(&attr.trigger.wait_value, timeout * 1000UL, + (timeout * 1000UL) >> 32); XSyncIntToValue(&attr.delta, 0); flags = XSyncCACounter | XSyncCATestType | XSyncCAValueType |