Skip to contentSkip to conversation

coccinelle: add g_assert_cmp* to macro file

PATCH In review Paolo Bonzini 2 participants 2 messages May 18, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 coccinelle: add g_assert_cmp* to macro file

This helps applying semantic patches to unit tests.

---
 scripts/cocci-macro-file.h | 6 ++++++
 1 file changed, 6 insertions(+)
scripts/cocci-macro-file.h +6 -0
index eceb4be..9f2e72e 100644
@@ -117,3 +117,9 @@ struct {                                                                \
         type *tqe_next;       /* next element */                        \
         type **tqe_prev;      /* address of previous next element */    \
 }
+
+/* From glib */
+#define g_assert_cmpint(a, op, b)   g_assert(a op b)
+#define g_assert_cmpuint(a, op, b)   g_assert(a op b)
+#define g_assert_cmphex(a, op, b)   g_assert(a op b)
+#define g_assert_cmpstr(a, op, b)   g_assert(strcmp(a, b) op 0)
Signature · 1 line
2.5.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Paolo Bonzini

This helps applying semantic patches to unit tests.

---
 scripts/cocci-macro-file.h | 6 ++++++
 1 file changed, 6 insertions(+)

scripts/cocci-macro-file.h struct { \ · line 123

Quoted 13 lines
scripts/cocci-macro-file.h +4 -0
index eceb4be..9f2e72e 100644
@@ -117,3 +117,9 @@ struct {                                                                \
         type *tqe_next;       /* next element */                        \
         type **tqe_prev;      /* address of previous next element */    \
 }
+
+/* From glib */
+#define g_assert_cmpint(a, op, b)   g_assert(a op b)
+#define g_assert_cmpuint(a, op, b)   g_assert(a op b)

Odd indentation, compared to the other lines.

Quoted 3 lines
scripts/cocci-macro-file.h +2 -0
+#define g_assert_cmphex(a, op, b)   g_assert(a op b)
+#define g_assert_cmpstr(a, op, b)   g_assert(strcmp(a, b) op 0)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org