[git commit] Use chomp to remove newlines

Denys Vlasenko vda.linux at googlemail.com
Thu Mar 12 19:18:51 UTC 2015


commit: http://git.busybox.net/busybox/commit/?id=8ec1ff350c28ae691ee80a001c7786f4ad8abe47
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
unix_do_one                                          548     540      -8
process_timer_stats                                  508     500      -8
process_irq_counts                                   532     524      -8
lpd_main                                             839     831      -8
hwclock_main                                         502     494      -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 0/6 up/down: 0/-50)             Total: -40 bytes

Signed-off-by: Ron Yorston <rmy at tigress.co.uk>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 networking/netstat.c |    2 +-
 printutils/lpd.c     |    2 +-
 procps/powertop.c    |    4 ++--
 util-linux/hwclock.c |    2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/networking/netstat.c b/networking/netstat.c
index 02f4cc7..1303d3f 100644
--- a/networking/netstat.c
+++ b/networking/netstat.c
@@ -622,7 +622,7 @@ static int FAST_FUNC unix_do_one(char *line)
 
 	/* TODO: currently we stop at first NUL byte. Is it a problem? */
 	line += path_ofs;
-	*strchrnul(line, '\n') = '\0';
+	chomp(line);
 	while (*line)
 		fputc_printable(*line++, stdout);
 	bb_putchar('\n');
diff --git a/printutils/lpd.c b/printutils/lpd.c
index 642e8a8..eaf42c0 100644
--- a/printutils/lpd.c
+++ b/printutils/lpd.c
@@ -204,7 +204,7 @@ int lpd_main(int argc UNUSED_PARAM, char *argv[])
 			goto err_exit;
 		}
 		// get filename
-		*strchrnul(s, '\n') = '\0';
+		chomp(s);
 		fname = strchr(s, ' ');
 		if (!fname) {
 // bad_fname:
diff --git a/procps/powertop.c b/procps/powertop.c
index 18affac..1de5d32 100644
--- a/procps/powertop.c
+++ b/procps/powertop.c
@@ -360,7 +360,7 @@ static void process_irq_counts(void)
 		}
 
 		name = p;
-		strchrnul(name, '\n')[0] = '\0';
+		chomp(p);
 		/* Save description of the interrupt */
 		if (nr >= 20000)
 			sprintf(irq_desc, "   <kernel IPI> : %s", name);
@@ -470,7 +470,7 @@ static NOINLINE int process_timer_stats(void)
 				process = idx < 2 ? "[kernel module]" : "<kernel core>";
 			}
 
-			strchrnul(p, '\n')[0] = '\0';
+			chomp(p);
 
 			// 46D\01136\0kondemand/1\0do_dbs_timer (delayed_work_timer_fn)
 			// ^          ^            ^
diff --git a/util-linux/hwclock.c b/util-linux/hwclock.c
index 3f53155..6c99977 100644
--- a/util-linux/hwclock.c
+++ b/util-linux/hwclock.c
@@ -69,7 +69,7 @@ static void show_clock(const char **pp_rtcname, int utc)
 	strftime(cp, sizeof(cp), "%c", ptm);
 #else
 	char *cp = ctime(&t);
-	strchrnul(cp, '\n')[0] = '\0';
+	chomp(cp);
 #endif
 
 #if !SHOW_HWCLOCK_DIFF


More information about the busybox-cvs mailing list