diff mbox

coccinelle: add g_assert_cmp* to macro file

Message ID 1463563673-671-1-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini May 18, 2016, 9:27 a.m. UTC
This helps applying semantic patches to unit tests.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 scripts/cocci-macro-file.h | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Eric Blake May 18, 2016, 2:22 p.m. UTC | #1
On 05/18/2016 03:27 AM, Paolo Bonzini wrote:
> This helps applying semantic patches to unit tests.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  scripts/cocci-macro-file.h | 6 ++++++
>  1 file changed, 6 insertions(+)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/scripts/cocci-macro-file.h b/scripts/cocci-macro-file.h
> index eceb4be..9f2e72e 100644
> --- a/scripts/cocci-macro-file.h
> +++ b/scripts/cocci-macro-file.h
> @@ -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.

> +#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)
>
diff mbox

Patch

diff --git a/scripts/cocci-macro-file.h b/scripts/cocci-macro-file.h
index eceb4be..9f2e72e 100644
--- a/scripts/cocci-macro-file.h
+++ b/scripts/cocci-macro-file.h
@@ -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)