aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-08-23 04:08:38 +0000
committerDaniel Eklöf <daniel@ekloef.se>2020-08-23 04:08:38 +0000
commit75dc06f3036b36d35fb9c6116bee44d8f0ad9a95 (patch)
treee1e85fe4eee6ddcaaedca95770ceee3b6c4b5902
parentMerge branch 'dont-send-mouse-events-to-client-when-binding-consumed-it' into master (diff)
parentcsi: avoid using memcmp() to compare timespec structs (diff)
Merge branch 'timespec-compare-fix' into master
-rw-r--r--csi.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/csi.c b/csi.c
index 657f6628..53a90805 100644
--- a/csi.c
+++ b/csi.c
@@ -544,6 +544,12 @@ decrst(struct terminal *term, unsigned param)
decset_decrst(term, param, false);
}
+static bool
+timespecs_equal(const struct timespec *a, const struct timespec *b)
+{
+ return a->tv_sec == b->tv_sec && a->tv_nsec == b->tv_nsec;
+}
+
static void
xtsave(struct terminal *term, unsigned param)
{
@@ -561,10 +567,10 @@ xtsave(struct terminal *term, unsigned param)
if (timerfd_gettime(term->cursor_blink.fd, &current_value) < 0)
LOG_WARN("xtsave: failed to read cursor blink timer: %s", strerror(errno));
else {
- const struct timespec zero = {};
+ const struct timespec zero = {.tv_sec = 0, .tv_nsec = 0};
term->xtsave.cursor_blink =
- !(memcmp(&current_value.it_interval, &zero, sizeof(zero)) == 0 &&
- memcmp(&current_value.it_value, &zero, sizeof(zero)) == 0);
+ !(timespecs_equal(&current_value.it_interval, &zero) &&
+ timespecs_equal(&current_value.it_value, &zero));
}
break;
}