All of lore.kernel.org
 help / color / mirror / Atom feed
From: przanoni@gmail.com
To: intel-gfx@lists.freedesktop.org
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: [PATCH 1/2] Fix "always false" conditionals
Date: Fri, 16 Sep 2011 18:53:01 -0300	[thread overview]
Message-ID: <1316209981-23217-1-git-send-email-przanoni@gmail.com> (raw)

From: Paulo Zanoni <paulo.r.zanoni@intel.com>

Enums are unsigned by default in gcc and we can't rely on any specific
signedess for the other compilers.

i965_render.c: In function ‘i965_prepare_composite’:
i965_render.c:2018:2: warning: comparison of unsigned expression < 0 is always false
i965_render.c:2025:2: warning: comparison of unsigned expression < 0 is always false
i965_render.c:2050:3: warning: comparison of unsigned expression < 0 is always false
i965_render.c:2057:3: warning: comparison of unsigned expression < 0 is always false

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
 src/i965_render.c |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

I could also have defined FILTER_ERROR as -1, then gcc would have automagically
converted the enum to signed, but I'm not sure what other compilers would do in
this case.

diff --git a/src/i965_render.c b/src/i965_render.c
index 7e1da5b..2bd25b5 100644
--- a/src/i965_render.c
+++ b/src/i965_render.c
@@ -606,7 +606,8 @@ static const uint32_t ps_kernel_masknoca_projective_static_gen7[][4] = {
 typedef enum {
 	SAMPLER_STATE_FILTER_NEAREST,
 	SAMPLER_STATE_FILTER_BILINEAR,
-	FILTER_COUNT
+	FILTER_COUNT,
+	FILTER_ERROR
 } sampler_state_filter_t;
 
 typedef enum {
@@ -614,7 +615,8 @@ typedef enum {
 	SAMPLER_STATE_EXTEND_REPEAT,
 	SAMPLER_STATE_EXTEND_PAD,
 	SAMPLER_STATE_EXTEND_REFLECT,
-	EXTEND_COUNT
+	EXTEND_COUNT,
+	EXTEND_ERROR
 } sampler_state_extend_t;
 
 typedef enum {
@@ -1248,7 +1250,7 @@ static sampler_state_filter_t sampler_state_filter_from_picture(int filter)
 	case PictFilterBilinear:
 		return SAMPLER_STATE_FILTER_BILINEAR;
 	default:
-		return -1;
+		return FILTER_ERROR;
 	}
 }
 
@@ -1264,7 +1266,7 @@ static sampler_state_extend_t sampler_state_extend_from_picture(int repeat_type)
 	case RepeatReflect:
 		return SAMPLER_STATE_EXTEND_REFLECT;
 	default:
-		return -1;
+		return EXTEND_ERROR;
 	}
 }
 
@@ -2015,14 +2017,14 @@ i965_prepare_composite(int op, PicturePtr source_picture,
 
 	composite_op->src_filter =
 	    sampler_state_filter_from_picture(source_picture->filter);
-	if (composite_op->src_filter < 0) {
+	if (composite_op->src_filter == FILTER_ERROR) {
 		intel_debug_fallback(scrn, "Bad src filter 0x%x\n",
 				     source_picture->filter);
 		return FALSE;
 	}
 	composite_op->src_extend =
 	    sampler_state_extend_from_picture(source_picture->repeatType);
-	if (composite_op->src_extend < 0) {
+	if (composite_op->src_extend == EXTEND_ERROR) {
 		intel_debug_fallback(scrn, "Bad src repeat 0x%x\n",
 				     source_picture->repeatType);
 		return FALSE;
@@ -2047,14 +2049,14 @@ i965_prepare_composite(int op, PicturePtr source_picture,
 
 		composite_op->mask_filter =
 		    sampler_state_filter_from_picture(mask_picture->filter);
-		if (composite_op->mask_filter < 0) {
+		if (composite_op->mask_filter == FILTER_ERROR) {
 			intel_debug_fallback(scrn, "Bad mask filter 0x%x\n",
 					     mask_picture->filter);
 			return FALSE;
 		}
 		composite_op->mask_extend =
 		    sampler_state_extend_from_picture(mask_picture->repeatType);
-		if (composite_op->mask_extend < 0) {
+		if (composite_op->mask_extend == EXTEND_ERROR) {
 			intel_debug_fallback(scrn, "Bad mask repeat 0x%x\n",
 					     mask_picture->repeatType);
 			return FALSE;
-- 
1.7.4.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

             reply	other threads:[~2011-09-16 21:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-16 21:53 przanoni [this message]
2011-09-16 21:56 ` [PATCH 2/2] Remove useless assertion przanoni
2011-09-16 22:11 ` [PATCH 1/2] Fix "always false" conditionals Chris Wilson
2011-09-18  8:48 ` Chris Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1316209981-23217-1-git-send-email-przanoni@gmail.com \
    --to=przanoni@gmail.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=paulo.r.zanoni@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.