]> git.proxmox.com Git - mirror_frr.git/blobdiff - pimd/pim_oil.c
Merge pull request #2884 from opensourcerouting/assorted-20180821
[mirror_frr.git] / pimd / pim_oil.c
index c45b0ce14c34ca46e327f62811870db55b8bb864..a0debc0c78f86a0994f9c751fe96c872005714f3 100644 (file)
 
 char *pim_channel_oil_dump(struct channel_oil *c_oil, char *buf, size_t size)
 {
+       char *out;
        struct prefix_sg sg;
        int i;
 
-       memset(buf, 0, size);
        sg.src = c_oil->oil.mfcc_origin;
        sg.grp = c_oil->oil.mfcc_mcastgrp;
-       sprintf(buf, "%s IIF: %d, OIFS: ", pim_str_sg_dump(&sg),
-               c_oil->oil.mfcc_parent);
+       snprintf(buf, size, "%s IIF: %d, OIFS: ", pim_str_sg_dump(&sg),
+                c_oil->oil.mfcc_parent);
 
+       out = buf + strlen(buf);
        for (i = 0; i < MAXVIFS; i++) {
                if (c_oil->oil.mfcc_ttls[i] != 0) {
-                       char buf1[10];
-                       sprintf(buf1, "%d ", i);
-                       strcat(buf, buf1);
+                       snprintf(out, buf + size - out, "%d ", i);
+                       out += strlen(out);
                }
        }
 
@@ -104,17 +104,10 @@ void pim_oil_init(struct pim_instance *pim)
        char hash_name[64];
 
        snprintf(hash_name, 64, "PIM %s Oil Hash", pim->vrf->name);
-       pim->channel_oil_hash = hash_create_size(8192,
-                                               pim_oil_hash_key,
-                                               pim_oil_equal,
-                                               hash_name);
+       pim->channel_oil_hash = hash_create_size(8192, pim_oil_hash_key,
+                                                pim_oil_equal, hash_name);
 
        pim->channel_oil_list = list_new();
-       if (!pim->channel_oil_list) {
-               zlog_err("%s %s: failure: channel_oil_list=list_new()",
-                        __FILE__, __PRETTY_FUNCTION__);
-               return;
-       }
        pim->channel_oil_list->del = (void (*)(void *))pim_channel_oil_free;
        pim->channel_oil_list->cmp =
                (int (*)(void *, void *))pim_channel_oil_compare;
@@ -135,8 +128,8 @@ void pim_channel_oil_free(struct channel_oil *c_oil)
        XFREE(MTYPE_PIM_CHANNEL_OIL, c_oil);
 }
 
-static struct channel_oil *pim_find_channel_oil(struct pim_instance *pim,
-                                               struct prefix_sg *sg)
+struct channel_oil *pim_find_channel_oil(struct pim_instance *pim,
+                                        struct prefix_sg *sg)
 {
        struct channel_oil *c_oil = NULL;
        struct channel_oil lookup;
@@ -185,10 +178,6 @@ struct channel_oil *pim_channel_oil_add(struct pim_instance *pim,
        }
 
        c_oil = XCALLOC(MTYPE_PIM_CHANNEL_OIL, sizeof(*c_oil));
-       if (!c_oil) {
-               zlog_err("PIM XCALLOC(%zu) failure", sizeof(*c_oil));
-               return NULL;
-       }
 
        c_oil->oil.mfcc_mcastgrp = sg->grp;
        c_oil->oil.mfcc_origin = sg->src;