[Mesa-dev] [PATCH] dri: use 'bool' instead 'int' for boolean variables

Jan Ziak 0xe2.0x9a.0x9b at gmail.com
Sun Jul 31 15:49:02 UTC 2016


Signed-off-by: Jan Ziak (http://atom-symbol.net) <0xe2.0x9a.0x9b at gmail.com>
---
 src/egl/drivers/dri2/egl_dri2.h            | 19 ++++++++++---------
 src/gallium/auxiliary/vl/vl_winsys_dri3.c  |  2 +-
 src/glx/dri3_glx.c                         |  1 +
 src/glx/dri3_priv.h                        |  4 ++--
 src/loader/loader.c                        |  7 ++++---
 src/loader/loader.h                        |  4 +++-
 6 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 4577875..e406443 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/gallium/auxiliary/vl/vl_winsys_dri3.c b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
index 493e645..54a94e8 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -627,7 +627,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_glx.c b/src/glx/dri3_glx.c
index ff16fef..b3c39b1 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -989,6 +989,7 @@ dri3_create_display(Display * dpy)
       free(error);
       goto no_extension;
    }
+   pdp->hasPresent = true;
    pdp->presentMajor = present_reply->major_version;
    pdp->presentMinor = present_reply->minor_version;
    free(present_reply);
diff --git a/src/glx/dri3_priv.h b/src/glx/dri3_priv.h
index 0822377..b4bd694 100644
--- a/src/glx/dri3_priv.h
+++ b/src/glx/dri3_priv.h
@@ -78,7 +78,7 @@ struct dri3_display
    int dri3Minor;
 
    /* Present bits */
-   int hasPresent;
+   bool hasPresent;
    int presentMajor;
    int presentMinor;
 };
@@ -101,7 +101,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..a3b75c7 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 = 0;
+   int fd = default_fd;
    char *default_device_id_path_tag;
    char *device_name = NULL;
    char another_tag = 0;
@@ -441,7 +442,7 @@ 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;
    return default_fd;
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