From patchwork Tue Jul 23 20:38:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 813981 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2489502wro; Tue, 23 Jul 2024 13:42:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUbfdw1ScMVN8/d5vZlaQxgRwT0AhqAegcdOBBpP0fxYgWd6XFt4lcUXN3V2WTMbRrop7gQN3pVyR92o/gNi35L X-Google-Smtp-Source: AGHT+IHm72/jF1yqkzKYkZB/kdll6YBEtDTcRYn/YnDMcW7oEs+DLHsxI5FpES5VsNOy03MZy0PU X-Received: by 2002:a05:6102:5713:b0:493:b484:ac06 with SMTP id ada2fe7eead31-493c19ee819mr695203137.21.1721767321874; Tue, 23 Jul 2024 13:42:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721767321; cv=none; d=google.com; s=arc-20160816; b=Z25VAiDllrjnTFL2KQ4k5DWj5jiNwgqq3lCoowYezGa/jtnDW67VOztwIl9nxvietA ijySfHLGoB2Jp95kqybaWy6wAwjv76hXaALdH8ZcUhh2/+/T+bS4tEwDVlz+lKqWyKRD LHV3xfPrkOKrReTE5hhFHzeDWNP3dvwRlovou5YDJ3bH5/U6fZ1JXn6Y4lUSim822hip MVx4aRqHvlEYWTHQ58QuGk/xQ3BXspKsrlbl3+1zboklLULtnyWxMTOg0OpwH2xIl2id M0vqOAeHUGnC9LWWd+LpYc9aikRPLQKA4dlU8V9ns6PS/Roh0EKvClIQWsxonnq7tX3P IFBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2N8bD0EiQwQSfnPzHE5ISzd574iE9UTxrUPygv1PgWk=; fh=/qvncaaVouBG2u7u0xelaaO0gOBYgzka2KHwazWJUws=; b=srSeMDdSN+1Em9FaOwJIpydQeDN28Gf009oHPPkvNYAGeL1gybzUEB2fogOVTZbSn/ Ey+qiTeX5lV+4ABAiRSsXJiKv/s6/rXxuiRUc5nWQMbCGrnSFsclfoSm415fx3DuAY0S mIFp8+8jmnFDuV+Qf1eb9p0zxeBVGDMYJMF5I1nXf6GyB6+H+g1/8g6QPkfECARHhup7 IGG5eOJzpY8WN1tGt+8g3z7+u0b46ems1KXZuAusZQm5NjmM8vNBL5NTkvZf78Nup5qM xU3FWjiJbZn6lMyUBu9M5ZqRV3NDBIM99CrtN7eC+8rAJ1f+GaaEWeuVUsSZKDfljzdW WzpA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X6CifGpN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-44f9cdb8264si118340811cf.366.2024.07.23.13.42.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jul 2024 13:42:01 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X6CifGpN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWMJb-00036i-Gi; Tue, 23 Jul 2024 16:40:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sWMJK-0001I6-5u for qemu-devel@nongnu.org; Tue, 23 Jul 2024 16:40:42 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sWMJI-0004Ne-25 for qemu-devel@nongnu.org; Tue, 23 Jul 2024 16:40:37 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-367963ea053so4295768f8f.2 for ; Tue, 23 Jul 2024 13:40:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721767234; x=1722372034; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2N8bD0EiQwQSfnPzHE5ISzd574iE9UTxrUPygv1PgWk=; b=X6CifGpN5f7R3sDxPih/4GB9XCUk2rV/FSV675VobXIQ3u+IGjRkO15SFAzgbivmmt IStqD4XS/KuuYvPamc60xPK9LXAz9oNHDa691sI1X+jEf/t235JtOK+CGatIJUsMFnQm GdaI6k4Fkr/D+UWEObuIBbYAvKry7sPvGBV4zO5pfI750p20MrbKWFs4J82MSGgRghLj meE1FVLgrUU0pSEKf4IJhfoiH0mKZDL8f0U9oQ3O4jQN3+5vJr5SXZO9adgdpZiBW3nN T9VRy6KgVrT1bHcz9c4CfuaE74tAG09bC/hsVg88I7sUPAjr78KLZ9IZXoCtNWJ60kNc ynwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721767234; x=1722372034; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2N8bD0EiQwQSfnPzHE5ISzd574iE9UTxrUPygv1PgWk=; b=sd0eD4pNQBKPrPfzC2XJMr+RR037nX5JTZY2gqTAdJt5D13jMSVVqedgMVBOR9bEwF hsGkMNuB626XgYoO3r1skcclbZYK/Ml1/0h6k3cpLf4B1xXP4gJo3e4LQSxSShesGTT8 rWE2BnFW3L2tg0upDYCDVslt4uEHUDh/s7uNp7LSoertISZp/cO/aZW0SDow7arxC8lf 77ohg9Q3LoAau+M5TN0fLu2Il9SZ6GC1IPSUhT0ixDYVT0SPK2DUxUHvK4JOFxSG/yrn hnibJ3MYgVDiLdNFNE4k2wxDraOCPNR9zlbOpQOX1gg2kvHLyEOowQQTgLnWzZ1zLYwT 52oA== X-Gm-Message-State: AOJu0Yxj4J2tX5KIbTAs855uiYII6J/rmPcy2+pk8TDavgBAtkWaUA2P sSTzNJdKSQ4XQlDaJY27FgQ7qENtEnDCxgHx1BI4/tiPVhUNQUaL9ygILSJa23JMc5/W+UpnrsX clCU= X-Received: by 2002:a5d:5751:0:b0:367:9d4e:8861 with SMTP id ffacd0b85a97d-369f0a994acmr632762f8f.57.1721767234014; Tue, 23 Jul 2024 13:40:34 -0700 (PDT) Received: from localhost.localdomain (vbo91-h01-176-184-50-4.dsl.sta.abo.bbox.fr. [176.184.50.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-368787cee03sm12462353f8f.76.2024.07.23.13.40.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 Jul 2024 13:40:33 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Yao Xingtao , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PULL 17/28] dump: make range overlap check more readable Date: Tue, 23 Jul 2024 22:38:44 +0200 Message-ID: <20240723203855.65033-18-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240723203855.65033-1-philmd@linaro.org> References: <20240723203855.65033-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=philmd@linaro.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Yao Xingtao use ranges_overlap() instead of open-coding the overlap check to improve the readability of the code. Signed-off-by: Yao Xingtao Reviewed-by: Marc-André Lureau Message-ID: <20240722040742.11513-13-yaoxt.fnst@fujitsu.com> Signed-off-by: Philippe Mathieu-Daudé --- dump/dump.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dump/dump.c b/dump/dump.c index 84064d890d2..45e84428aea 100644 --- a/dump/dump.c +++ b/dump/dump.c @@ -30,6 +30,7 @@ #include "migration/blocker.h" #include "hw/core/cpu.h" #include "win_dump.h" +#include "qemu/range.h" #include #ifdef CONFIG_LZO @@ -574,8 +575,10 @@ static void get_offset_range(hwaddr phys_addr, QTAILQ_FOREACH(block, &s->guest_phys_blocks.head, next) { if (dump_has_filter(s)) { - if (block->target_start >= s->filter_area_begin + s->filter_area_length || - block->target_end <= s->filter_area_begin) { + if (!ranges_overlap(block->target_start, + block->target_end - block->target_start, + s->filter_area_begin, + s->filter_area_length)) { /* This block is out of the range */ continue; } @@ -734,8 +737,9 @@ int64_t dump_filtered_memblock_start(GuestPhysBlock *block, { if (filter_area_length) { /* return -1 if the block is not within filter area */ - if (block->target_start >= filter_area_start + filter_area_length || - block->target_end <= filter_area_start) { + if (!ranges_overlap(block->target_start, + block->target_end - block->target_start, + filter_area_start, filter_area_length)) { return -1; }