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

Giuseppe Bilotta giuseppe.bilotta at gmail.com
Sat Apr 22 21:59:32 UTC 2017


v2: simply add an assert(0) in args_match()'s allegedly impossible case, to be
    revisited for promotion to unreachable() after some time, as suggested by
    Nicolai

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

diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index aac9de78ca..3ba37810eb 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,9 @@ static GLboolean args_match( const struct state_key *key, GLuint unit )
 	    return GL_FALSE;
 	 }
 	 break;
-      default: 
-	 return GL_FALSE;	/* impossible */
+      default:
+	 assert(0);
+	 return GL_FALSE; /* impossible */
       }
    }
 
@@ -579,9 +577,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