[PATCH u-boot-marvell v2 15/39] tools: kwboot: Allow greater timeout when executing header code

Marek Behún marek.behun at nic.cz
Tue Sep 7 23:53:09 CEST 2021


On Tue,  7 Sep 2021 11:58:13 +0200
Marek Behún <marek.behun at nic.cz> wrote:

> +static uint64_t
> +_now(void)
> +{
> +	struct timespec ts;
> +
> +	if (clock_gettime(CLOCK_MONOTONIC, &ts)) {
> +		static int err_print;
> +
> +		if (!err_print) {
> +			perror("clock_gettime() does not work");
> +			err_print = 1;
> +		}
> +
> +		/* this will just make the timeout not work */
> +		return -1ULL;
> +	}
> +
> +	return ts.tv_sec * 1000 + (ts.tv_nsec + 500000) / 1000000;

We need u64 literal here to avoid overflow:
  return ts.tv_sec * 1000ULL + (ts.tv_nsec + 500000) / 1000000;

Marek


More information about the U-Boot mailing list