[Spice-devel] [PATCH 08/12] common, server: use ASSERT from spice_common.h

Christophe Fergeau cfergeau at redhat.com
Fri Apr 22 09:43:06 PDT 2011


spice_common.h provides an ASSERT macro, no need to duplicate it
in many places. For now client/debug.h keeps its own copy since
debug.h and spice_common.h have clashes on other macros which are
trickier to unify.
---
 common/canvas_base.c    |    7 -------
 common/canvas_utils.c   |    8 --------
 common/glc.c            |    2 --
 common/pixman_utils.c   |    8 +-------
 common/region.c         |    5 -----
 common/rop3.c           |    8 +-------
 common/spice_common.h   |    1 +
 server/reds_gl_canvas.c |    2 ++
 server/reds_sw_canvas.c |    2 ++
 9 files changed, 7 insertions(+), 36 deletions(-)

diff --git a/common/canvas_base.c b/common/canvas_base.c
index 272c7e8..a8db367 100644
--- a/common/canvas_base.c
+++ b/common/canvas_base.c
@@ -50,13 +50,6 @@
 }
 #endif
 
-#ifndef ASSERT
-#define ASSERT(x) if (!(x)) {                               \
-    printf("%s: ASSERT %s failed\n", __FUNCTION__, #x);     \
-    abort();                                                \
-}
-#endif
-
 #ifndef WARN
 #define WARN(x) printf("warning: %s\n", x)
 #endif
diff --git a/common/canvas_utils.c b/common/canvas_utils.c
index 1b81d54..d861800 100644
--- a/common/canvas_utils.c
+++ b/common/canvas_utils.c
@@ -33,14 +33,6 @@
 extern int gdi_handlers;
 #endif
 
-#ifndef ASSERT
-#define ASSERT(x) if (!(x)) {                               \
-    printf("%s: ASSERT %s failed\n", __FUNCTION__, #x);     \
-    abort();                                                \
-}
-#endif
-
-
 #ifndef CANVAS_ERROR
 #define CANVAS_ERROR(format, ...) {                             \
     printf("%s: " format "\n", __FUNCTION__, ## __VA_ARGS__);   \
diff --git a/common/glc.c b/common/glc.c
index d90e383..0396fc9 100644
--- a/common/glc.c
+++ b/common/glc.c
@@ -40,8 +40,6 @@
 #include "glc.h"
 #include "gl_utils.h"
 
-#define ASSERT(x) if (!(x)) {printf("%s: assert failed %s\n", __FUNCTION__, #x); abort();}
-
 #define WARN_ONCE(x) {      \
     static int warn = TRUE; \
     if (warn) {             \
diff --git a/common/pixman_utils.c b/common/pixman_utils.c
index e876fe6..99a3005 100644
--- a/common/pixman_utils.c
+++ b/common/pixman_utils.c
@@ -20,6 +20,7 @@
 #endif
 
 #include "pixman_utils.h"
+#include "spice_common.h"
 #include <spice/macros.h>
 
 #include <stdlib.h>
@@ -27,13 +28,6 @@
 #include <stdio.h>
 #include "mem.h"
 
-#ifndef ASSERT
-#define ASSERT(x) if (!(x)) {                               \
-    printf("%s: ASSERT %s failed\n", __FUNCTION__, #x);     \
-    abort();                                                \
-}
-#endif
-
 #ifndef PANIC
 #define PANIC(str) {                                \
     printf("%s: panic: %s", __FUNCTION__, str);     \
diff --git a/common/region.c b/common/region.c
index 0e1613c..10a6e62 100644
--- a/common/region.c
+++ b/common/region.c
@@ -28,11 +28,6 @@
 #include "rect.h"
 #include "mem.h"
 
-#define ASSERT(x) if (!(x)) {                               \
-    printf("%s: ASSERT %s failed\n", __FUNCTION__, #x);     \
-    abort();                                                \
-}
-
 /*  true iff two Boxes overlap */
 #define EXTENTCHECK(r1, r2)        \
     (!( ((r1)->x2 <= (r2)->x1)  || \
diff --git a/common/rop3.c b/common/rop3.c
index 53e8a6d..1ce2cd2 100644
--- a/common/rop3.c
+++ b/common/rop3.c
@@ -22,13 +22,7 @@
 #include <stdio.h>
 
 #include "rop3.h"
-
-#ifndef ASSERT
-#define ASSERT(x) if (!(x)) {                               \
-    printf("%s: ASSERT %s failed\n", __FUNCTION__, #x);     \
-    abort();                                                \
-}
-#endif
+#include "spice_common.h"
 
 #ifndef WARN
 #define WARN(x) printf("warning: %s\n", x)
diff --git a/common/spice_common.h b/common/spice_common.h
index 75ebda7..430c8af 100644
--- a/common/spice_common.h
+++ b/common/spice_common.h
@@ -19,6 +19,7 @@
 #define H_SPICE_COMMON
 
 #include <stdio.h>
+#include <stdint.h>
 #include <time.h>
 #include <stdlib.h>
 
diff --git a/server/reds_gl_canvas.c b/server/reds_gl_canvas.c
index bf5244f..deec440 100644
--- a/server/reds_gl_canvas.c
+++ b/server/reds_gl_canvas.c
@@ -18,6 +18,8 @@
 #include <config.h>
 #endif
 
+#include "spice_common.h"
+
 #include "reds_gl_canvas.h"
 #define SPICE_CANVAS_INTERNAL
 #define SW_CANVAS_IMAGE_CACHE
diff --git a/server/reds_sw_canvas.c b/server/reds_sw_canvas.c
index 6df63e6..43e086d 100644
--- a/server/reds_sw_canvas.c
+++ b/server/reds_sw_canvas.c
@@ -18,6 +18,8 @@
 #include <config.h>
 #endif
 
+#include "spice_common.h"
+
 #include "reds_sw_canvas.h"
 #define SPICE_CANVAS_INTERNAL
 #define SW_CANVAS_IMAGE_CACHE
-- 
1.7.4.4



More information about the Spice-devel mailing list