From dc78d159de0471583f04ba6dae2b0808b540844f Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 12 Jan 2012 14:39:23 -0500 Subject: [PATCH] Fix ht default size test in the line: size != 0 ? : (size = DEFAULT_HT_SIZE); we should notice that the lack of ( ) around "size != 0" leads to the following behavior: the compiler will try to evaluate "0 ? : (size = DEFAULT_HT_SIZE)" and compare it to size, which is not the expected behavior. Use a standard "if (cond)" test instead. The ? : expression is not needed here anyway, it just complicates the code. Signed-off-by: Mathieu Desnoyers --- liblttng-ht/lttng-ht.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/liblttng-ht/lttng-ht.c b/liblttng-ht/lttng-ht.c index d55c95373..74e5ed4fe 100644 --- a/liblttng-ht/lttng-ht.c +++ b/liblttng-ht/lttng-ht.c @@ -62,7 +62,8 @@ struct lttng_ht *lttng_ht_new(unsigned long size, int type) struct lttng_ht *ht; /* Test size */ - size != 0 ? : (size = DEFAULT_HT_SIZE); + if (!size) + size = DEFAULT_HT_SIZE; ht = zmalloc(sizeof(*ht)); if (ht == NULL) { -- 2.34.1