Skip to content
Snippets Groups Projects
Commit 92e483f8 authored by Ganesh Ajjanagadde's avatar Ganesh Ajjanagadde
Browse files

all: use FFDIFFSIGN to resolve possible undefined behavior in comparators


FFDIFFSIGN was created explicitly for this purpose, since the common
return a - b idiom is unsafe regarding overflow on signed integers. It
optimizes to branchless code on common compilers.

FFDIFFSIGN also has the subjective benefit of being easier to read due
to lack of ternary operators.

Tested with FATE.

Things not covered by this are unsigned integers, for which overflows
are well defined, and also places where overflow is clearly impossible,
e.g an instance where the a - b was being done on 24 bit values.

Reviewed-by: default avatarMichael Niedermayer <michael@niedermayer.cc>
Reviewed-by: default avatarClément Bœsch <u@pkh.me>
Signed-off-by: default avatarGanesh Ajjanagadde <gajjanagadde@gmail.com>
parent 265f83fd
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment