* [PATCH] logger: remove trailing spaces when outputing to journal
@ 2016-07-18 20:34 Sami Kerola
2016-07-18 20:49 ` Sami Kerola
0 siblings, 1 reply; 3+ messages in thread
From: Sami Kerola @ 2016-07-18 20:34 UTC (permalink / raw)
To: util-linux; +Cc: Sami Kerola
Issues:
1. Whitespace-ish \r is not stripped, while it should be.
2. In journal \r is considered unprintable.
Lennart: "it is the duty of the client side to drop the trailing whitespace,
which "logger" doesn't do".
Reported-by: Ivan Babrou <ibobrik@gmail.com>
Explained-by: Lennart Poettering <lennart@poettering.net>
Reference: https://github.com/systemd/systemd/issues/3416
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
misc-utils/logger.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 9f2940c..6251f96 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -341,14 +341,10 @@ static int journald_entry(struct logger_ctl *ctl, FILE *fp)
for (lines = 0; /* nothing */ ; lines++) {
buf = NULL;
sz = getline(&buf, &dummy, fp);
- if (sz == -1) {
+ if (sz == -1 && (sz = rtrim_whitespace(buf)) != 0) {
free(buf);
break;
}
- if (0 < sz && buf[sz - 1] == '\n') {
- sz--;
- buf[sz] = '\0';
- }
if (lines == vectors) {
vectors *= 2;
if (IOV_MAX < vectors)
--
2.9.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] logger: remove trailing spaces when outputing to journal
2016-07-18 20:34 [PATCH] logger: remove trailing spaces when outputing to journal Sami Kerola
@ 2016-07-18 20:49 ` Sami Kerola
2016-07-19 9:10 ` Karel Zak
0 siblings, 1 reply; 3+ messages in thread
From: Sami Kerola @ 2016-07-18 20:49 UTC (permalink / raw)
To: util-linux
On Mon, 18 Jul 2016, Sami Kerola wrote:
> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Hi Sami, no repeat 100 time: do not send patches before testing them.
Let me try again, and also available from
https://github.com/kerolasa/lelux-utiliteetit/commit/076ce184fea4591bd364d77474fcfffdcad73a5b
--->8----
From: Sami Kerola <kerolasa@iki.fi>
Date: Mon, 18 Jul 2016 21:15:54 +0100
Subject: [PATCH] logger: remove trailing spaces when outputing to journal
Issues:
1. Whitespace-ish \r is not stripped, while it should be.
2. In journal \r is considered unprintable.
Lennart: "it is the duty of the client side to drop the trailing whitespace,
which "logger" doesn't do".
Reported-by: Ivan Babrou <ibobrik@gmail.com>
Explained-by: Lennart Poettering <lennart@poettering.net>
Reference: https://github.com/systemd/systemd/issues/3416
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
misc-utils/logger.c | 7 ++-----
tests/expected/logger/journald | 1 -
2 files changed, 2 insertions(+), 6 deletions(-)
diff --git a/misc-utils/logger.c b/misc-utils/logger.c
index 9f2940c..70fac68 100644
--- a/misc-utils/logger.c
+++ b/misc-utils/logger.c
@@ -341,14 +341,11 @@ static int journald_entry(struct logger_ctl *ctl, FILE *fp)
for (lines = 0; /* nothing */ ; lines++) {
buf = NULL;
sz = getline(&buf, &dummy, fp);
- if (sz == -1) {
+ if (sz == -1 ||
+ (sz = rtrim_whitespace((unsigned char *) buf)) == 0) {
free(buf);
break;
}
- if (0 < sz && buf[sz - 1] == '\n') {
- sz--;
- buf[sz] = '\0';
- }
if (lines == vectors) {
vectors *= 2;
if (IOV_MAX < vectors)
diff --git a/tests/expected/logger/journald b/tests/expected/logger/journald
index 75bd0f3..354628d 100644
--- a/tests/expected/logger/journald
+++ b/tests/expected/logger/journald
@@ -1,4 +1,3 @@
MESSAGE_ID=b8f74e14bc714bfc8040a5106dc9376a
MESSAGE=a b c 1 2 3
-
ret: 0
--
2.9.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] logger: remove trailing spaces when outputing to journal
2016-07-18 20:49 ` Sami Kerola
@ 2016-07-19 9:10 ` Karel Zak
0 siblings, 0 replies; 3+ messages in thread
From: Karel Zak @ 2016-07-19 9:10 UTC (permalink / raw)
To: Sami Kerola; +Cc: util-linux
On Mon, Jul 18, 2016 at 09:49:27PM +0100, Sami Kerola wrote:
> Hi Sami, no repeat 100 time: do not send patches before testing them.
Always code as if the person who ends up maintaining your code is a
violent psychopath who knows where you live [1].
... just to make you feel better :-))
[1] http://c2.com/cgi/wiki?CodeForTheMaintainer
> ---
> misc-utils/logger.c | 7 ++-----
> tests/expected/logger/journald | 1 -
> 2 files changed, 2 insertions(+), 6 deletions(-)
Applied, thanks!
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-19 9:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-18 20:34 [PATCH] logger: remove trailing spaces when outputing to journal Sami Kerola
2016-07-18 20:49 ` Sami Kerola
2016-07-19 9:10 ` Karel Zak
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.