From 1f46f33f9a8d6c7b8a887e34ad8f7a52f44c1187 Mon Sep 17 00:00:00 2001 From: sri-mohan1 Date: Mon, 29 Aug 2022 12:23:46 +0530 Subject: [PATCH] isisd: changes for code maintainability these changes are for improving the code maintainability Signed-off-by: sri-mohan1 --- isisd/isis_adjacency.c | 10 +++++----- isisd/isis_bpf.c | 13 +++++++------ isisd/isis_circuit.c | 10 +++++----- isisd/isis_dlpi.c | 24 +++++++++++------------- isisd/isis_dr.c | 12 +++++++----- 5 files changed, 35 insertions(+), 34 deletions(-) diff --git a/isisd/isis_adjacency.c b/isisd/isis_adjacency.c index 86cf10ae17..00763135e6 100644 --- a/isisd/isis_adjacency.c +++ b/isisd/isis_adjacency.c @@ -860,13 +860,13 @@ void isis_adj_build_neigh_list(struct list *adjdb, struct list *list) struct listnode *node; if (!list) { - zlog_warn("isis_adj_build_neigh_list(): NULL list"); + zlog_warn("%s: NULL list", __func__); return; } for (ALL_LIST_ELEMENTS_RO(adjdb, node, adj)) { if (!adj) { - zlog_warn("isis_adj_build_neigh_list(): NULL adj"); + zlog_warn("%s: NULL adj", __func__); return; } @@ -883,18 +883,18 @@ void isis_adj_build_up_list(struct list *adjdb, struct list *list) struct listnode *node; if (adjdb == NULL) { - zlog_warn("isis_adj_build_up_list(): adjacency DB is empty"); + zlog_warn("%s: adjacency DB is empty", __func__); return; } if (!list) { - zlog_warn("isis_adj_build_up_list(): NULL list"); + zlog_warn("%s: NULL list", __func__); return; } for (ALL_LIST_ELEMENTS_RO(adjdb, node, adj)) { if (!adj) { - zlog_warn("isis_adj_build_up_list(): NULL adj"); + zlog_warn("%s: NULL adj", __func__); return; } diff --git a/isisd/isis_bpf.c b/isisd/isis_bpf.c index 5f3d70ed3a..11f43279ec 100644 --- a/isisd/isis_bpf.c +++ b/isisd/isis_bpf.c @@ -165,7 +165,7 @@ static int open_bpf_dev(struct isis_circuit *circuit) bpf_prog.bf_len = 8; bpf_prog.bf_insns = &(llcfilter[0]); if (ioctl(fd, BIOCSETF, (caddr_t)&bpf_prog) < 0) { - zlog_warn("open_bpf_dev(): failed to install filter: %s", + zlog_warn("%s: failed to install filter: %s", __func__, safe_strerror(errno)); return ISIS_WARNING; } @@ -198,7 +198,7 @@ int isis_sock_init(struct isis_circuit *circuit) circuit->tx = isis_send_pdu_bcast; circuit->rx = isis_recv_pdu_bcast; } else { - zlog_warn("isis_sock_init(): unknown circuit type"); + zlog_warn("%s: unknown circuit type", __func__); retval = ISIS_WARNING; break; } @@ -223,8 +223,8 @@ int isis_recv_pdu_bcast(struct isis_circuit *circuit, uint8_t *ssnpa) bytesread = read(circuit->fd, readbuff, readblen); } if (bytesread < 0) { - zlog_warn("isis_recv_pdu_bcast(): read() failed: %s", - safe_strerror(errno)); + zlog_warn("%s: read() failed: %s", __func__, + safe_strerror(errno)); return ISIS_WARNING; } @@ -267,8 +267,9 @@ int isis_send_pdu_bcast(struct isis_circuit *circuit, int level) buflen = stream_get_endp(circuit->snd_stream) + LLC_LEN + ETHER_HDR_LEN; if (buflen > sizeof(sock_buff)) { zlog_warn( - "isis_send_pdu_bcast: sock_buff size %zu is less than output pdu size %zu on circuit %s", - sizeof(sock_buff), buflen, circuit->interface->name); + "%s: sock_buff size %zu is less than output pdu size %zu on circuit %s", + __func__, sizeof(sock_buff), buflen, + circuit->interface->name); return ISIS_WARNING; } diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index 9e97e48937..178fbe7903 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -513,7 +513,7 @@ void isis_circuit_if_add(struct isis_circuit *circuit, struct interface *ifp) } else { /* It's normal in case of loopback etc. */ if (IS_DEBUG_EVENTS) - zlog_debug("isis_circuit_if_add: unsupported media"); + zlog_debug("%s: unsupported media", __func__); circuit->circ_type = CIRCUIT_T_UNKNOWN; } @@ -678,10 +678,10 @@ int isis_circuit_up(struct isis_circuit *circuit) } #ifdef EXTREME_DEGUG if (IS_DEBUG_EVENTS) - zlog_debug( - "isis_circuit_if_add: if_id %d, isomtu %d snpa %s", - circuit->interface->ifindex, ISO_MTU(circuit), - snpa_print(circuit->u.bc.snpa)); + zlog_debug("%s: if_id %d, isomtu %d snpa %s", __func__, + circuit->interface->ifindex, + ISO_MTU(circuit), + snpa_print(circuit->u.bc.snpa)); #endif /* EXTREME_DEBUG */ circuit->u.bc.adjdb[0] = list_new(); diff --git a/isisd/isis_dlpi.c b/isisd/isis_dlpi.c index bb8c542597..f6ea0aea60 100644 --- a/isisd/isis_dlpi.c +++ b/isisd/isis_dlpi.c @@ -336,9 +336,8 @@ static int open_dlpi_dev(struct isis_circuit *circuit) /* Double check the DLPI style */ if (dia->dl_provider_style != DL_STYLE2) { - zlog_warn( - "open_dlpi_dev(): interface %s: %s is not style 2", - circuit->interface->name, devpath); + zlog_warn("%s: interface %s: %s is not style 2", + __func__, circuit->interface->name, devpath); close(fd); return ISIS_WARNING; } @@ -355,9 +354,8 @@ static int open_dlpi_dev(struct isis_circuit *circuit) } else { /* Double check the DLPI style */ if (dia->dl_provider_style != DL_STYLE1) { - zlog_warn( - "open_dlpi_dev(): interface %s: %s is not style 1", - circuit->interface->name, devpath); + zlog_warn("%s: interface %s: %s is not style 1", + __func__, circuit->interface->name, devpath); close(fd); return ISIS_WARNING; } @@ -404,9 +402,8 @@ static int open_dlpi_dev(struct isis_circuit *circuit) * so we need to be careful and use DL_PHYS_ADDR_REQ instead. */ if (dlpiaddr(fd, circuit->u.bc.snpa) == -1) { - zlog_warn( - "open_dlpi_dev(): interface %s: unable to get MAC address", - circuit->interface->name); + zlog_warn("%s: interface %s: unable to get MAC address", + __func__, circuit->interface->name); close(fd); return ISIS_WARNING; } @@ -479,7 +476,7 @@ int isis_sock_init(struct isis_circuit *circuit) circuit->tx = isis_send_pdu_bcast; circuit->rx = isis_recv_pdu_bcast; } else { - zlog_warn("isis_sock_init(): unknown circuit type"); + zlog_warn("%s: unknown circuit type", __func__); retval = ISIS_WARNING; break; } @@ -511,7 +508,7 @@ int isis_recv_pdu_bcast(struct isis_circuit *circuit, uint8_t *ssnpa) retv = getmsg(circuit->fd, &ctlbuf, &databuf, &flags); if (retv < 0) { - zlog_warn("isis_recv_pdu_bcast: getmsg failed: %s", + zlog_warn("%s: getmsg failed: %s", __func__, safe_strerror(errno)); return ISIS_WARNING; } @@ -561,8 +558,9 @@ int isis_send_pdu_bcast(struct isis_circuit *circuit, int level) buflen = stream_get_endp(circuit->snd_stream) + LLC_LEN; if ((size_t)buflen > sizeof(sock_buff)) { zlog_warn( - "isis_send_pdu_bcast: sock_buff size %zu is less than output pdu size %d on circuit %s", - sizeof(sock_buff), buflen, circuit->interface->name); + "%s: sock_buff size %zu is less than output pdu size %d on circuit %s", + __func__, sizeof(sock_buff), buflen, + circuit->interface->name); return ISIS_WARNING; } diff --git a/isisd/isis_dr.c b/isisd/isis_dr.c index b9bf49867d..400982f2fc 100644 --- a/isisd/isis_dr.c +++ b/isisd/isis_dr.c @@ -80,7 +80,8 @@ void isis_run_dr(struct thread *thread) } if (circuit->u.bc.run_dr_elect[level - 1]) - zlog_warn("isis_run_dr(): run_dr_elect already set for l%d", level); + zlog_warn("%s: run_dr_elect already set for l%d", __func__, + level); circuit->u.bc.t_run_dr[level - 1] = NULL; circuit->u.bc.run_dr_elect[level - 1] = 1; @@ -126,7 +127,7 @@ int isis_dr_elect(struct isis_circuit *circuit, int level) adjdb = circuit->u.bc.adjdb[level - 1]; if (!adjdb) { - zlog_warn("isis_dr_elect() adjdb == NULL"); + zlog_warn("%s adjdb == NULL", __func__); list_delete(&list); return ISIS_WARNING; } @@ -155,7 +156,8 @@ int isis_dr_elect(struct isis_circuit *circuit, int level) } if (cmp_res == 0) zlog_warn( - "isis_dr_elect(): multiple adjacencies with same SNPA"); + "%s: multiple adjacencies with same SNPA", + __func__); } else { adj_dr = adj; } @@ -218,7 +220,7 @@ int isis_dr_resign(struct isis_circuit *circuit, int level) uint8_t id[ISIS_SYS_ID_LEN + 2]; if (IS_DEBUG_EVENTS) - zlog_debug("isis_dr_resign l%d", level); + zlog_debug("%s l%d", __func__, level); circuit->u.bc.is_dr[level - 1] = 0; circuit->u.bc.run_dr_elect[level - 1] = 0; @@ -266,7 +268,7 @@ int isis_dr_commence(struct isis_circuit *circuit, int level) uint8_t old_dr[ISIS_SYS_ID_LEN + 2]; if (IS_DEBUG_EVENTS) - zlog_debug("isis_dr_commence l%d", level); + zlog_debug("%s l%d", __func__, level); /* Lets keep a pause in DR election */ circuit->u.bc.run_dr_elect[level - 1] = 0; -- 2.39.5