chiark / gitweb /
terminal: fix tile-offset calculation
authorDavid Herrmann <dh.herrmann@gmail.com>
Tue, 23 Sep 2014 11:38:09 +0000 (13:38 +0200)
committerDavid Herrmann <dh.herrmann@gmail.com>
Tue, 23 Sep 2014 18:05:44 +0000 (20:05 +0200)
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.

src/libsystemd-terminal/grdev.c

index c5ea524c69fd725990977f9e55bb4856527c4981..80a71beeb937693bf81abcffdcced031634409b5 100644 (file)
@@ -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;
         }