diff mbox series

[18/38] trace-cmd lib: remove useless code in tracecmd_plog()

Message ID 20240605134054.2626953-19-jmarchan@redhat.com (mailing list archive)
State Accepted
Commit 93a8dd946aaae5366fb8012b702fb3578938e01b
Headers show
Series trace-cmd: fix misc issues found by static analysis | expand

Commit Message

Jerome Marchand June 5, 2024, 1:40 p.m. UTC
In __plog(), both branch of the "if (newline)" statement are
identical. I guess the original intent was to print a newline if the
last message didn't end in one. But it seems that all messages send to
tracecmd_plog() terminates with a newline and are short enough to not
get truncated.

Remove all newline code that doesn't do anything.

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
---
 lib/trace-cmd/trace-util.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c
index 47ca3db1..a4334a98 100644
--- a/lib/trace-cmd/trace-util.c
+++ b/lib/trace-cmd/trace-util.c
@@ -453,7 +453,6 @@  void __weak tracecmd_debug(const char *fmt, ...)
 #define LOG_BUF_SIZE 1024
 static void __plog(const char *prefix, const char *fmt, va_list ap, FILE *fp)
 {
-	static int newline = 1;
 	char buf[LOG_BUF_SIZE];
 	int r;
 
@@ -463,11 +462,7 @@  static void __plog(const char *prefix, const char *fmt, va_list ap, FILE *fp)
 		r = LOG_BUF_SIZE;
 
 	if (logfp) {
-		if (newline)
-			fprintf(logfp, "[%d]%s%.*s", getpid(), prefix, r, buf);
-		else
-			fprintf(logfp, "[%d]%s%.*s", getpid(), prefix, r, buf);
-		newline = buf[r - 1] == '\n';
+		fprintf(logfp, "[%d]%s%.*s", getpid(), prefix, r, buf);
 		fflush(logfp);
 		return;
 	}