aboutgitcodebugslistschat
path: root/tcp_buf.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2024-09-06 12:43:45 +0200
committerStefano Brivio <sbrivio@redhat.com>2024-09-06 13:01:34 +0200
commit63513e54f3208566ecb746d204ebeaafdd2c79c1 (patch)
tree892ee47045f8485243bbbd70cccd33d11c0fd78d /tcp_buf.c
parent748ef4cd6e7d7307b4c91cbe59ad040ef535dbdc (diff)
downloadpasst-63513e54f3208566ecb746d204ebeaafdd2c79c1.tar
passt-63513e54f3208566ecb746d204ebeaafdd2c79c1.tar.gz
passt-63513e54f3208566ecb746d204ebeaafdd2c79c1.tar.bz2
passt-63513e54f3208566ecb746d204ebeaafdd2c79c1.tar.lz
passt-63513e54f3208566ecb746d204ebeaafdd2c79c1.tar.xz
passt-63513e54f3208566ecb746d204ebeaafdd2c79c1.tar.zst
passt-63513e54f3208566ecb746d204ebeaafdd2c79c1.zip
util: Fix order of operands and carry of one second in timespec_diff_us()
If the nanoseconds of the minuend timestamp are less than the nanoseconds of the subtrahend timestamp, we need to carry one second in the subtraction. I subtracted this second from the minuend, but didn't actually carry it in the subtraction of nanoseconds, and logged timestamps would jump back whenever we switched to the first branch of timespec_diff_us() from the second one. Most likely, the reason why I didn't carry the second is that I instinctively thought that swapping the operands would have the same effect. But it doesn't, in general: that only happens with arithmetic in modulo powers of 2. Undo the swap as well. Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'tcp_buf.c')
0 files changed, 0 insertions, 0 deletions