From patchwork Tue Jul 23 20:38:40 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: 813991 Delivered-To: patch@linaro.org Received: by 2002:adf:f288:0:b0:367:895a:4699 with SMTP id k8csp2490003wro; Tue, 23 Jul 2024 13:43:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVS0Cr47XBJ8Ud3aoLcyKNSRn8N98ODUxa+5uXRkxKekybjeNwnRGmkxqZRiSiLPaLSkXDUrx/RglaIjHmlsHMN X-Google-Smtp-Source: AGHT+IEkQzgP1wuvqrRAK251KbOhtF33ZmxRj5pNtG0Adr8pfgvjSVheWH+o7O50XWALlWir5WEc X-Received: by 2002:a05:622a:190b:b0:447:e046:8482 with SMTP id d75a77b69052e-44fa5281649mr116336301cf.23.1721767417505; Tue, 23 Jul 2024 13:43:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1721767417; cv=none; d=google.com; s=arc-20160816; b=qkhpqQ2hx/Y5O0bBoEh/yGowNpDCbruMtrWtXlj8K8Sr351ux6/fFGZpjbSW3HWbXN CoE4ahb43jFG2DLldL5yTGQtLF2qM3oXNvoCl/55KetjwP/cgh3SYPPKS1Dv9iX1IvVS PeHcdtrK8U2LG6oxpU1E7CQcApBiX6VJKWzb1gOsSycXEjx6EVGUDSG56TbjC7MtA2yZ JmWQTvR+1+6pgYeP01pbpQFbeAuOcljhdfBh137f5PlRJAOvoKWt8KFctcQC7Mdv7QwF elkXGMvHmrzWcWl6P0WIVNKKBcNLDSswTOOq1mhP2rFQN3KFq6OLHJEJMO4HW4akfNlF YnAg== 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=efl2J6FZMNBybvIOohahy/rqbvmAN7ozlP6FIF0OQ4s=; fh=2T+KfhuSLAapjLkuIGm4M/wQO1FbRA2dukK4EuTVnoI=; b=xJzRIQOVNFjDSPunBkvohguiX/gd+uCCV+YVJ97JLl/L7HUKC0K5eLrYugCPznh/89 oFH66dRF3KBs9+soJ7w0JXM86mkYbhUBPb+ODNY22jPucrxJb4lxaRXfLw4QcneV9ZA5 Q96oIWL+czh2A1EwyiNCeAuSzAcm6ceitc/ElB2Jl8v1yXTxtwvwi3R4DcrZzQ9luSo9 nQNHL7lw4ewaOwtymk9RoYiCN0Eu5XjR2DwaZ8sS7ciUu4n0OApBxASSzFNBhoMOKqkT S3a8ElD3zj7l1u3u/zZGClckIFuLWl928jQ+3e5xfmBUZIu36KGJTh0IM8xuzC65CQ1/ 178w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QfZaLrxW; 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-44f9ccfb398si106007271cf.33.2024.07.23.13.43.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Jul 2024 13:43:37 -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=QfZaLrxW; 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 1sWMJI-0000uu-12; Tue, 23 Jul 2024 16:40:36 -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 1sWMIy-0007Y6-Fi for qemu-devel@nongnu.org; Tue, 23 Jul 2024 16:40:18 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sWMIw-0004Fh-GE for qemu-devel@nongnu.org; Tue, 23 Jul 2024 16:40:15 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-426526d30aaso44701285e9.0 for ; Tue, 23 Jul 2024 13:40:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1721767211; x=1722372011; 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=efl2J6FZMNBybvIOohahy/rqbvmAN7ozlP6FIF0OQ4s=; b=QfZaLrxWWJ40W9K54k+09t0exDCPNjKY9S2tOAT4/qLaLQTvZDWLLgKUjttgmw2L+L PktN9OnMXGvhKfjhHgJ7azSYBfv9ikbZ1gZhVFoL9kGbFGaNbXU4PXmFWoqSR3U2d9gS UizxYFtFvRQcVGo42YHFidEjOi3+vpT7k80YPLP3yNkRqIjiD4B24DS1FNMxQo/gPFIf DaT8IU6W9xLo1dyeCN1MyMjI51U1iSmjjCxjUMeZDvb4UH9u2752bNU5GmsuLq1cM90k 2bB/dOgncAEV5cmsTrLNH96zazlZ62wSTa5dPx6yyhvtO6YjmVlzNjkkQbtr3wTyjx41 ASoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721767211; x=1722372011; 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=efl2J6FZMNBybvIOohahy/rqbvmAN7ozlP6FIF0OQ4s=; b=ua8OGrB7gzbdv/VwYdXQp0bEg4kdMdW1YzvALbWQvKi8DRPEef6fdGZTjbkN8eP8ZL gast4moUEogPyzq5kR5oIf5yUn1XCAqV8AnVdj1J8dzCjL6Woch55LljhAYSICRL2v3D HXMxvtrloEAGxHvejj1v1Udsj/cmITgWtj6Na3VuDxnZurs/Lq4lsuUlh18ht7CHlvf0 ZQyHMBVxpQoqg7z5D7KnHh9jPY09Fx3FKcmocmoVQBNG6IEA5r3eztyLP2KSifJQTJwy iIfC6l/fogpjTTS4RcwD7BHP2qxOTivqb8LRK/xBvGfOfe5lDUhwDZvHgAivgEfgca8t e3QA== X-Gm-Message-State: AOJu0YzV9Nsf1zAssu18yuXlJ1wEsyMFHmCweO9B0iRMk8AwrhUUVU2+ 0Bx4qJ03SVtk0q+4c0BJ0Eqr6pph7DaLHiweqvUxRVFijwgoWe50IrgBKBOShsqKt6tU1B8dx1p E7js= X-Received: by 2002:a05:600c:4586:b0:426:6f0e:a60 with SMTP id 5b1f17b1804b1-427f955c2d4mr81865e9.17.1721767211490; Tue, 23 Jul 2024 13:40:11 -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 5b1f17b1804b1-427f9413663sm316075e9.45.2024.07.23.13.40.10 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 23 Jul 2024 13:40:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Yao Xingtao , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PULL 13/28] cxl/mailbox: make range overlap check more readable Date: Tue, 23 Jul 2024 22:38:40 +0200 Message-ID: <20240723203855.65033-14-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::332; envelope-from=philmd@linaro.org; helo=mail-wm1-x332.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: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Message-ID: <20240722040742.11513-5-yaoxt.fnst@fujitsu.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/cxl/cxl-mailbox-utils.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 74eeb6fde73..507690c0dd1 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1086,8 +1086,8 @@ static CXLRetCode cmd_media_get_poison_list(const struct cxl_cmd *cmd, QLIST_FOREACH(ent, poison_list, node) { /* Check for no overlap */ - if (ent->start >= query_start + query_length || - ent->start + ent->length <= query_start) { + if (!ranges_overlap(ent->start, ent->length, + query_start, query_length)) { continue; } record_count++; @@ -1100,8 +1100,8 @@ static CXLRetCode cmd_media_get_poison_list(const struct cxl_cmd *cmd, uint64_t start, stop; /* Check for no overlap */ - if (ent->start >= query_start + query_length || - ent->start + ent->length <= query_start) { + if (!ranges_overlap(ent->start, ent->length, + query_start, query_length)) { continue; }