2015-09-10 21:49 GMT+08:00 Emil Velikov <emil.l.veli...@gmail.com>: > Currently the check was incorrect as it did not consider the (unlikely) > case of fd == 0. In order to fix this we should first correctly > initialize it to -1, as the swrast implementations leave it set to zero > (props to calloc()).
Reviewed-by: Boyan Ding <boyan.j.d...@gmail.com> > > Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com> > --- > > Noticed while checking the code wrt patch 1/2. > > -Emil > > src/egl/drivers/dri2/egl_dri2.c | 2 +- > src/egl/drivers/dri2/platform_wayland.c | 1 + > src/egl/drivers/dri2/platform_x11.c | 1 + > 3 files changed, 3 insertions(+), 1 deletion(-) > > diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c > index eb56113..1740ee3 100644 > --- a/src/egl/drivers/dri2/egl_dri2.c > +++ b/src/egl/drivers/dri2/egl_dri2.c > @@ -786,7 +786,7 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp) > > if (dri2_dpy->own_dri_screen) > dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen); > - if (dri2_dpy->fd) > + if (dri2_dpy->fd >= 0) > close(dri2_dpy->fd); > if (dri2_dpy->driver) > dlclose(dri2_dpy->driver); > diff --git a/src/egl/drivers/dri2/platform_wayland.c > b/src/egl/drivers/dri2/platform_wayland.c > index dbc64ba..6cf5461 100644 > --- a/src/egl/drivers/dri2/platform_wayland.c > +++ b/src/egl/drivers/dri2/platform_wayland.c > @@ -1804,6 +1804,7 @@ dri2_initialize_wayland_swrast(_EGLDriver *drv, > _EGLDisplay *disp) > if (roundtrip(dri2_dpy) < 0 || dri2_dpy->formats == 0) > goto cleanup_shm; > > + dri2_dpy->fd = -1; > dri2_dpy->driver_name = strdup("swrast"); > if (!dri2_load_driver_swrast(disp)) > goto cleanup_shm; > diff --git a/src/egl/drivers/dri2/platform_x11.c > b/src/egl/drivers/dri2/platform_x11.c > index bf7d2be..7991fc2 100644 > --- a/src/egl/drivers/dri2/platform_x11.c > +++ b/src/egl/drivers/dri2/platform_x11.c > @@ -1161,6 +1161,7 @@ dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay > *disp) > * Every hardware driver_name is set using strdup. Doing the same in > * here will allow is to simply free the memory at dri2_terminate(). > */ > + dri2_dpy->fd = -1; > dri2_dpy->driver_name = strdup("swrast"); > if (!dri2_load_driver_swrast(disp)) > goto cleanup_conn; > -- > 2.5.0 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev