commit 4a95c2d3ea18a6f522b3ee22e7ca0a6dad791bcd
parent 5b87b9e0fd7ae0c0920be5f4a4fc8fc8efe61f15
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Mon, 9 Jan 2017 14:55:32 +0100
Fix parser pivots are created uninitialized.
Diffstat:
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/parser/solparser.c b/src/parser/solparser.c
@@ -138,6 +138,7 @@
/* Declare the array of pivots */
#define DARRAY_NAME pivot
#define DARRAY_DATA struct solparser_pivot
+#define DARRAY_FUNCTOR_INIT solparser_pivot_init
#include <rsys/dynamic_array.h>
/* Declare the hash table that maps the address of a YAML node to the id of its
@@ -2574,7 +2575,6 @@ parse_pivot
if(res != RES_OK) goto error;
#undef SETUP_MASK
}
-
#define CHECK_PARAM(Flag, Name) \
if(!(mask & BIT(Flag))) { \
log_err(parser, pivot, "the pivot parameter `"Name"' is missing.\n"); \
diff --git a/src/parser/solparser_pivot.h b/src/parser/solparser_pivot.h
@@ -22,7 +22,9 @@ enum solparser_target_type {
SOLPARSER_TARGET_ANCHOR,
SOLPARSER_TARGET_DIRECTION,
SOLPARSER_TARGET_POSITION,
- SOLPARSER_TARGET_SUN
+ SOLPARSER_TARGET_SUN,
+
+ SOLPARSER_TARGET_TYPES_COUNT__
};
struct solparser_anchor_id { size_t i; };
@@ -78,7 +80,19 @@ struct solparser_pivot {
} target;
};
+#define SOLPARSER_PIVOT_NULL__ { {0,0,0}, {0,0,0}, {0,0,0}, {0,0,0}, SOLPARSER_TARGET_TYPES_COUNT__, {0,0,0} };
+
+static const struct solparser_pivot SOLPARSER_PIVOT_NULL = SOLPARSER_PIVOT_NULL__;
+
struct solparser_pivot_id { size_t i; };
+static INLINE void
+solparser_pivot_init
+ (struct mem_allocator* allocator, struct solparser_pivot* pivot)
+{
+ ASSERT(pivot);
+ *pivot = SOLPARSER_PIVOT_NULL;
+}
+
#endif /* SOLPARSER_PIVOT_H */