Re: [PATCH v33 5/5] trace-cmd [POC]: Add KVM timestamp synchronization plugin

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

 



On Thu, 25 Mar 2021 09:14:13 +0200
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@xxxxxxxxx> wrote:

> +static int read_ll_form_file(char *file, long long *res)

Is this reading a ll form file, or is this suppose to be read ll from file?

> +{
> +	char buf[32];
> +	int ret;
> +	int fd;
> +
> +	if (!file)
> +		return -1;
> +	fd = open(file, O_RDONLY | O_NONBLOCK);
> +	if (fd < 0)
> +		return -1;
> +	ret = read(fd, buf, 32);
> +	close(fd);
> +	if (ret <= 0)
> +		return -1;
> +
> +	*res = strtoll(buf, NULL, 10);

Also, if for some reason this file produced hex this wont work. Should we
just let it detect the format?

	*res = strtoll(buf, NULL, 0);

This way both "10" and "0xa" would produce the same result.

-- Steve


> +
> +	return 0;
> +}



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

  Powered by Linux