From mboxrd@z Thu Jan 1 00:00:00 1970 From: jeremie.galarneau@efficios.com (=?UTF-8?Q?J=C3=A9r=C3=A9mie_Galarneau?=) Date: Thu, 19 May 2016 00:12:35 -0400 Subject: [lttng-dev] [PATCH lttng-tools 05/10] Fix: bogus mask on error.h PRINT types In-Reply-To: <1463594659-10964-6-git-send-email-mathieu.desnoyers@efficios.com> References: <1463594659-10964-1-git-send-email-mathieu.desnoyers@efficios.com> <1463594659-10964-6-git-send-email-mathieu.desnoyers@efficios.com> Message-ID: Good catch, merged! Thanks! Jérémie On Wed, May 18, 2016 at 2:04 PM, Mathieu Desnoyers wrote: > PRINT_ERR maps to 0x1, PRINT_WARN maps to 0x2, which is fine so far to > use as masks, but PRINT_BUG maps to 0x3, which is the same as both > PRINT_ERR and PRINT_WARN, and does not make sense to use in masks with > __lttng_print: > > (type & (PRINT_WARN | PRINT_ERR | PRINT_BUG)) > > Fix this by ensuring PRINT_BUG has its own mask, and express all > constants as shifts to eliminate the risk of re-introducing a similar > bug in the future. > > Signed-off-by: Mathieu Desnoyers > --- > src/common/error.h | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/src/common/error.h b/src/common/error.h > index f2a31df..3ab1d46 100644 > --- a/src/common/error.h > +++ b/src/common/error.h > @@ -57,13 +57,13 @@ extern int lttng_opt_verbose; > extern int lttng_opt_mi; > > /* Error type. */ > -#define PRINT_ERR 0x1 > -#define PRINT_WARN 0x2 > -#define PRINT_BUG 0x3 > -#define PRINT_MSG 0x4 > -#define PRINT_DBG 0x10 > -#define PRINT_DBG2 0x20 > -#define PRINT_DBG3 0x30 > +#define PRINT_ERR (1 << 0) > +#define PRINT_WARN (1 << 1) > +#define PRINT_BUG (1 << 2) > +#define PRINT_MSG (1 << 3) > +#define PRINT_DBG (1 << 4) > +#define PRINT_DBG2 (1 << 5) > +#define PRINT_DBG3 (1 << 6) > > /* > * Macro for printing message depending on command line option and verbosity. > -- > 2.1.4 > -- Jérémie Galarneau EfficiOS Inc. http://www.efficios.com