[Mesa-dev] [PATCH] dri: use 'bool' instead of 'int' for boolean variables
Eric Engestrom
eric.engestrom at imgtec.com
Fri Aug 5 12:34:14 UTC 2016
On Wed, Aug 03, 2016 at 01:22:35PM +0200, Jan Ziak wrote:
> Signed-off-by: Jan Ziak (http://atom-symbol.net) <0xe2.0x9a.0x9b at gmail.com>
> ---
It is customary to put [PATCH vN] in the subject to keep track of which
version is current, as well as to add a description of what changed
since the previous version, here, after the "---" (so it doesn't appear
in the final commit message, unless one thinks something should be in
the commit message).
As it stands, I have no idea why you sent the patch again :)
Cheers,
Eric
> src/egl/drivers/dri2/egl_dri2.h | 19 ++++++++++---------
> src/egl/drivers/dri2/platform_drm.c | 6 +++---
> src/egl/drivers/dri2/platform_wayland.c | 20 ++++++++++----------
> src/egl/drivers/dri2/platform_x11.c | 4 ++--
> src/gallium/auxiliary/vl/vl_winsys_dri3.c | 3 ++-
> src/glx/dri3_priv.h | 5 +++--
> src/loader/loader.c | 19 ++++++++++---------
> src/loader/loader.h | 4 +++-
> 8 files changed, 43 insertions(+), 37 deletions(-)
>
> diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
> index 4577875..f4e6be8 100644
> --- a/src/egl/drivers/dri2/egl_dri2.h
> +++ b/src/egl/drivers/dri2/egl_dri2.h
> @@ -28,6 +28,7 @@
> #ifndef EGL_DRI2_INCLUDED
> #define EGL_DRI2_INCLUDED
>
> +#include <stdbool.h>
> #include <stdint.h>
>
> #ifdef HAVE_X11_PLATFORM
> @@ -160,7 +161,7 @@ struct dri2_egl_display
> int dri2_major;
> int dri2_minor;
> __DRIscreen *dri_screen;
> - int own_dri_screen;
> + bool own_dri_screen;
> const __DRIconfig **driver_configs;
> void *driver;
> const __DRIcoreExtension *core;
> @@ -181,8 +182,8 @@ struct dri2_egl_display
> * dri2_make_current (tracks if there are active contexts/surfaces). */
> int ref_count;
>
> - int own_device;
> - int invalidate_available;
> + bool own_device;
> + bool invalidate_available;
> int min_swap_interval;
> int max_swap_interval;
> int default_swap_interval;
> @@ -201,7 +202,7 @@ struct dri2_egl_display
> #ifdef HAVE_X11_PLATFORM
> xcb_connection_t *conn;
> int screen;
> - int swap_available;
> + bool swap_available;
> #ifdef HAVE_DRI3
> struct loader_dri3_extensions loader_dri3_ext;
> #endif
> @@ -214,13 +215,13 @@ struct dri2_egl_display
> struct wl_drm *wl_drm;
> struct wl_shm *wl_shm;
> struct wl_event_queue *wl_queue;
> - int authenticated;
> + bool authenticated;
> int formats;
> uint32_t capabilities;
> #endif
>
> - int is_render_node;
> - int is_different_gpu;
> + bool is_render_node;
> + bool is_different_gpu;
> };
>
> struct dri2_egl_context
> @@ -244,7 +245,7 @@ struct dri2_egl_surface
> __DRIdrawable *dri_drawable;
> __DRIbuffer buffers[5];
> int buffer_count;
> - int have_fake_front;
> + bool have_fake_front;
>
> #ifdef HAVE_X11_PLATFORM
> xcb_drawable_t drawable;
> @@ -282,7 +283,7 @@ struct dri2_egl_surface
> #ifdef HAVE_DRM_PLATFORM
> struct gbm_bo *bo;
> #endif
> - int locked;
> + bool locked;
> int age;
> } color_buffers[4], *back, *current;
> #endif
> diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
> index 9373496..06c06ab 100644
> --- a/src/egl/drivers/dri2/platform_drm.c
> +++ b/src/egl/drivers/dri2/platform_drm.c
> @@ -56,7 +56,7 @@ lock_front_buffer(struct gbm_surface *_surf)
> bo = dri2_surf->current->bo;
>
> if (device->dri2) {
> - dri2_surf->current->locked = 1;
> + dri2_surf->current->locked = true;
> dri2_surf->current = NULL;
> }
>
> @@ -72,7 +72,7 @@ release_buffer(struct gbm_surface *_surf, struct gbm_bo *bo)
>
> for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
> if (dri2_surf->color_buffers[i].bo == bo) {
> - dri2_surf->color_buffers[i].locked = 0;
> + dri2_surf->color_buffers[i].locked = false;
> }
> }
> }
> @@ -621,7 +621,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
> fd = loader_open_device(buf);
> if (fd < 0)
> fd = loader_open_device("/dev/dri/card0");
> - dri2_dpy->own_device = 1;
> + dri2_dpy->own_device = true;
> gbm = gbm_create_device(fd);
> if (gbm == NULL)
> goto cleanup;
> diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
> index e714e44..675ca2b 100644
> --- a/src/egl/drivers/dri2/platform_wayland.c
> +++ b/src/egl/drivers/dri2/platform_wayland.c
> @@ -101,7 +101,7 @@ wl_buffer_release(void *data, struct wl_buffer *buffer)
> return;
> }
>
> - dri2_surf->color_buffers[i].locked = 0;
> + dri2_surf->color_buffers[i].locked = false;
> }
>
> static const struct wl_buffer_listener wl_buffer_listener = {
> @@ -288,7 +288,7 @@ dri2_wl_release_buffers(struct dri2_egl_surface *dri2_surf)
> dri2_surf->color_buffers[i].dri_image = NULL;
> dri2_surf->color_buffers[i].linear_copy = NULL;
> dri2_surf->color_buffers[i].data = NULL;
> - dri2_surf->color_buffers[i].locked = 0;
> + dri2_surf->color_buffers[i].locked = false;
> }
>
> if (dri2_dpy->dri2) {
> @@ -382,7 +382,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
> if (dri2_surf->back->dri_image == NULL)
> return -1;
>
> - dri2_surf->back->locked = 1;
> + dri2_surf->back->locked = true;
>
> return 0;
> }
> @@ -883,7 +883,7 @@ dri2_wl_authenticate(_EGLDisplay *disp, uint32_t id)
> "authenticate for render-nodes");
> return 0;
> }
> - dri2_dpy->authenticated = 0;
> + dri2_dpy->authenticated = false;
>
> wl_drm_authenticate(dri2_dpy->wl_drm, id);
> if (roundtrip(dri2_dpy) < 0)
> @@ -893,7 +893,7 @@ dri2_wl_authenticate(_EGLDisplay *disp, uint32_t id)
> ret = -1;
>
> /* reset authenticated */
> - dri2_dpy->authenticated = 1;
> + dri2_dpy->authenticated = true;
>
> return ret;
> }
> @@ -916,7 +916,7 @@ drm_handle_device(void *data, struct wl_drm *drm, const char *device)
> }
>
> if (drmGetNodeTypeFromFd(dri2_dpy->fd) == DRM_NODE_RENDER) {
> - dri2_dpy->authenticated = 1;
> + dri2_dpy->authenticated = true;
> } else {
> drmGetMagic(dri2_dpy->fd, &magic);
> wl_drm_authenticate(dri2_dpy->wl_drm, magic);
> @@ -954,7 +954,7 @@ drm_handle_authenticated(void *data, struct wl_drm *drm)
> {
> struct dri2_egl_display *dri2_dpy = data;
>
> - dri2_dpy->authenticated = 1;
> + dri2_dpy->authenticated = true;
> }
>
> static const struct wl_drm_listener drm_listener = {
> @@ -1086,7 +1086,7 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp)
> dri2_dpy->wl_dpy = wl_display_connect(NULL);
> if (dri2_dpy->wl_dpy == NULL)
> goto cleanup_dpy;
> - dri2_dpy->own_device = 1;
> + dri2_dpy->own_device = true;
> } else {
> dri2_dpy->wl_dpy = disp->PlatformDisplay;
> }
> @@ -1472,7 +1472,7 @@ swrast_update_buffers(struct dri2_egl_surface *dri2_surf)
> return -1;
> }
>
> - dri2_surf->back->locked = 1;
> + dri2_surf->back->locked = true;
>
> /* If we have an extra unlocked buffer at this point, we had to do triple
> * buffering for a while, but now can go back to just double buffering.
> @@ -1812,7 +1812,7 @@ dri2_initialize_wayland_swrast(_EGLDriver *drv, _EGLDisplay *disp)
> dri2_dpy->wl_dpy = wl_display_connect(NULL);
> if (dri2_dpy->wl_dpy == NULL)
> goto cleanup_dpy;
> - dri2_dpy->own_device = 1;
> + dri2_dpy->own_device = true;
> } else {
> dri2_dpy->wl_dpy = disp->PlatformDisplay;
> }
> diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
> index c0a4005..1663c1f 100644
> --- a/src/egl/drivers/dri2/platform_x11.c
> +++ b/src/egl/drivers/dri2/platform_x11.c
> @@ -422,7 +422,7 @@ dri2_x11_process_buffers(struct dri2_egl_surface *dri2_surf,
> unsigned i;
>
> dri2_surf->buffer_count = count;
> - dri2_surf->have_fake_front = 0;
> + dri2_surf->have_fake_front = false;
>
> /* This assumes the DRI2 buffer attachment tokens matches the
> * __DRIbuffer tokens. */
> @@ -439,7 +439,7 @@ dri2_x11_process_buffers(struct dri2_egl_surface *dri2_surf,
> * Note that EGL doesn't require that several clients rendering
> * to the same window must see the same aux buffers. */
> if (dri2_surf->buffers[i].attachment == __DRI_BUFFER_FAKE_FRONT_LEFT)
> - dri2_surf->have_fake_front = 1;
> + dri2_surf->have_fake_front = true;
> }
>
> if (dri2_surf->region != XCB_NONE)
> diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
> index 493e645..7cb6c18 100644
> --- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
> +++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
> @@ -25,6 +25,7 @@
> *
> **************************************************************************/
>
> +#include <stdbool.h>
> #include <fcntl.h>
>
> #include <X11/Xlib-xcb.h>
> @@ -627,7 +628,7 @@ vl_dri3_screen_create(Display *display, int screen)
> xcb_dri3_open_reply_t *open_reply;
> xcb_get_geometry_cookie_t geom_cookie;
> xcb_get_geometry_reply_t *geom_reply;
> - int is_different_gpu;
> + bool is_different_gpu;
> int fd;
>
> assert(display);
> diff --git a/src/glx/dri3_priv.h b/src/glx/dri3_priv.h
> index 0822377..bfb0786 100644
> --- a/src/glx/dri3_priv.h
> +++ b/src/glx/dri3_priv.h
> @@ -54,6 +54,7 @@
> * Kristian Høgsberg (krh at redhat.com)
> */
>
> +#include <stdbool.h>
> #include <xcb/xcb.h>
> #include <xcb/dri3.h>
> #include <xcb/present.h>
> @@ -101,7 +102,7 @@ struct dri3_screen {
>
> void *driver;
> int fd;
> - int is_different_gpu;
> + bool is_different_gpu;
>
> int show_fps_interval;
>
> diff --git a/src/loader/loader.c b/src/loader/loader.c
> index 56ffc5d..18e712a 100644
> --- a/src/loader/loader.c
> +++ b/src/loader/loader.c
> @@ -356,7 +356,7 @@ DRI_CONF_BEGIN
> DRI_CONF_END;
> #endif
>
> -int loader_get_user_preferred_fd(int default_fd, int *different_device)
> +int loader_get_user_preferred_fd(int default_fd, bool *different_device)
> {
> struct udev *udev;
> #ifdef USE_DRICONF
> @@ -365,7 +365,8 @@ int loader_get_user_preferred_fd(int default_fd, int *different_device)
> #endif
> const char *dri_prime = getenv("DRI_PRIME");
> char *prime = NULL;
> - int is_different_device = 0, fd = default_fd;
> + bool is_different_device = false;
> + int fd = default_fd;
> char *default_device_id_path_tag;
> char *device_name = NULL;
> char another_tag = 0;
> @@ -386,7 +387,7 @@ int loader_get_user_preferred_fd(int default_fd, int *different_device)
> #endif
>
> if (prime == NULL) {
> - *different_device = 0;
> + *different_device = false;
> return default_fd;
> }
>
> @@ -398,7 +399,7 @@ int loader_get_user_preferred_fd(int default_fd, int *different_device)
> if (!default_device_id_path_tag)
> goto udev_clean;
>
> - is_different_device = 1;
> + is_different_device = true;
> /* two format are supported:
> * "1": choose any other card than the card used by default.
> * id_path_tag: (for example "pci-0000_02_00_0") choose the card
> @@ -411,13 +412,13 @@ int loader_get_user_preferred_fd(int default_fd, int *different_device)
> another_tag = 1;
> } else if (!strcmp(default_device_id_path_tag, prime))
> /* we are to get a new fd (render-node) of the same device */
> - is_different_device = 0;
> + is_different_device = false;
>
> device_name = get_render_node_from_id_path_tag(udev,
> prime,
> another_tag);
> if (device_name == NULL) {
> - is_different_device = 0;
> + is_different_device = false;
> goto default_device_clean;
> }
>
> @@ -426,7 +427,7 @@ int loader_get_user_preferred_fd(int default_fd, int *different_device)
> close(default_fd);
> } else {
> fd = default_fd;
> - is_different_device = 0;
> + is_different_device = false;
> }
> free(device_name);
>
> @@ -441,9 +442,9 @@ int loader_get_user_preferred_fd(int default_fd, int *different_device)
> return fd;
> }
> #else
> -int loader_get_user_preferred_fd(int default_fd, int *different_device)
> +int loader_get_user_preferred_fd(int default_fd, bool *different_device)
> {
> - *different_device = 0;
> + *different_device = false;
> return default_fd;
> }
> #endif
> diff --git a/src/loader/loader.h b/src/loader/loader.h
> index 055dc78..cead7a3 100644
> --- a/src/loader/loader.h
> +++ b/src/loader/loader.h
> @@ -27,6 +27,8 @@
> #ifndef LOADER_H
> #define LOADER_H
>
> +#include <stdbool.h>
> +
> #ifdef __cplusplus
> extern "C" {
> #endif
> @@ -54,7 +56,7 @@ loader_get_device_name_for_fd(int fd);
> */
>
> int
> -loader_get_user_preferred_fd(int default_fd, int *different_device);
> +loader_get_user_preferred_fd(int default_fd, bool *different_device);
>
> /* for logging.. keep this aligned with egllog.h so we can just use
> * _eglLog directly.
More information about the mesa-dev
mailing list