[Mesa-dev] [PATCH] V2 radeon: remove unnecessary checks

Jakob Sinclair sinclair.jakob at openmailbox.org
Tue Jun 14 18:28:33 UTC 2016


PIPE_SWIZZLE_X is always 0 and desc->swizzle is an unsigned char meaning
that desc->swizzle can never be smaller then PIPE_SWIZZLE_X. Removing
these checks doesn't change the code path at all because they would
always give the same result. Issue discovered by Coverity.

V2: Removed "- PIPE_SWIZZLE_X" for more consistency.

CID: 1337954

Signed-off-by: Jakob Sinclair <sinclair.jakob at openmailbox.org>
---
 src/gallium/drivers/radeon/r600_texture.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c
index 32347f2..3a56f9f 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -1754,10 +1754,9 @@ static void vi_get_fast_clear_parameters(enum pipe_format surface_format,
 		return;
 
 	for (i = 0; i < 4; ++i) {
-		int index = desc->swizzle[i] - PIPE_SWIZZLE_X;
+		int index = desc->swizzle[i];
 
-		if (desc->swizzle[i] < PIPE_SWIZZLE_X ||
-		    desc->swizzle[i] > PIPE_SWIZZLE_W)
+		if (desc->swizzle[i] > PIPE_SWIZZLE_W)
 			continue;
 
 		if (util_format_is_pure_sint(surface_format)) {
@@ -1782,8 +1781,7 @@ static void vi_get_fast_clear_parameters(enum pipe_format surface_format,
 
 	for (int i = 0; i < 4; ++i)
 		if (values[i] != main_value &&
-		    desc->swizzle[i] - PIPE_SWIZZLE_X != extra_channel &&
-		    desc->swizzle[i] >= PIPE_SWIZZLE_X &&
+		    desc->swizzle[i] != extra_channel &&
 		    desc->swizzle[i] <= PIPE_SWIZZLE_W)
 			return;
 
-- 
2.8.3



More information about the mesa-dev mailing list