panfrost: assert(0) -> unreachable for some switch
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Thu, 16 May 2019 23:42:33 +0000 (23:42 +0000)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Thu, 16 May 2019 23:42:33 +0000 (23:42 +0000)
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_format.c

index c4bb57d782eb14335987b75e5a4f9c4ea49bcf5d..635d0cfa44aa9f9e2cfc03c3c93e9cb6742d7fef 100644 (file)
@@ -438,8 +438,7 @@ translate_tex_wrap(enum pipe_tex_wrap w)
                 return MALI_WRAP_MIRRORED_REPEAT;
 
         default:
-                assert(0);
-                return 0;
+                unreachable("Invalid wrap");
         }
 }
 
@@ -454,8 +453,7 @@ translate_tex_filter(enum pipe_tex_filter f)
                 return MALI_LINEAR;
 
         default:
-                assert(0);
-                return 0;
+                unreachable("Invalid filter");
         }
 }
 
@@ -492,10 +490,10 @@ panfrost_translate_compare_func(enum pipe_compare_func in)
 
         case PIPE_FUNC_ALWAYS:
                 return MALI_FUNC_ALWAYS;
-        }
 
-        assert (0);
-        return 0; /* Unreachable */
+        default:
+                unreachable("Invalid func");
+        }
 }
 
 static unsigned
@@ -525,10 +523,10 @@ panfrost_translate_alt_compare_func(enum pipe_compare_func in)
 
         case PIPE_FUNC_ALWAYS:
                 return MALI_ALT_FUNC_ALWAYS;
-        }
 
-        assert (0);
-        return 0; /* Unreachable */
+        default:
+                unreachable("Invalid alt func");
+        }
 }
 
 static unsigned
@@ -558,10 +556,10 @@ panfrost_translate_stencil_op(enum pipe_stencil_op in)
 
         case PIPE_STENCIL_OP_INVERT:
                 return MALI_STENCIL_INVERT;
-        }
 
-        assert (0);
-        return 0; /* Unreachable */
+        default:
+                unreachable("Invalid stencil op");
+        }
 }
 
 static void
@@ -1200,8 +1198,7 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data)
                         break;
 
                 default:
-                        DBG("Unknown shader stage %d in uniform upload\n", i);
-                        assert(0);
+                        unreachable("Invalid shader stage\n");
                 }
 
                 /* Also attach the same buffer as a UBO for extended access */
@@ -1432,9 +1429,7 @@ g2m_draw_mode(enum pipe_prim_type mode)
                 DEFINE_CASE(POLYGON);
 
         default:
-                DBG("Illegal draw mode %d\n", mode);
-                assert(0);
-                return MALI_LINE_LOOP;
+                unreachable("Invalid draw mode");
         }
 }
 
@@ -1454,9 +1449,7 @@ panfrost_translate_index_size(unsigned size)
                 return MALI_DRAW_INDEXED_UINT32;
 
         default:
-                DBG("Unknown index size %d\n", size);
-                assert(0);
-                return 0;
+                unreachable("Invalid index size");
         }
 }
 
index a61d7b19a55a4342071d82a1884b7b4ac6a839ee..5f75a065861b0526e26e7ad2b4dca86524d529a1 100644 (file)
@@ -53,8 +53,7 @@ panfrost_translate_swizzle(enum pipe_swizzle s)
                 return MALI_CHANNEL_ONE;
 
         default:
-                assert(0);
-                return 0;
+                unreachable("INvalid swizzle");
         }
 }
 
@@ -100,9 +99,7 @@ panfrost_translate_channel_width(unsigned size)
                 case 32:
                         return MALI_CHANNEL_32;
                 default:
-                        fprintf(stderr, "Unknown width %d\n", size);
-                        assert(0);
-                        return 0;
+                        unreachable("Invalid width");
         }
 }
 
@@ -128,8 +125,7 @@ panfrost_translate_channel_type(unsigned type, unsigned size, bool norm) {
                         }
 
                 default:
-                        assert(0);
-                        return 0;
+                        unreachable("Invalid type");
         }
 }
 
@@ -232,9 +228,7 @@ panfrost_find_format(const struct util_format_description *desc)
                         break;
 
                 default:
-                        fprintf(stderr, "Unknown format type in %s\n", desc->name);
-                        assert(0);
-                        break;
+                        unreachable("Invalid format type");
         }
 
         return (enum mali_format) format;