From f6ae63ca955e77aaf40ee1add30506a7a1bbcffa Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Thu, 9 Aug 2018 20:37:30 +0200 Subject: [PATCH] isisd: fix warnings by removing union isis_N and going to void * instead Signed-off-by: Christian Franke --- isisd/isis_spf.c | 10 +++---- isisd/isis_spf_private.h | 19 +++++++------ tests/isisd/test_isis_vertex_queue.c | 40 ++++++++++++++-------------- 3 files changed, 32 insertions(+), 37 deletions(-) diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c index 02575a2f6a..8f8cfb3078 100644 --- a/isisd/isis_spf.c +++ b/isisd/isis_spf.c @@ -179,14 +179,14 @@ const char *vid2string(struct isis_vertex *vertex, char *buff, int size) } static struct isis_vertex *isis_vertex_new(struct isis_spftree *spftree, - union isis_N *n, + void *id, enum vertextype vtype) { struct isis_vertex *vertex; vertex = XCALLOC(MTYPE_ISIS_VERTEX, sizeof(struct isis_vertex)); - isis_vertex_id_init(vertex, n, vtype); + isis_vertex_id_init(vertex, id, vtype); vertex->Adj_N = list_new(); vertex->parents = list_new(); @@ -330,17 +330,13 @@ static struct isis_vertex *isis_spf_add_root(struct isis_spftree *spftree, #ifdef EXTREME_DEBUG char buff[VID2STR_BUFFER]; #endif /* EXTREME_DEBUG */ - union isis_N n; - - memcpy(n.id, sysid, ISIS_SYS_ID_LEN); - LSP_PSEUDO_ID(n.id) = 0; lsp = isis_root_system_lsp(spftree->area, spftree->level, sysid); if (lsp == NULL) zlog_warn("ISIS-Spf: could not find own l%d LSP!", spftree->level); - vertex = isis_vertex_new(spftree, &n, + vertex = isis_vertex_new(spftree, sysid, spftree->area->oldmetric ? VTYPE_NONPSEUDO_IS : VTYPE_NONPSEUDO_TE_IS); diff --git a/isisd/isis_spf_private.h b/isisd/isis_spf_private.h index 2e33367e21..664ddc3f29 100644 --- a/isisd/isis_spf_private.h +++ b/isisd/isis_spf_private.h @@ -53,13 +53,12 @@ struct prefix_pair { /* * Triple */ -union isis_N { - uint8_t id[ISIS_SYS_ID_LEN + 1]; - struct prefix_pair ip; -}; struct isis_vertex { enum vertextype type; - union isis_N N; + union { + uint8_t id[ISIS_SYS_ID_LEN + 1]; + struct prefix_pair ip; + } N; uint32_t d_N; /* d(N) Distance from this IS */ uint16_t depth; /* The depth in the imaginary tree */ struct list *Adj_N; /* {Adj(N)} next hop or neighbor list */ @@ -309,15 +308,15 @@ struct isis_spftree { }; __attribute__((__unused__)) -static void isis_vertex_id_init(struct isis_vertex *vertex, const union isis_N *n, +static void isis_vertex_id_init(struct isis_vertex *vertex, const void *id, enum vertextype vtype) { vertex->type = vtype; if (VTYPE_IS(vtype) || VTYPE_ES(vtype)) { - memcpy(vertex->N.id, n->id, ISIS_SYS_ID_LEN + 1); + memcpy(vertex->N.id, id, ISIS_SYS_ID_LEN + 1); } else if (VTYPE_IP(vtype)) { - memcpy(&vertex->N.ip, &n->ip, sizeof(n->ip)); + memcpy(&vertex->N.ip, id, sizeof(vertex->N.ip)); } else { flog_err(LIB_ERR_DEVELOPMENT, "Unknown Vertex Type"); } @@ -325,12 +324,12 @@ static void isis_vertex_id_init(struct isis_vertex *vertex, const union isis_N * __attribute__((__unused__)) static struct isis_vertex *isis_find_vertex(struct isis_vertex_queue *queue, - union isis_N *n, + const void *id, enum vertextype vtype) { struct isis_vertex querier; - isis_vertex_id_init(&querier, n, vtype); + isis_vertex_id_init(&querier, id, vtype); return hash_lookup(queue->hash, &querier); } diff --git a/tests/isisd/test_isis_vertex_queue.c b/tests/isisd/test_isis_vertex_queue.c index 96c215dcff..869dd732eb 100644 --- a/tests/isisd/test_isis_vertex_queue.c +++ b/tests/isisd/test_isis_vertex_queue.c @@ -18,44 +18,44 @@ static void setup_test_vertices(void) { struct isis_spftree t = { }; - union isis_N nid, nip = { - .ip.dest.family = AF_UNSPEC + struct prefix_pair p = { }; + uint8_t node_id[7]; vertices = XMALLOC(MTYPE_TMP, sizeof(*vertices) * 16); - nip.ip.dest.family = AF_INET; - nip.ip.dest.prefixlen = 24; - inet_pton(AF_INET, "192.168.1.0", &nip.ip.dest.u.prefix4); - vertices[vertex_count] = isis_vertex_new(&t, &nip, VTYPE_IPREACH_TE); + p.dest.family = AF_INET; + p.dest.prefixlen = 24; + inet_pton(AF_INET, "192.168.1.0", &p.dest.u.prefix4); + vertices[vertex_count] = isis_vertex_new(&t, &p, VTYPE_IPREACH_TE); vertices[vertex_count]->d_N = 20; vertex_count++; - nip.ip.dest.family = AF_INET; - nip.ip.dest.prefixlen = 24; - inet_pton(AF_INET, "192.168.2.0", &nip.ip.dest.u.prefix4); - vertices[vertex_count] = isis_vertex_new(&t, &nip, VTYPE_IPREACH_TE); + p.dest.family = AF_INET; + p.dest.prefixlen = 24; + inet_pton(AF_INET, "192.168.2.0", &p.dest.u.prefix4); + vertices[vertex_count] = isis_vertex_new(&t, &p, VTYPE_IPREACH_TE); vertices[vertex_count]->d_N = 20; vertex_count++; - memset(nid.id, 0, sizeof(nid.id)); - nid.id[6] = 1; - vertices[vertex_count] = isis_vertex_new(&t, &nid, + memset(node_id, 0, sizeof(node_id)); + node_id[6] = 1; + vertices[vertex_count] = isis_vertex_new(&t, node_id, VTYPE_PSEUDO_TE_IS); vertices[vertex_count]->d_N = 15; vertex_count++; - memset(nid.id, 0, sizeof(nid.id)); - nid.id[5] = 2; - vertices[vertex_count] = isis_vertex_new(&t, &nid, + memset(node_id, 0, sizeof(node_id)); + node_id[5] = 2; + vertices[vertex_count] = isis_vertex_new(&t, node_id, VTYPE_NONPSEUDO_TE_IS); vertices[vertex_count]->d_N = 15; vertex_count++; - nip.ip.dest.family = AF_INET; - nip.ip.dest.prefixlen = 24; - inet_pton(AF_INET, "192.168.3.0", &nip.ip.dest.u.prefix4); - vertices[vertex_count] = isis_vertex_new(&t, &nip, VTYPE_IPREACH_TE); + p.dest.family = AF_INET; + p.dest.prefixlen = 24; + inet_pton(AF_INET, "192.168.3.0", &p.dest.u.prefix4); + vertices[vertex_count] = isis_vertex_new(&t, &p, VTYPE_IPREACH_TE); vertices[vertex_count]->d_N = 20; vertex_count++; }; -- 2.39.5