]> git.proxmox.com Git - mirror_frr.git/commitdiff
*: do not check XMALLOC / XCALLOC for null ret
authorQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 25 Feb 2019 19:43:09 +0000 (19:43 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Mon, 25 Feb 2019 23:00:44 +0000 (23:00 +0000)
They never return NULL

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
14 files changed:
babeld/babel_interface.c
bfdd/bfd.c
bfdd/config.c
bfdd/control.c
bfdd/ptm_adapter.c
bgpd/bgp_evpn.c
bgpd/bgp_routemap.c
lib/frr_zmq.c
lib/hash.c
lib/pqueue.c
lib/thread.c
ospf6d/ospf6_lsdb.c
zebra/zebra_dplane.c
zebra/zebra_ptm.c

index 79242f5b85c5910c8da1a259051ace4aadd1731f..973c4618f836e8b14d126a16a25ad7c84b28fd26 100644 (file)
@@ -1415,8 +1415,6 @@ babel_interface_allocate (void)
 {
     babel_interface_nfo *babel_ifp;
     babel_ifp = XMALLOC(MTYPE_BABEL_IF, sizeof(babel_interface_nfo));
-    if(babel_ifp == NULL)
-        return NULL;
 
     /* Here are set the default values for an interface. */
     memset(babel_ifp, 0, sizeof(babel_interface_nfo));
index afd5d814a0bbd64a3ff3688e90df868662c6b908..be6f2caa44862aa0d365518d158e85125d0ca5bb 100644 (file)
@@ -551,8 +551,6 @@ static struct bfd_session *bfd_session_new(void)
        struct bfd_session *bs;
 
        bs = XCALLOC(MTYPE_BFDD_CONFIG, sizeof(*bs));
-       if (bs == NULL)
-               return NULL;
 
        QOBJ_REG(bs, bfd_session);
 
index d1342eff1ec22fb58efa982b226c7731128da976..17e155e41df37208c6b8a846e3fddc7f8e0469f6 100644 (file)
@@ -574,8 +574,6 @@ struct peer_label *pl_new(const char *label, struct bfd_session *bs)
        struct peer_label *pl;
 
        pl = XCALLOC(MTYPE_BFDD_LABEL, sizeof(*pl));
-       if (pl == NULL)
-               return NULL;
 
        if (strlcpy(pl->pl_label, label, sizeof(pl->pl_label))
            > sizeof(pl->pl_label))
index 40f4f4d3be482af8282dd84469383ce1aef209fc..c308d647d83e36c5084babc7e362dd6de02d4c7c 100644 (file)
@@ -186,8 +186,6 @@ struct bfd_control_socket *control_new(int sd)
        struct bfd_control_socket *bcs;
 
        bcs = XCALLOC(MTYPE_BFDD_CONTROL, sizeof(*bcs));
-       if (bcs == NULL)
-               return NULL;
 
        /* Disable notifications by default. */
        bcs->bcs_notify = 0;
@@ -247,10 +245,6 @@ struct bfd_notify_peer *control_notifypeer_new(struct bfd_control_socket *bcs,
                return bnp;
 
        bnp = XCALLOC(MTYPE_BFDD_CONTROL, sizeof(*bnp));
-       if (bnp == NULL) {
-               log_warning("%s: calloc: %s", __func__, strerror(errno));
-               return NULL;
-       }
 
        TAILQ_INSERT_TAIL(&bcs->bcs_bnplist, bnp, bnp_entry);
        bnp->bnp_bs = bs;
@@ -285,10 +279,6 @@ struct bfd_control_queue *control_queue_new(struct bfd_control_socket *bcs)
        struct bfd_control_queue *bcq;
 
        bcq = XCALLOC(MTYPE_BFDD_NOTIFICATION, sizeof(*bcq));
-       if (bcq == NULL) {
-               log_warning("%s: calloc: %s", __func__, strerror(errno));
-               return NULL;
-       }
 
        control_reset_buf(&bcq->bcq_bcb);
        TAILQ_INSERT_TAIL(&bcs->bcs_bcqueue, bcq, bcq_entry);
@@ -743,11 +733,6 @@ static void control_response(struct bfd_control_socket *bcs, uint16_t id,
        jsonstrlen = strlen(jsonstr);
        bcm = XMALLOC(MTYPE_BFDD_NOTIFICATION,
                      sizeof(struct bfd_control_msg) + jsonstrlen);
-       if (bcm == NULL) {
-               log_warning("%s: malloc: %s", __func__, strerror(errno));
-               XFREE(MTYPE_BFDD_NOTIFICATION, jsonstr);
-               return;
-       }
 
        bcm->bcm_length = htonl(jsonstrlen);
        bcm->bcm_ver = BMV_VERSION_1;
@@ -778,11 +763,6 @@ static void _control_notify(struct bfd_control_socket *bcs,
        jsonstrlen = strlen(jsonstr);
        bcm = XMALLOC(MTYPE_BFDD_NOTIFICATION,
                      sizeof(struct bfd_control_msg) + jsonstrlen);
-       if (bcm == NULL) {
-               log_warning("%s: malloc: %s", __func__, strerror(errno));
-               XFREE(MTYPE_BFDD_NOTIFICATION, jsonstr);
-               return;
-       }
 
        bcm->bcm_length = htonl(jsonstrlen);
        bcm->bcm_ver = BMV_VERSION_1;
@@ -846,11 +826,6 @@ static void _control_notify_config(struct bfd_control_socket *bcs,
        jsonstrlen = strlen(jsonstr);
        bcm = XMALLOC(MTYPE_BFDD_NOTIFICATION,
                      sizeof(struct bfd_control_msg) + jsonstrlen);
-       if (bcm == NULL) {
-               log_warning("%s: malloc: %s", __func__, strerror(errno));
-               XFREE(MTYPE_BFDD_NOTIFICATION, jsonstr);
-               return;
-       }
 
        bcm->bcm_length = htonl(jsonstrlen);
        bcm->bcm_ver = BMV_VERSION_1;
index 3f1512d8e715de38b86304c3b90a2e3e2cf20682..5610c352fb3f1fdebedd7768d9f382eabd5dcfb8 100644 (file)
@@ -752,8 +752,6 @@ static struct ptm_client *pc_new(uint32_t pid)
 
        /* Allocate the client data and save it. */
        pc = XCALLOC(MTYPE_BFDD_CONTROL, sizeof(*pc));
-       if (pc == NULL)
-               return NULL;
 
        pc->pc_pid = pid;
        TAILQ_INSERT_HEAD(&pcqueue, pc, pc_entry);
@@ -799,8 +797,6 @@ static struct ptm_client_notification *pcn_new(struct ptm_client *pc,
 
        /* Save the client notification data. */
        pcn = XCALLOC(MTYPE_BFDD_NOTIFICATION, sizeof(*pcn));
-       if (pcn == NULL)
-               return NULL;
 
        TAILQ_INSERT_HEAD(&pc->pc_pcnqueue, pcn, pcn_entry);
        pcn->pcn_pc = pc;
index 1471bd9829a50719b564d1526113edb78330119d..214aaeac5b1001bc066ce1781a48a897d24b2038 100644 (file)
@@ -184,8 +184,6 @@ static struct vrf_irt_node *vrf_import_rt_new(struct ecommunity_val *rt)
 
        irt = XCALLOC(MTYPE_BGP_EVPN_VRF_IMPORT_RT,
                      sizeof(struct vrf_irt_node));
-       if (!irt)
-               return NULL;
 
        irt->rt = *rt;
        irt->vrfs = list_new();
@@ -296,8 +294,6 @@ static struct irt_node *import_rt_new(struct bgp *bgp,
                return NULL;
 
        irt = XCALLOC(MTYPE_BGP_EVPN_IMPORT_RT, sizeof(struct irt_node));
-       if (!irt)
-               return NULL;
 
        irt->rt = *rt;
        irt->vnis = list_new();
@@ -968,8 +964,6 @@ static struct in_addr *es_vtep_new(struct in_addr vtep)
        struct in_addr *ip;
 
        ip = XCALLOC(MTYPE_BGP_EVPN_ES_VTEP, sizeof(struct in_addr));
-       if (!ip)
-               return NULL;
 
        ip->s_addr = vtep.s_addr;
        return ip;
@@ -5099,8 +5093,6 @@ struct bgpevpn *bgp_evpn_new(struct bgp *bgp, vni_t vni,
                return NULL;
 
        vpn = XCALLOC(MTYPE_BGP_EVPN, sizeof(struct bgpevpn));
-       if (!vpn)
-               return NULL;
 
        /* Set values - RD and RT set to defaults. */
        vpn->vni = vni;
@@ -5180,8 +5172,6 @@ struct evpnes *bgp_evpn_es_new(struct bgp *bgp,
                return NULL;
 
        es = XCALLOC(MTYPE_BGP_EVPN_ES, sizeof(struct evpnes));
-       if (!es)
-               return NULL;
 
        /* set the ESI and originator_ip */
        memcpy(&es->esi, esi, sizeof(esi_t));
index 17109281bc8b36ae61b6880ba40c629d26074126..7be0e508d0b1d0dd7dc00bf4e96b19c2934cff8a 100644 (file)
@@ -197,8 +197,6 @@ static void *route_value_compile(const char *arg)
        }
 
        rv = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(struct rmap_value));
-       if (!rv)
-               return NULL;
 
        rv->action = action;
        rv->variable = var;
@@ -837,8 +835,6 @@ static void *route_match_vni_compile(const char *arg)
        char *end = NULL;
 
        vni = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(vni_t));
-       if (!vni)
-               return NULL;
 
        *vni = strtoul(arg, &end, 10);
        if (*end != '\0') {
@@ -998,9 +994,6 @@ static void *route_match_local_pref_compile(const char *arg)
 
        local_pref = XMALLOC(MTYPE_ROUTE_MAP_COMPILED, sizeof(uint32_t));
 
-       if (!local_pref)
-               return local_pref;
-
        *local_pref = tmpval;
        return local_pref;
 }
index cfea238d95b1e34de249b4ac7c3012b3497e7aad..7781beae5e95535a9762605e7ef2178d84321e51 100644 (file)
@@ -176,8 +176,6 @@ int funcname_frrzmq_thread_add_read(struct thread_master *master,
                cb = *cbp;
        else {
                cb = XCALLOC(MTYPE_ZEROMQ_CB, sizeof(struct frrzmq_cb));
-               if (!cb)
-                       return -1;
 
                cb->write.cancelled = 1;
                *cbp = cb;
@@ -286,8 +284,6 @@ int funcname_frrzmq_thread_add_write(struct thread_master *master,
                cb = *cbp;
        else {
                cb = XCALLOC(MTYPE_ZEROMQ_CB, sizeof(struct frrzmq_cb));
-               if (!cb)
-                       return -1;
 
                cb->read.cancelled = 1;
                *cbp = cb;
index 9f9fc31d3740f9b6d22f9abd9fb3f67aa2632e86..611fd33fbe1ce32ef6ed6f52675bbc9f44ab2bde 100644 (file)
@@ -95,8 +95,6 @@ static void hash_expand(struct hash *hash)
 
        new_index = XCALLOC(MTYPE_HASH_INDEX,
                            sizeof(struct hash_bucket *) * new_size);
-       if (new_index == NULL)
-               return;
 
        hash->stats.empty = new_size;
 
index 1565de216eb0e5f013e754c2edadde057bd36f0a..87b54a681a1d5ed99273bd75723771ac360cb500 100644 (file)
@@ -133,8 +133,6 @@ static int pqueue_expand(struct pqueue *queue)
 
        newarray =
                XCALLOC(MTYPE_PQUEUE_DATA, queue->array_size * DATA_SIZE * 2);
-       if (newarray == NULL)
-               return 0;
 
        memcpy(newarray, queue->array, queue->array_size * DATA_SIZE);
 
index 055587434ccfc9ec06d0877b910e5487ebd7e9e1..e757ff639bb0c26db06d9d3198cb268db2de9e87 100644 (file)
@@ -414,8 +414,6 @@ struct thread_master *thread_master_create(const char *name)
        pthread_once(&init_once, &initializer);
 
        rv = XCALLOC(MTYPE_THREAD_MASTER, sizeof(struct thread_master));
-       if (rv == NULL)
-               return NULL;
 
        /* Initialize master mutex */
        pthread_mutex_init(&rv->mtx, NULL);
index 5e02c0c917b66471931a6626bb32395acea53275..b551dbdfa6e2bededa49e0265567e3b2364d08d3 100644 (file)
@@ -39,10 +39,6 @@ struct ospf6_lsdb *ospf6_lsdb_create(void *data)
        struct ospf6_lsdb *lsdb;
 
        lsdb = XCALLOC(MTYPE_OSPF6_LSDB, sizeof(struct ospf6_lsdb));
-       if (lsdb == NULL) {
-               zlog_warn("Can't malloc lsdb");
-               return NULL;
-       }
        memset(lsdb, 0, sizeof(struct ospf6_lsdb));
 
        lsdb->data = data;
index 28f7666f87797e87c787251f6cbd04790454ee31..894914e57645defcf1100ea9fe12277348f74a1d 100644 (file)
@@ -1474,10 +1474,6 @@ int dplane_provider_register(const char *name,
 
        /* Allocate and init new provider struct */
        p = XCALLOC(MTYPE_DP_PROV, sizeof(struct zebra_dplane_provider));
-       if (p == NULL) {
-               ret = ENOMEM;
-               goto done;
-       }
 
        pthread_mutex_init(&(p->dp_mutex), NULL);
        TAILQ_INIT(&(p->dp_ctx_in_q));
index 1e942d6433f9f8642a9704994ad498f6ed6e30bd..cc5e38e690df9bf3389790eed6e898cf14440bed 100644 (file)
@@ -1215,8 +1215,6 @@ static struct ptm_process *pp_new(pid_t pid, struct zserv *zs)
 
        /* Allocate and register new process. */
        pp = XCALLOC(MTYPE_ZEBRA_PTM_BFD_PROCESS, sizeof(*pp));
-       if (pp == NULL)
-               return NULL;
 
        pp->pp_pid = pid;
        pp->pp_zs = zs;