Re: [PATCH 2/7] trace-cmd: Added new option in trace.dat file for negative time offsets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 16 Jan 2019 21:18:33 +0200
Tzvetomir Stoyanov <tstoyanov@xxxxxxxxxx> wrote:

> diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
> index b628570..de15d4b 100644
> --- a/lib/trace-cmd/trace-input.c
> +++ b/lib/trace-cmd/trace-input.c
> @@ -2151,6 +2151,7 @@ static int handle_options(struct tracecmd_input *handle)
>  			handle->ts_offset += offset;
>  			break;
>  		case TRACECMD_OPTION_OFFSET:
> +		case TRACECMD_OPTION_OFFSET_N:
>  			/*
>  			 * Similar to date option, but just adds an
>  			 * offset to the timestamp.
> @@ -2158,7 +2159,11 @@ static int handle_options(struct tracecmd_input *handle)
>  			if (handle->flags & TRACECMD_FL_IGNORE_DATE)
>  				break;
>  			offset = strtoll(buf, NULL, 0);
> -			handle->ts_offset += offset;
> +			if (option == TRACECMD_OPTION_OFFSET_N) {

Instead of adding a new option, couldn't we just make option a "long
long" and save a negative number in the trace.dat file? strtoll()
should be able to handle it.

-- Steve


> +				if (handle->ts_offset > offset)
> +					handle->ts_offset -= offset;
> +			} else
> +				handle->ts_offset += offset;
>  			break;
>  		case TRACECMD_OPTION_CPUSTAT:
>  			buf[size-1] = '\n';



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux