[PATCH 4/4] ipconfig: cleanup printk usage

From: John Ogness
Date: Fri Jul 17 2020 - 19:49:09 EST


The use of pr_info() and pr_cont() was not ordered correctly for
all cases. Order it so that all cases provide the expected output.

Signed-off-by: John Ogness <john.ogness@xxxxxxxxxxxxx>
---
net/ipv4/ipconfig.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
index 561f15b5a944..0f4bd7a59310 100644
--- a/net/ipv4/ipconfig.c
+++ b/net/ipv4/ipconfig.c
@@ -1442,6 +1442,9 @@ static int __init ip_auto_config(void)
#endif
int err;
unsigned int i;
+#ifndef IPCONFIG_SILENT
+ bool pr0;
+#endif

/* Initialise all name servers and NTP servers to NONE (but only if the
* "ip=" or "nfsaddrs=" kernel command line parameters weren't decoded,
@@ -1575,31 +1578,37 @@ static int __init ip_auto_config(void)
if (ic_dev_mtu)
pr_cont(", mtu=%d", ic_dev_mtu);
/* Name servers (if any): */
+ pr0 = false;
for (i = 0; i < CONF_NAMESERVERS_MAX; i++) {
if (ic_nameservers[i] != NONE) {
- if (i == 0)
+ if (!pr0) {
pr_info(" nameserver%u=%pI4",
i, &ic_nameservers[i]);
- else
+ pr0 = true;
+ } else {
pr_cont(", nameserver%u=%pI4",
i, &ic_nameservers[i]);
+ }
}
- if (i + 1 == CONF_NAMESERVERS_MAX)
- pr_cont("\n");
}
+ if (pr0)
+ pr_cont("\n");
/* NTP servers (if any): */
+ pr0 = false;
for (i = 0; i < CONF_NTP_SERVERS_MAX; i++) {
if (ic_ntp_servers[i] != NONE) {
- if (i == 0)
+ if (!pr0) {
pr_info(" ntpserver%u=%pI4",
i, &ic_ntp_servers[i]);
- else
+ pr0 = true;
+ } else {
pr_cont(", ntpserver%u=%pI4",
i, &ic_ntp_servers[i]);
+ }
}
- if (i + 1 == CONF_NTP_SERVERS_MAX)
- pr_cont("\n");
}
+ if (pr0)
+ pr_cont("\n");
#endif /* !SILENT */

/*
--
2.20.1