Re: [PATCH v2 3/3] trace-cmd: Get the timestamp of the first recorded event as TSC offset

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

 



On Fri, 16 Apr 2021 13:34:09 +0300
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@xxxxxxxxx> wrote:

> +int get_first_ts_instance(struct buffer_instance *instance)
> +{
> +	struct tracecmd_ts_corrections corrections;
> +	unsigned long long first_ts = 0;
> +	enum kbuffer_long_size long_size;
> +	enum kbuffer_endian endian;
> +	struct kbuffer *kbuf = NULL;

Small nit, but I'll leave it as it doesn't really hurt anything. But
assigning kbuf to NULL isn't needed. It gets assigned in the
kbuffer_alloc() before it is ever referenced, and the only error path
before that is a return. But if we ever add another error path, it's safe
to have it NULL.

-- Steve


> +	unsigned long long ts;
> +	unsigned int flags;
> +	int first_ts_cpu;
> +	bool first = true;
> +	char *page;
> +	char *file;
> +	int psize;
> +	int ret;
> +	int i;
> +
> +	psize = getpagesize();
> +	page = calloc(1, psize);
> +	if (!page)
> +		return -1;
> +
> +	if (tracecmd_host_bigendian())
> +		endian = KBUFFER_ENDIAN_BIG;
> +	else
> +		endian = KBUFFER_ENDIAN_LITTLE;
> +	if (sizeof(long) == 8)
> +		long_size = KBUFFER_LSIZE_8;
> +	else
> +		long_size = KBUFFER_LSIZE_4;
> +
> +	kbuf = kbuffer_alloc(long_size, endian);
> +	if (!kbuf)
> +		goto out;
> +



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

  Powered by Linux