summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsri-mohan1 <sri.mohan@samsung.com>2023-06-08 23:19:43 +0530
committersri-mohan1 <sri.mohan@samsung.com>2023-06-14 16:42:26 +0530
commit8443d112b398ded67daaaffae0539ffa2a7118a4 (patch)
treeab6c92fccca522a29296cb37247b647e0ed7f7c9
parent22c329ed32cd83ce54a1f1d014d8056d816cb28b (diff)
ldpd: changes for code maintainability
these changes are for improving the code maintainability and readability Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
-rw-r--r--ldpd/control.c18
-rw-r--r--ldpd/ldp_debug.c9
-rw-r--r--ldpd/log.c12
-rw-r--r--ldpd/logmsg.c6
-rw-r--r--ldpd/pfkey.c6
5 files changed, 17 insertions, 34 deletions
diff --git a/ldpd/control.c b/ldpd/control.c
index 6bb5204d13..db52d46325 100644
--- a/ldpd/control.c
+++ b/ldpd/control.c
@@ -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);
diff --git a/ldpd/ldp_debug.c b/ldpd/ldp_debug.c
index d2aeaba8b3..957fb8e556 100644
--- a/ldpd/ldp_debug.c
+++ b/ldpd/ldp_debug.c
@@ -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))
diff --git a/ldpd/log.c b/ldpd/log.c
index a9898a64f0..7c4d782dcf 100644
--- a/ldpd/log.c
+++ b/ldpd/log.c
@@ -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);
}
diff --git a/ldpd/logmsg.c b/ldpd/logmsg.c
index 4f1d950bb3..75f4293f0c 100644
--- a/ldpd/logmsg.c
+++ b/ldpd/logmsg.c
@@ -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",
diff --git a/ldpd/pfkey.c b/ldpd/pfkey.c
index 4bea2e1904..ae771cae19 100644
--- a/ldpd/pfkey.c
+++ b/ldpd/pfkey.c
@@ -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;