diff mbox series

[v2,44/87] trace-cmd library: Set input handler default values in allocation function

Message ID 20210729050959.12263-45-tz.stoyanov@gmail.com (mailing list archive)
State Superseded
Headers show
Series Trace file version 7 | expand

Commit Message

Tzvetomir Stoyanov (VMware) July 29, 2021, 5:09 a.m. UTC
Set usecs flag by default when the input handler is allocated, it makes
more sense than setting it when options are handeled. This clean up is
needed for parsing version 7 trace files, where multiple options
sections may exist.

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 lib/trace-cmd/trace-input.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Steven Rostedt Aug. 19, 2021, 6:11 p.m. UTC | #1
On Thu, 29 Jul 2021 08:09:16 +0300
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:

> Set usecs flag by default when the input handler is allocated, it makes
> more sense than setting it when options are handeled. This clean up is
> needed for parsing version 7 trace files, where multiple options
> sections may exist.

Clean ups like this can also be moved to the front of the patch queue.

-- Steve

> 
> Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> ---
>  lib/trace-cmd/trace-input.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
> index 41f95874..23eea0d1 100644
> --- a/lib/trace-cmd/trace-input.c
> +++ b/lib/trace-cmd/trace-input.c
> @@ -2794,8 +2794,6 @@ static int handle_options(struct tracecmd_input *handle)
>  	int cpus;
>  	int ret;
>  
> -	/* By default, use usecs, unless told otherwise */
> -	handle->flags |= TRACECMD_FL_IN_USECS;
>  	handle->options_start = lseek64(handle->fd, 0, SEEK_CUR);
>  
>  	for (;;) {
> @@ -3448,6 +3446,9 @@ struct tracecmd_input *tracecmd_alloc_fd(int fd, int flags)
>  	handle->fd = fd;
>  	handle->ref = 1;
>  
> +	/* By default, use usecs, unless told otherwise */
> +	handle->flags |= TRACECMD_FL_IN_USECS;
> +
>  	if (do_read_check(handle, buf, 3))
>  		goto failed_read;
>
diff mbox series

Patch

diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 41f95874..23eea0d1 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -2794,8 +2794,6 @@  static int handle_options(struct tracecmd_input *handle)
 	int cpus;
 	int ret;
 
-	/* By default, use usecs, unless told otherwise */
-	handle->flags |= TRACECMD_FL_IN_USECS;
 	handle->options_start = lseek64(handle->fd, 0, SEEK_CUR);
 
 	for (;;) {
@@ -3448,6 +3446,9 @@  struct tracecmd_input *tracecmd_alloc_fd(int fd, int flags)
 	handle->fd = fd;
 	handle->ref = 1;
 
+	/* By default, use usecs, unless told otherwise */
+	handle->flags |= TRACECMD_FL_IN_USECS;
+
 	if (do_read_check(handle, buf, 3))
 		goto failed_read;