util: Avoid localised underflow
authorMartin Schwenke <martin@meltin.net>
Mon, 1 Jul 2019 11:28:43 +0000 (21:28 +1000)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 5 Jul 2019 01:05:21 +0000 (01:05 +0000)
commit5f7d82a88991d93d32f9cd1bbbfa3c3629e471c7
tree02ff1cc1239e1858afdfab098711b4b8bd621611
parent31345376406562e375516fdad5a1bcabf6b8dc27
util: Avoid localised underflow

Avoid parenthesising an unsigned subtraction that can be negative and,
therefore, underflow.  There is no need for the parentheses and
removing them results in an expression that is evaluated left-to-right
and can not underflow.

It isn't clear that the underflow matters.  lp <= ls, so if (li - lp)
underflows then ls + (li - lp) will always overflow.  This should
produce the correct answer.  However, depending on this seems wrong.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/util/substitute.c