X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Foptional.h;h=53215b0315e299695e03ec67dc49890176707cd4;hp=aee5fcc5ec911d9d17e97218632767348f827cb8;hb=bc2dc8d464c34ad5a51ed46e46c6fc98a5bbf3fd;hpb=a1298db6cf0b806e968d9baa6da08ab78caf460b diff --git a/src/common/optional.h b/src/common/optional.h index aee5fcc5e..53215b031 100644 --- a/src/common/optional.h +++ b/src/common/optional.h @@ -73,8 +73,8 @@ */ #define LTTNG_OPTIONAL_GET(optional) \ ({ \ - assert(optional.is_set); \ - optional.value; \ + assert((optional).is_set); \ + (optional).value; \ }) /* @@ -86,12 +86,16 @@ #define LTTNG_OPTIONAL_INIT { .is_set = 0 } /* Set the value of an optional field. */ -#define LTTNG_OPTIONAL_SET(field_ptr, val) \ - (field_ptr)->value = val; \ - (field_ptr)->is_set = 1; +#define LTTNG_OPTIONAL_SET(field_ptr, val) \ + do { \ + (field_ptr)->value = (val); \ + (field_ptr)->is_set = 1; \ + } while (0) /* Put an optional field in the "unset" (NULL-ed) state. */ -#define LTTNG_OPTIONAL_UNSET(field_ptr) \ - (field_ptr)->is_set = 0; +#define LTTNG_OPTIONAL_UNSET(field_ptr) \ + do { \ + (field_ptr)->is_set = 0; \ + } while (0) #endif /* LTTNG_OPTIONAL_H */