]> git.puffer.fish Git - mirror/frr.git/commitdiff
isisd: fix warnings by removing union isis_N and going to void * instead
authorChristian Franke <chris@opensourcerouting.org>
Thu, 9 Aug 2018 18:37:30 +0000 (20:37 +0200)
committerChristian Franke <chris@opensourcerouting.org>
Wed, 5 Sep 2018 09:38:13 +0000 (11:38 +0200)
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
isisd/isis_spf.c
isisd/isis_spf_private.h
tests/isisd/test_isis_vertex_queue.c

index 02575a2f6a95f4582893ec217b49d42520a8c7db..8f8cfb3078fe884519a573b07e120a06a179e5f5 100644 (file)
@@ -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);
index 2e33367e21d366a8aa2b69e10adf94a4c3f0cb96..664ddc3f29a711d3d6f5a1292e5067e9a5bd2243 100644 (file)
@@ -53,13 +53,12 @@ struct prefix_pair {
 /*
  * Triple <N, d(N), {Adj(N)}>
  */
-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);
 }
 
index 96c215dcff4c67017f10b4292cebfd5c376c8c9c..869dd732eb9dcf6b3ba98156e427d1ade530685f 100644 (file)
@@ -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++;
 };