[Piglit] [PATCH] ext_packed_depth_stencil: Fix Clang absolute-value warning.
Brian Paul
brianp at vmware.com
Mon Mar 23 07:37:25 PDT 2015
On 03/22/2015 12:48 AM, Vinson Lee wrote:
> readpixels-24_8.c:62:6: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]
> abs((value >> 8) - (expected >> 8)) > 1) {
> ^
> readpixels-24_8.c:62:6: note: remove the call to 'abs' since unsigned values cannot be negative
> abs((value >> 8) - (expected >> 8)) > 1) {
> ^~~
>
> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> ---
> tests/spec/ext_packed_depth_stencil/readpixels-24_8.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/spec/ext_packed_depth_stencil/readpixels-24_8.c b/tests/spec/ext_packed_depth_stencil/readpixels-24_8.c
> index 7fb9ad8..1a3b055 100644
> --- a/tests/spec/ext_packed_depth_stencil/readpixels-24_8.c
> +++ b/tests/spec/ext_packed_depth_stencil/readpixels-24_8.c
> @@ -59,7 +59,7 @@ test_pixel(int x, int y, uint32_t value)
>
> /* Compare depth and stencil separately. Use 1-bit tolerance for depth. */
> if ((value & 0xff) - (expected & 0xff) != 0 ||
> - abs((value >> 8) - (expected >> 8)) > 1) {
> + ((value >> 8) - (expected >> 8)) > 1) {
> fprintf(stderr,
> "Expected 0x%08x at (%d,%d), found 0x%08x\n",
> expected, x, y, value);
>
We still need the abs(). The correct fix is to cast the two terms of
the subtraction to int:
abs((int) (value >> 8) - (int) (expected >> 8))
-Brian
More information about the Piglit
mailing list