[Mesa-dev] [PATCH 01/18] t_dd_dmatmp: Replace fprintf with unreachable
Iago Toral
itoral at igalia.com
Tue Oct 6 00:35:39 PDT 2015
On Wed, 2015-09-30 at 13:57 -0700, Ian Romanick wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> From http://lists.freedesktop.org/archives/mesa-dev/2015-May/084883.html:
>
> "There are no real error cases here, just dead code.
> validate_render() is supposed to make sure we never call these
> functions if the code can't actually render the primitives. The
> fprintf()+return branches should really just contain assert(0) or
> equivalent."
>
> I also rearranged the if-else-block in render_quad_strip_verts to look
> more like the other functions. A future patch is going to change a
> bunch of that code anyway.
>
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> Suggested-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
> src/mesa/tnl_dd/t_dd_dmatmp.h | 18 ++++++------------
> 1 file changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/src/mesa/tnl_dd/t_dd_dmatmp.h b/src/mesa/tnl_dd/t_dd_dmatmp.h
> index e7e19a0..415c3df 100644
> --- a/src/mesa/tnl_dd/t_dd_dmatmp.h
> +++ b/src/mesa/tnl_dd/t_dd_dmatmp.h
> @@ -85,8 +85,7 @@ static void TAG(render_points_verts)(struct gl_context *ctx,
> currentsz = dmasz;
> }
> } else {
> - fprintf(stderr, "%s - cannot draw primitive\n", __func__);
> - return;
> + unreachable("Cannot draw primitive");
Since the reason this is unreachable is because a previous call to
validate_render should have prevented this, maybe it would be better to
modify the message to mention that explicitly, something like:
unreachable("Cannot draw primitive; validate_render should have
prevented this");
> }
> }
>
> @@ -319,8 +318,7 @@ static void TAG(render_poly_verts)(struct gl_context *ctx,
> } else if (ctx->Light.ShadeModel == GL_SMOOTH) {
> TAG(render_tri_fan_verts)( ctx, start, count, flags );
> } else {
> - fprintf(stderr, "%s - cannot draw primitive\n", __func__);
> - return;
> + unreachable("Cannot draw primitive");
Same here
> }
> }
>
> @@ -331,14 +329,8 @@ static void TAG(render_quad_strip_verts)(struct gl_context *ctx,
> {
> GLuint j, nr;
>
> - if (ctx->Light.ShadeModel == GL_FLAT &&
> - TNL_CONTEXT(ctx)->vb.AttribPtr[_TNL_ATTRIB_COLOR0]->stride) {
> - /* Vertices won't fit in a single buffer or elts not available - should
> - * never happen.
> - */
> - fprintf(stderr, "%s - cannot draw primitive\n", __func__);
> - return;
Same here
> - } else {
> + if (ctx->Light.ShadeModel != GL_FLAT ||
> + !TNL_CONTEXT(ctx)->vb.AttribPtr[_TNL_ATTRIB_COLOR0]->stride) {
> LOCAL_VARS;
> const unsigned dmasz = GET_SUBSEQUENT_VB_MAX_VERTS() & ~1;
> unsigned currentsz;
> @@ -364,6 +356,8 @@ static void TAG(render_quad_strip_verts)(struct gl_context *ctx,
> }
>
> FLUSH();
> + } else {
> + unreachable("Cannot draw primitive");
Same here
Otherwise:
Reviewed-by: Iago Toral Quiroga <itoral at igalia.com>
> }
> }
>
More information about the mesa-dev
mailing list