[Mesa-dev] [PATCH v2] egl/dri2: Fix GCC maybe-uninitialized warning.
Jan Vesely
jan.vesely at rutgers.edu
Wed Mar 25 16:15:03 PDT 2015
On Wed, 2015-03-25 at 18:55 -0400, Ilia Mirkin wrote:
> On Wed, Mar 25, 2015 at 6:51 PM, Jan Vesely <jan.vesely at rutgers.edu> wrote:
> > On Fri, 2015-03-06 at 23:54 -0800, Vinson Lee wrote:
> >> egl_dri2.c: In function ‘dri2_bind_tex_image’:
> >> egl_dri2.c:1240:4: warning: ‘format’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> >> (*dri2_dpy->tex_buffer->setTexBuffer2)(dri2_ctx->dri_context,
> >> ^
> >>
> >> Suggested-by: Ilia Mirkin <imirkin at alum.mit.edu>
> >> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> >> ---
> >> src/egl/drivers/dri2/egl_dri2.c | 6 ++++--
> >> 1 file changed, 4 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> >> index d503196..c5c475d 100644
> >> --- a/src/egl/drivers/dri2/egl_dri2.c
> >> +++ b/src/egl/drivers/dri2/egl_dri2.c
> >> @@ -1226,7 +1226,8 @@ dri2_bind_tex_image(_EGLDriver *drv,
> >> format = __DRI_TEXTURE_FORMAT_RGBA;
> >> break;
> >> default:
> >> - assert(0);
> >> + _eglError(EGL_BAD_SURFACE, "unrecognized format");
> >> + return EGL_FALSE;
> >
> > does using:
> > unreachable("unrecognized format");
> > instead of
> > assert(0);
> > fix the warning?
>
> unreachable is for *truly* unreachable code... it sounded like this
> was reachable with bad input.
maybe I misunderstood the situation.
since there is assert(0) I assumed it can never happen.
combination of assert(0) and return is very confusing:
either the code is reachable and should have a correct error path (in
which case there should not be assert(0)),
or the code is not reachable in which case unreachable does just fine
and you should not have the error path.
it looks to me that using assert and return just makes sure that the
error path is never run on debug build.
anyway, it was just a suggestion. I won't argue one way or another,
since I don't work with/understand those parts of the code.
regards,
jan
>
> >
> >> }
> >>
> >> switch (dri2_surf->base.TextureTarget) {
> >> @@ -1234,7 +1235,8 @@ dri2_bind_tex_image(_EGLDriver *drv,
> >> target = GL_TEXTURE_2D;
> >> break;
> >> default:
> >> - assert(0);
> >> + _eglError(EGL_BAD_SURFACE, "unrecognized target");
> >> + return EGL_FALSE;
> >> }
> >>
> >> (*dri2_dpy->tex_buffer->setTexBuffer2)(dri2_ctx->dri_context,
> >
> > --
> > Jan Vesely <jan.vesely at rutgers.edu>
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >
--
Jan Vesely <jan.vesely at rutgers.edu>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150325/3be69387/attachment.sig>
More information about the mesa-dev
mailing list