]> granicus.if.org Git - libvpx/commitdiff
vp9: address integer sanitizer warning
authorJohann <johannkoenig@google.com>
Fri, 3 Aug 2018 22:36:59 +0000 (15:36 -0700)
committerJohann <johannkoenig@google.com>
Mon, 6 Aug 2018 22:55:07 +0000 (15:55 -0700)
Comparing the size values with subtraction requires casting. Sort in
descending order.

(a < b) - (a > b)
If a is greater, this is 0 - 1 = -1
If the  values are equal, this is 0 - 0 = 0
If b is greater, this is 1 - 0 = 1

Change-Id: I5c20fd10fbc97c391c6858235c44d25d7db57f0e

vp9/decoder/vp9_decodeframe.c

index 9c793f710772362a7906613d3bea11121cc9ab01..2d6dbe8d748736484f89c03407cf1083a37ac285 100644 (file)
@@ -1532,9 +1532,9 @@ static int tile_worker_hook(void *arg1, void *arg2) {
 
 // sorts in descending order
 static int compare_tile_buffers(const void *a, const void *b) {
-  const TileBuffer *const buf1 = (const TileBuffer *)a;
-  const TileBuffer *const buf2 = (const TileBuffer *)b;
-  return (int)((int64_t)buf2->size - buf1->size);
+  const TileBuffer *const buf_a = (const TileBuffer *)a;
+  const TileBuffer *const buf_b = (const TileBuffer *)b;
+  return (buf_a->size < buf_b->size) - (buf_a->size > buf_b->size);
 }
 
 static const uint8_t *decode_tiles_mt(VP9Decoder *pbi, const uint8_t *data,