]> git.puffer.fish Git - mirror/frr.git/commitdiff
ldpd: changes for code maintainability 13742/head
authorsri-mohan1 <sri.mohan@samsung.com>
Thu, 8 Jun 2023 17:49:43 +0000 (23:19 +0530)
committersri-mohan1 <sri.mohan@samsung.com>
Wed, 14 Jun 2023 11:12:26 +0000 (16:42 +0530)
these changes are for improving the code maintainability and readability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
ldpd/control.c
ldpd/ldp_debug.c
ldpd/log.c
ldpd/logmsg.c
ldpd/pfkey.c

index 6bb5204d13828cabb555bb4a41a478c45ac3220c..db52d46325399e204b6bc843ed91b69c26f5c1be 100644 (file)
@@ -106,8 +106,7 @@ static void control_accept(struct event *thread)
                 */
                if (errno == ENFILE || errno == EMFILE)
                        accept_pause();
-               else if (errno != EWOULDBLOCK && errno != EINTR &&
-                   errno != ECONNABORTED)
+               else if (errno != EWOULDBLOCK && errno != EINTR && errno != ECONNABORTED)
                        log_warn("%s: accept", __func__);
                return;
        }
@@ -192,8 +191,7 @@ static void control_dispatch_imsg(struct event *thread)
 
        c->iev.ev_read = NULL;
 
-       if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) ||
-           n == 0) {
+       if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) || n == 0) {
                control_close(fd);
                return;
        }
@@ -217,12 +215,10 @@ static void control_dispatch_imsg(struct event *thread)
                        /* ignore */
                        break;
                case IMSG_CTL_SHOW_INTERFACE:
-                       if (imsg.hdr.len == IMSG_HEADER_SIZE +
-                           sizeof(ifidx)) {
+                       if (imsg.hdr.len == IMSG_HEADER_SIZE + sizeof(ifidx)) {
                                memcpy(&ifidx, imsg.data, sizeof(ifidx));
                                ldpe_iface_ctl(c, ifidx);
-                               imsg_compose_event(&c->iev, IMSG_CTL_END, 0,
-                                   0, -1, NULL, 0);
+                               imsg_compose_event(&c->iev, IMSG_CTL_END, 0, 0, -1, NULL, 0);
                        }
                        break;
                case IMSG_CTL_SHOW_DISCOVERY:
@@ -242,8 +238,7 @@ static void control_dispatch_imsg(struct event *thread)
                        ldpe_nbr_ctl(c);
                        break;
                case IMSG_CTL_CLEAR_NBR:
-                       if (imsg.hdr.len != IMSG_HEADER_SIZE +
-                           sizeof(struct ctl_nbr))
+                       if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(struct ctl_nbr))
                                break;
 
                        nbr_clear_ctl(imsg.data);
@@ -255,8 +250,7 @@ static void control_dispatch_imsg(struct event *thread)
                        /* ignore */
                        break;
                default:
-                       log_debug("%s: error handling imsg %d", __func__,
-                           imsg.hdr.type);
+                       log_debug("%s: error handling imsg %d", __func__, imsg.hdr.type);
                        break;
                }
                imsg_free(&imsg);
index d2aeaba8b314f5affca95e0a32f6cf540acf7e84..957fb8e55636a1267ac3bc2d1aacd2e58f7008e3 100644 (file)
@@ -97,8 +97,7 @@ ldp_vty_debug(struct vty *vty, const char *negate, const char *type_str,
                        DEBUG_ON(zebra, LDP_DEBUG_ZEBRA);
        }
 
-       main_imsg_compose_both(IMSG_DEBUG_UPDATE, &ldp_debug,
-           sizeof(ldp_debug));
+       main_imsg_compose_both(IMSG_DEBUG_UPDATE, &ldp_debug, sizeof(ldp_debug));
 
        return (CMD_SUCCESS);
 }
@@ -119,13 +118,11 @@ ldp_vty_show_debugging(struct vty *vty)
        if (LDP_DEBUG(labels, LDP_DEBUG_LABELS))
                vty_out (vty, "  LDP labels debugging is on\n");
        if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL))
-               vty_out (vty,
-                         "  LDP detailed messages debugging is on (inbound)\n");
+               vty_out (vty, "  LDP detailed messages debugging is on (inbound)\n");
        else if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV))
                vty_out (vty,"  LDP messages debugging is on (inbound)\n");
        if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL))
-               vty_out (vty,
-                         "  LDP detailed messages debugging is on (outbound)\n");
+               vty_out (vty, "  LDP detailed messages debugging is on (outbound)\n");
        else if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND))
                vty_out (vty,"  LDP messages debugging is on (outbound)\n");
        if (LDP_DEBUG(sync, LDP_DEBUG_SYNC))
index a9898a64f09f9bfe17aaecfece2edf6efb72f1ab..7c4d782dcfaad7fd6683c7d35746be9b3de4b173 100644 (file)
@@ -35,13 +35,11 @@ vlog(int pri, const char *fmt, va_list ap)
        switch (ldpd_process) {
        case PROC_LDE_ENGINE:
                vsnprintfrr(buf, sizeof(buf), fmt, ap);
-               lde_imsg_compose_parent_sync(IMSG_LOG, pri, buf,
-                   strlen(buf) + 1);
+               lde_imsg_compose_parent_sync(IMSG_LOG, pri, buf, strlen(buf) + 1);
                break;
        case PROC_LDP_ENGINE:
                vsnprintfrr(buf, sizeof(buf), fmt, ap);
-               ldpe_imsg_compose_parent_sync(IMSG_LOG, pri, buf,
-                   strlen(buf) + 1);
+               ldpe_imsg_compose_parent_sync(IMSG_LOG, pri, buf, strlen(buf) + 1);
                break;
        case PROC_MAIN:
                vzlog(pri, fmt, ap);
@@ -121,15 +119,13 @@ void
 fatal(const char *emsg)
 {
        if (emsg == NULL)
-               logit(LOG_CRIT, "fatal in %s: %s", log_procname,
-                   strerror(errno));
+               logit(LOG_CRIT, "fatal in %s: %s", log_procname, strerror(errno));
        else
                if (errno)
                        logit(LOG_CRIT, "fatal in %s: %s: %s",
                            log_procname, emsg, strerror(errno));
                else
-                       logit(LOG_CRIT, "fatal in %s: %s",
-                           log_procname, emsg);
+                       logit(LOG_CRIT, "fatal in %s: %s", log_procname, emsg);
 
        exit(1);
 }
index 4f1d950bb3da07190414dd7fe250043dedae8eff..75f4293f0cda39ef6cb82fd6b6d48535f2d4833f 100644 (file)
@@ -74,8 +74,7 @@ log_addr(int af, const union ldpd_addr *addr)
        switch (af) {
        case AF_INET:
                round = (round + 1) % NUM_LOGS;
-               if (inet_ntop(AF_INET, &addr->v4, buf[round],
-                   sizeof(buf[round])) == NULL)
+               if (inet_ntop(AF_INET, &addr->v4, buf[round], sizeof(buf[round])) == NULL)
                        return ("???");
                return (buf[round]);
        case AF_INET6:
@@ -166,8 +165,7 @@ log_hello_src(const struct hello_source *src)
 
        switch (src->type) {
        case HELLO_LINK:
-               snprintf(buf, sizeof(buf), "iface %s",
-                   src->link.ia->iface->name);
+               snprintf(buf, sizeof(buf), "iface %s", src->link.ia->iface->name);
                break;
        case HELLO_TARGETED:
                snprintf(buf, sizeof(buf), "source %s",
index 4bea2e1904376104786b485902673587948ae0d5..ae771cae194f63b115713a96522a05ed6abc2ead 100644 (file)
@@ -256,8 +256,7 @@ pfkey_read(int sd, struct sadb_msg *h)
        }
 
        /* XXX: Only one message can be outstanding. */
-       if (hdr.sadb_msg_seq == sadb_msg_seq &&
-           hdr.sadb_msg_pid == pid) {
+       if (hdr.sadb_msg_seq == sadb_msg_seq && hdr.sadb_msg_pid == pid) {
                if (h)
                        *h = hdr;
                return (0);
@@ -412,8 +411,7 @@ pfkey_establish(struct nbr *nbr, struct nbr_params *nbrp)
 {
        switch (nbr->auth.method) {
        case AUTH_MD5SIG:
-               strlcpy(nbr->auth.md5key, nbrp->auth.md5key,
-                   sizeof(nbr->auth.md5key));
+               strlcpy(nbr->auth.md5key, nbrp->auth.md5key, sizeof(nbr->auth.md5key));
                return pfkey_md5sig_establish(nbr, nbrp);
        case AUTH_NONE:
                return 0;