[Mesa-dev] [RFC PATCH 3/4] ff_fragment_shader: mark impossible switch values with unreachable

Giuseppe Bilotta giuseppe.bilotta at gmail.com
Sat Apr 22 07:52:13 UTC 2017


Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
---
 src/mesa/main/ff_fragment_shader.cpp | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index aac9de78ca..4f2d6b07a2 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -138,8 +138,7 @@ need_saturate( GLuint mode )
    case TEXENV_MODE_ADD_PRODUCTS_SIGNED_NV:
       return GL_TRUE;
    default:
-      assert(0);
-      return GL_FALSE;
+      unreachable("Invalid TexEnv Combine mode");
    }
 }
 
@@ -426,8 +425,7 @@ get_source(texenv_fragment_program *p,
       }
 
    default:
-      assert(0);
-      return NULL;
+      unreachable("Invalid TexEnv source");
    }
 }
 
@@ -458,8 +456,7 @@ emit_combine_source(texenv_fragment_program *p,
       return src;
 
    default:
-      assert(0);
-      return src;
+      unreachable("Invalid TexEnv Combine operand");
    }
 }
 
@@ -495,8 +492,8 @@ static GLboolean args_match( const struct state_key *key, GLuint unit )
 	    return GL_FALSE;
 	 }
 	 break;
-      default: 
-	 return GL_FALSE;	/* impossible */
+      default:
+	 unreachable("Invalid TexEnv Combine operand");
       }
    }
 
@@ -579,9 +576,8 @@ emit_combine(texenv_fragment_program *p,
    case TEXENV_MODE_ADD_PRODUCTS_SIGNED_NV:
       return add(add(mul(src[0], src[1]), mul(src[2], src[3])),
 		 new(p->mem_ctx) ir_constant(-0.5f));
-   default: 
-      assert(0);
-      return src[0];
+   default:
+      unreachable("Invalid TexEnv Combine mode");
    }
 }
 
-- 
2.13.0.rc0.207.gb442654931



More information about the mesa-dev mailing list