git-commit-vandalism/xdiff
Derrick Stolee 19716b21a4 cleanup: fix possible overflow errors in binary search
A common mistake when writing binary search is to allow possible
integer overflow by using the simple average:

	mid = (min + max) / 2;

Instead, use the overflow-safe version:

	mid = min + (max - min) / 2;

This translation is safe since the operation occurs inside a loop
conditioned on "min < max". The included changes were found using
the following git grep:

	git grep '/ *2;' '*.c'

Making this cleanup will prevent future review friction when a new
binary search is contructed based on existing code.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-10-10 08:57:24 +09:00
..
xdiff.h diff: retire "compaction" heuristics 2016-12-23 12:32:22 -08:00
xdiffi.c diff: retire "compaction" heuristics 2016-12-23 12:32:22 -08:00
xdiffi.h diff: add --ignore-blank-lines option 2013-06-19 15:17:45 -07:00
xemit.c xdiff -W: relax end-of-file function detection 2017-01-15 16:08:11 -08:00
xemit.h diff: add --ignore-blank-lines option 2013-06-19 15:17:45 -07:00
xhistogram.c Correct common spelling mistakes in comments and tests 2013-04-12 13:38:40 -07:00
xinclude.h
xmacros.h
xmerge.c Merge branch 'ps/plug-xdl-merge-leak' 2016-02-26 13:37:22 -08:00
xpatience.c cleanup: fix possible overflow errors in binary search 2017-10-10 08:57:24 +09:00
xprepare.c xdiff/xprepare: fix a memory leak 2016-03-04 15:51:08 -08:00
xprepare.h
xtypes.h War on whitespace 2007-06-07 00:04:01 -07:00
xutils.c xdiff: drop XDL_FAST_HASH 2016-12-06 13:27:11 -08:00
xutils.h diff: add --ignore-blank-lines option 2013-06-19 15:17:45 -07:00