From 844eda0f3b69e8b724fdf14fc663f808f686037f Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Sat, 5 Jan 2019 00:06:19 +0100 Subject: util/ifdtool: Fix regions_collide() check The old version was unnecessarily complex and allowed one region to include the other. Change-Id: Ibf7faf8103c8945b82c3962b5a7b82c3288b871f Signed-off-by: Nico Huber Reviewed-on: https://review.coreboot.org/c/30673 Reviewed-by: Felix Held Reviewed-by: Stefan Reinauer Tested-by: build bot (Jenkins) --- util/ifdtool/ifdtool.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'util') diff --git a/util/ifdtool/ifdtool.c b/util/ifdtool/ifdtool.c index ccd27d0dc4..69cd2a9fef 100644 --- a/util/ifdtool/ifdtool.c +++ b/util/ifdtool/ifdtool.c @@ -1153,11 +1153,8 @@ static int regions_collide(const region_t *r1, const region_t *r2) if ((r1->size == 0) || (r2->size == 0)) return 0; - if ( ((r1->base >= r2->base) && (r1->base <= r2->limit)) || - ((r1->limit >= r2->base) && (r1->limit <= r2->limit)) ) - return 1; - - return 0; + /* r1 should be either completely below or completely above r2 */ + return !(r1->limit < r2->base || r1->base > r2->limit); } void new_layout(const char *filename, char *image, int size, -- cgit v1.2.3