[PATCH weston 3/4] Moved the MIN() macro to the helper include.

Jon A. Cruz jonc at osg.samsung.com
Fri Jun 12 21:25:04 PDT 2015


Removed multiple definitions of the MIN() macro from existing
locations and unified with a single definition. Updated sources
to use the shared version.

Signed-off-by: Jon A. Cruz <jonc at osg.samsung.com>
---
 clients/nested.c      |  2 --
 clients/weston-info.c |  2 --
 clients/window.c      |  2 --
 desktop-shell/shell.c |  1 +
 shared/helpers.h      | 11 +++++++++++
 src/compositor.h      |  4 ----
 6 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/clients/nested.c b/clients/nested.c
index 12a4c0e..e8b1ccd 100644
--- a/clients/nested.c
+++ b/clients/nested.c
@@ -48,8 +48,6 @@
 #include "shared/helpers.h"
 #include "window.h"
 
-#define MIN(x,y) (((x) < (y)) ? (x) : (y))
-
 #ifndef EGL_WL_create_wayland_buffer_from_image
 #define EGL_WL_create_wayland_buffer_from_image 1
 
diff --git a/clients/weston-info.c b/clients/weston-info.c
index 480fd01..26f1a9b 100644
--- a/clients/weston-info.c
+++ b/clients/weston-info.c
@@ -35,8 +35,6 @@
 #include "shared/os-compatibility.h"
 #include "presentation_timing-client-protocol.h"
 
-#define MIN(x,y) (((x) < (y)) ? (x) : (y))
-
 typedef void (*print_info_t)(void *info);
 typedef void (*destroy_info_t)(void *info);
 
diff --git a/clients/window.c b/clients/window.c
index 3af660b..b6dab0a 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -5149,8 +5149,6 @@ fini_xkb(struct input *input)
 	xkb_keymap_unref(input->xkb.keymap);
 }
 
-#define MIN(a,b) ((a) < (b) ? a : b)
-
 static void
 display_add_input(struct display *d, uint32_t id)
 {
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index 89d730c..c4d0fc5 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -38,6 +38,7 @@
 #include "desktop-shell-server-protocol.h"
 #include "workspaces-server-protocol.h"
 #include "shared/config-parser.h"
+#include "shared/helpers.h"
 #include "xdg-shell-server-protocol.h"
 
 #define DEFAULT_NUM_WORKSPACES 1
diff --git a/shared/helpers.h b/shared/helpers.h
index 2e4ae44..c56b4d0 100644
--- a/shared/helpers.h
+++ b/shared/helpers.h
@@ -42,6 +42,17 @@ extern "C" {
 #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
 #endif
 
+/**
+ * Returns the smaller of two values.
+ *
+ * @param x the first item to compare.
+ * @param y the second item to compare.
+ * @return the value that evaluates to lesser than the other.
+ */
+#ifndef MIN
+#define MIN(x,y) (((x) < (y)) ? (x) : (y))
+#endif
+
 #ifdef  __cplusplus
 }
 #endif
diff --git a/src/compositor.h b/src/compositor.h
index 54cda7a..4532d36 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -42,10 +42,6 @@ extern "C" {
 #include "zalloc.h"
 #include "timeline-object.h"
 
-#ifndef MIN
-#define MIN(x,y) (((x) < (y)) ? (x) : (y))
-#endif
-
 #define container_of(ptr, type, member) ({				\
 	const __typeof__( ((type *)0)->member ) *__mptr = (ptr);	\
 	(type *)( (char *)__mptr - offsetof(type,member) );})
-- 
2.1.0



More information about the wayland-devel mailing list