From: David Herrmann Date: Tue, 23 Sep 2014 11:38:09 +0000 (+0200) Subject: terminal: fix tile-offset calculation X-Git-Tag: v217~450 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=b4170aed36e667e52ce4a353bda1964e3872ab34 terminal: fix tile-offset calculation Binary operators with two pointers as arguments always operate on object-size, not bytes. That is, "int *a, *b", (a - b) calculates the number of integers between b and a, not the number of bytes. Fix our cache-offset calculation to not use sizeof() with full-ptr arithmetic. --- diff --git a/src/libsystemd-terminal/grdev.c b/src/libsystemd-terminal/grdev.c index c5ea524c6..80a71beeb 100644 --- a/src/libsystemd-terminal/grdev.c +++ b/src/libsystemd-terminal/grdev.c @@ -345,7 +345,7 @@ const grdev_display_target *grdev_display_next_target(grdev_display *display, co assert(cache->pipe->tile->display == display); assert(display->pipes >= cache); - idx = (cache - display->pipes) / sizeof(*cache) + 1; + idx = cache - display->pipes + 1; } else { idx = 0; }