util: mark s as MAYBE_UNUSED in _mesa_half_to_unorm8
authorKai Wasserbäch <kai@dev.carbon-project.org>
Fri, 17 Aug 2018 14:32:31 +0000 (16:32 +0200)
committerTimothy Arceri <tarceri@itsqueeze.com>
Sat, 18 Aug 2018 00:34:12 +0000 (10:34 +1000)
Only used, when asserts are enabled.

Fixes an unused-variable warning with gcc-8:
 ../../../src/util/half_float.c: In function '_mesa_half_to_unorm8':
 ../../../src/util/half_float.c:189:14: warning: unused variable 's' [-Wunused-variable]
     const int s = (val >> 15) & 0x1;
               ^

Signed-off-by: Kai Wasserbäch <kai@dev.carbon-project.org>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/util/half_float.c

index 2eff2c84f51f1e7eeccbedaeb32e4b036dc838ec..63aec5c5c14f476cf2ceaf3f73eca4f139a04cfb 100644 (file)
@@ -28,6 +28,7 @@
 #include <assert.h>
 #include "half_float.h"
 #include "rounding.h"
+#include "macros.h"
 
 typedef union { float f; int32_t i; uint32_t u; } fi_type;
 
@@ -186,7 +187,7 @@ uint8_t _mesa_half_to_unorm8(uint16_t val)
 {
    const int m = val & 0x3ff;
    const int e = (val >> 10) & 0x1f;
-   const int s = (val >> 15) & 0x1;
+   MAYBE_UNUSED const int s = (val >> 15) & 0x1;
 
    /* v = round_to_nearest(1.mmmmmmmmmm * 2^(e-15) * 255)
     *   = round_to_nearest((1.mmmmmmmmmm * 255) * 2^(e-15))