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);
}
}
return 0;
}
-static int pim_oil_equal(const void *arg1, const void *arg2)
+static bool pim_oil_equal(const void *arg1, const void *arg2)
{
const struct channel_oil *c1 = (const struct channel_oil *)arg1;
const struct channel_oil *c2 = (const struct channel_oil *)arg2;
if ((c1->oil.mfcc_mcastgrp.s_addr == c2->oil.mfcc_mcastgrp.s_addr)
&& (c1->oil.mfcc_origin.s_addr == c2->oil.mfcc_origin.s_addr))
- return 1;
+ return true;
- return 0;
+ return false;
}
static unsigned int pim_oil_hash_key(void *arg)
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;
void pim_oil_terminate(struct pim_instance *pim)
{
if (pim->channel_oil_list)
- list_delete_and_null(&pim->channel_oil_list);
+ list_delete(&pim->channel_oil_list);
if (pim->channel_oil_hash)
hash_free(pim->channel_oil_hash);
}
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;