All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH 4/5] trace-cmd library: Remove APIs for create and init output handle
Date: Thu,  2 Dec 2021 14:19:48 +0200	[thread overview]
Message-ID: <20211202121949.43084-5-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20211202121949.43084-1-tz.stoyanov@gmail.com>

These APIs are redundant, their functionality can be replaced by
existing library APIs. Removed them, to simplify the API set:
  tracecmd_create_init_fd()
  tracecmd_create_init_file()

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 .../include/private/trace-cmd-private.h       |  2 --
 lib/trace-cmd/trace-output.c                  | 36 -------------------
 tracecmd/trace-stream.c                       |  3 +-
 3 files changed, 2 insertions(+), 39 deletions(-)

diff --git a/lib/trace-cmd/include/private/trace-cmd-private.h b/lib/trace-cmd/include/private/trace-cmd-private.h
index 79196147..069283c7 100644
--- a/lib/trace-cmd/include/private/trace-cmd-private.h
+++ b/lib/trace-cmd/include/private/trace-cmd-private.h
@@ -281,9 +281,7 @@ int tracecmd_output_write_headers(struct tracecmd_output *handle,
 struct tracecmd_output *tracecmd_output_create(const char *output_file);
 struct tracecmd_output *tracecmd_output_create_fd(int fd);
 struct tracecmd_output *tracecmd_create_file_latency(const char *output_file, int cpus);
-struct tracecmd_output *tracecmd_create_init_fd(int fd);
 
-struct tracecmd_output *tracecmd_create_init_file(const char *output_file);
 struct tracecmd_option *tracecmd_add_option(struct tracecmd_output *handle,
 					    unsigned short id, int size,
 					    const void *data);
diff --git a/lib/trace-cmd/trace-output.c b/lib/trace-cmd/trace-output.c
index 067deae8..a20e42df 100644
--- a/lib/trace-cmd/trace-output.c
+++ b/lib/trace-cmd/trace-output.c
@@ -1828,42 +1828,6 @@ struct tracecmd_output *tracecmd_output_create(const char *output_file)
 	return out;
 }
 
-struct tracecmd_output *tracecmd_create_init_fd(int fd)
-{
-	struct tracecmd_output *out;
-
-	out = tracecmd_output_create_fd(fd);
-	if (!out)
-		return NULL;
-	if (tracecmd_output_write_init(out))
-		goto error;
-	if (tracecmd_output_write_headers(out, NULL))
-		goto error;
-
-	return out;
-error:
-	tracecmd_output_close(out);
-	return NULL;
-}
-
-struct tracecmd_output *tracecmd_create_init_file(const char *output_file)
-{
-	struct tracecmd_output *handle;
-	int fd;
-
-	fd = open(output_file, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, 0644);
-	if (fd < 0)
-		return NULL;
-	handle = tracecmd_create_init_fd(fd);
-	if (!handle) {
-		close(fd);
-		unlink(output_file);
-		return NULL;
-	}
-
-	return handle;
-}
-
 /**
  * tracecmd_copy - copy the headers of one trace.dat file for another
  * @ihandle: input handle of the trace.dat file to copy
diff --git a/tracecmd/trace-stream.c b/tracecmd/trace-stream.c
index b47b208c..ee310f3d 100644
--- a/tracecmd/trace-stream.c
+++ b/tracecmd/trace-stream.c
@@ -43,11 +43,12 @@ trace_stream_init(struct buffer_instance *instance, int cpu, int fd, int cpus,
 		tfd = fileno(fp);
 
 		ofd = dup(tfd);
-		trace_output = tracecmd_create_init_fd(ofd);
+		trace_output = tracecmd_output_create_fd(ofd);
 		if (!trace_output) {
 			fclose(fp);
 			return NULL;
 		}
+		tracecmd_output_write_headers(trace_output, NULL);
 		tracecmd_output_free(trace_output);
 	}
 
-- 
2.33.1


  parent reply	other threads:[~2021-12-02 12:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-02 12:19 [PATCH 0/5] Cleanups of tracecmd_output_ APIs Tzvetomir Stoyanov (VMware)
2021-12-02 12:19 ` [PATCH 1/5] trace-cmd library: Fix typo in tracecmd_output_set_msg() Tzvetomir Stoyanov (VMware)
2021-12-02 12:19 ` [PATCH 2/5] trace-cmd library: New API for creating an output trace handle Tzvetomir Stoyanov (VMware)
2021-12-02 12:19 ` [PATCH 3/5] trace-cmd library: Rename tracecmd_output_allocate() Tzvetomir Stoyanov (VMware)
2021-12-02 12:19 ` Tzvetomir Stoyanov (VMware) [this message]
2021-12-02 12:19 ` [PATCH 5/5] trace-cmd library: Make tracecmd_output_write_init static Tzvetomir Stoyanov (VMware)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211202121949.43084-5-tz.stoyanov@gmail.com \
    --to=tz.stoyanov@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.