Re: [PATCH v2 4/4] ibacm: Use MONOTONIC time base to avoid timer expiration issues

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

 



On Mon, Nov 13, 2017 at 04:25:04PM -0500, Michael J. Ruhl wrote:

Sorry, noticed a few more wonky things:

>  #define event_signal(e)	pthread_cond_signal(&(e)->cond)
>  #define ONE_SEC_IN_NSEC  1000000000

That should be 1000000000ULL so math doesn't accidental truncate

> +	clock_gettime(CLOCK_MONOTONIC, &wait);
> +	wait.tv_sec = wait.tv_sec + ((unsigned) timeout) / 1000;
> +	wait.tv_nsec = (wait.tv_nsec + (((unsigned) timeout) % 1000) * 1000000);

Why the odd casts to (unsigned) ? That should be (unsigned int)

> -	return (uint64_t) curtime.tv_sec * 1000000 + (uint64_t) curtime.tv_usec;
> +	struct timespec t;
> +	clock_gettime(CLOCK_MONOTONIC, &t);
> +	return ((uint64_t)t.tv_sec * ONE_SEC_IN_NSEC + (uint64_t)t.tv_nsec) / 1000;

These casts to uint64_t are also wrong, time is technically
signed. The change to ONE_SEC_IN_NSEC should remove the need
for the casting.

Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux