From 9023454067e0d18fd6a8d108e990841ed913cfcd Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 14 Jun 2018 07:57:39 -0400 Subject: [PATCH] lib: Allow adding arrays of ferr's Simplify addition of new messages to the system by allow passage of arrays of data, instead of one at a time. Signed-off-by: Donald Sharp --- lib/ferr.c | 7 ++++++- lib/ferr.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ferr.c b/lib/ferr.c index ccf2f853e..6625749c3 100644 --- a/lib/ferr.c +++ b/lib/ferr.c @@ -74,9 +74,14 @@ static inline unsigned int ferr_hash_key(void *a) void ferr_ref_add(struct ferr_ref *ref) { + uint32_t i = 0; + pthread_mutex_lock(&refs_mtx); { - hash_get(refs, ref, hash_alloc_intern); + while (ref[i].code != END_FERR) { + hash_get(refs, &ref[i], hash_alloc_intern); + i++; + } } pthread_mutex_unlock(&refs_mtx); } diff --git a/lib/ferr.h b/lib/ferr.h index 5efdc6bd6..7e38fa455 100644 --- a/lib/ferr.h +++ b/lib/ferr.h @@ -104,6 +104,7 @@ struct ferr { #define OSPF_FERR_END 0x03FFFFFF #define ZEBRA_FERR_START 0x04000001 #define ZEBRA_FERR_END 0x04FFFFFF +#define END_FERR 0xFFFFFFFF struct ferr_ref { /* Unique error code displayed to end user as a reference. -1 means -- 2.39.2