Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1572017lqt; Wed, 20 Mar 2024 07:58:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW5upxiVAMO/PvAvBL0m+Q/mZ8GWUFfn020v31mB7q4SLQ2HUy855wMXHAkotv+HcgBSpCdBLTjyO8Is9qqETyPTeJ+rx50aMuWglxYFA== X-Google-Smtp-Source: AGHT+IFfDVR2JMi2+G3d7ChP2SFihSpwka9E/MHEXBV0y+xvMfqYRz4WCUN80HazbbCsXG9WfqD+ X-Received: by 2002:a05:6902:2211:b0:dd9:20df:d5d with SMTP id dm17-20020a056902221100b00dd920df0d5dmr2367243ybb.32.1710946718368; Wed, 20 Mar 2024 07:58:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710946718; cv=pass; d=google.com; s=arc-20160816; b=cME1mjyGFcXWGG03qOiD+UF9anuKQ7a54oAKBPGNoSwPVzT3WDduuNOq1fWiUMGC/5 wxzvmcDn0ZqVc35qnorQj5x6TXcChc6eGl4hM7yvV7T2ggAZyRC3WnAGTj8+B2tMKBLX 84Q8Vj6v6G27VsP1XXDEuMGD0j55Yk2v5r3oKrScxtjgrxB06Rbt9k3SVtQeO+AvcQZk pShB4/Hj+xXZR7bBn4lUw6orXOhuCO7uNk2+UwCF6iupLBwGQKESDGVYV4Lc7FtaZ7YB lwCC57IuswgAUYp6x8Z4bii6Q0R2PSOC0WvwxMkJZecvK8ie77brwX2rRC5XGh5llTfP XhAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=zmVSQEC3TeRF4GcV4dCeypJopsqrkB0AwEs9FDrz4eI=; fh=nUH7jHH1gcimTo0SyDb7UTF2SiC5q9pzVpvEiJl6raQ=; b=fBOYBICKySD7w7Hd/2WYwsiapN/NIMvOSJX5fVGWklKFN/uxkc0r3HaR+gMgJP93pf 8bcXN3+tk78N1njlG7tIS1xbEoySL0Na0K4jDIxexHbPFxEhCmc+9LWxA+nzhZMVbXQK Fqkx5AqrLhKV60LFLLDqsbDoA/3fHxUAgvT504CHe6+aux3ERBujR0NiYmtTC4xA+WN8 VY/7YOm2zkcsdVgUUujIe9jkvbnwovoXH7WEW6/BN6rsjn+P0+Iu9gWQPetVYDcxY/IP XvjHIquqiaqCzmaxFP/L+foAI9nDh09Rqo/KqN6g+k+YyAOA4M8iOfqSbaMu0sEgIfvF Os2w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nqVyH86y; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-109047-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109047-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id i13-20020ac85e4d000000b0042ef40f869bsi10552892qtx.301.2024.03.20.07.58.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 07:58:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109047-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=nqVyH86y; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-109047-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109047-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 11E151C21358 for ; Wed, 20 Mar 2024 14:58:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C8C2C535D5; Wed, 20 Mar 2024 14:55:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nqVyH86y" Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6DA315FDA7; Wed, 20 Mar 2024 14:55:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710946528; cv=none; b=jUyse1GOOH2ldmUZQCYfR7Ujtj2fO6mmRfzsIhyiUal/JhSXtuNLotDUlNdxPzavP3ImdhDF1ZliUD6uRccyGp3jpekxvKVUDfjeJp3dTaSUfkDP/aMig7Bpz3y9KBdsrJ5lrdgN4Z/R7CttZowGPE/IehfJhYZ1GIwUSo1DnuA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710946528; c=relaxed/simple; bh=GQUVsfUcpz8LUorm5To23Yew7xCHJVZumueYQTygjj8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bRwEFiBfKxFslTswaYYIp3VyK4JIhjIoBY6fj1nDL+K8eHMq2SxGm4JsZ6zr9+HmGN5IeB/oJEXw1mMR1qXTrCqGbRVhsOqter4R4URCZHLQycIe4xdtokq88pOw1u7ihrpPWAx+MqnZAjCmh+CXYjqcMaRSCcbLXe5Bwh/Gyx0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nqVyH86y; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1dee6672526so6080105ad.1; Wed, 20 Mar 2024 07:55:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710946526; x=1711551326; darn=vger.kernel.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=zmVSQEC3TeRF4GcV4dCeypJopsqrkB0AwEs9FDrz4eI=; b=nqVyH86yJct1WUode4SMJgT5vFb7XnuI05Ro7iDK/ad4PbdFPsZXfzbxVx8ivkIhxj gXG0PybtYydj/yuuIVGrvD10q6vu8WVPqU3cJ8Vjiqb7Gc4uUfQ0+XTAV23PBSVqshKy Ed2VgaJxOmvAQhCc8TQupzZ85lj7P1Ki1JOqOsRW2WkWk66cUHCItBsLilSO/r8CPFXZ P8A6FMCHf+Xj30IFpyirx13HtRvMSgpARyUVl+7rPzyn1d1kWj5mbTK6yo3dj0/I7SV+ pwZjYE+XJBocjUEwVCS/UbWrCnhLjDnxJcbNnxSfR0/jmlBjIqqZjeE/RKdPXNrI2XvC m15g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710946526; x=1711551326; 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=zmVSQEC3TeRF4GcV4dCeypJopsqrkB0AwEs9FDrz4eI=; b=kj0zMCk5ZgRGySOyqlNeQ0myGX+hbc7ZK3qUtqwBq7GY8K6YiMuGG11lVJd+AIqWJb 6qOjcg/AelFwwK9jV7sOeIA5hpzoXaxvfDvdsbuJ2oFb9sND6eIag3L17nVfeURgi6HJ gtxJm/hFLZiwzVQW/N1xEWAMnF6aLd0sylZx82SkAxFs9XygepsZp3cxTxoJn8o75c4C 9VGkzRFCVBDxMwAGTXYfmXOYOUHS7L6pNOWp80i7YWX4+jK6iKDH0eHP0KaMoyqLZntN LAAAgkjm+8MtqAhbVLe2SIrxff7FQx3iIeVbBL/3qu5UFZayLwCTjJZ+4iFIQzMidIKd JvDA== X-Forwarded-Encrypted: i=1; AJvYcCXr7ajBnrZLgaV3iRre5K/lRsGGj83LQyXkMQbMi5aQDwuRATVUj6B2O9nYXYh0bzVNtZlZ9WQOngc+5H79pHWe10mTeNmf9H3k2lPUYuLSaAqxQApeQNaqyxHza3xTwOyUwpBQWhrPIPtYTcG8Qggw12GRWs1jAUrlRYORCFWpdCphb3nkHaVZL7L7hwh6FEUCKNKfNualgF98v9+75tsiIUB+5SHmB54H9PHa X-Gm-Message-State: AOJu0YwCHZy67y1CXU1OYEImGzM1Spy+SbAexhoxoW9sXbpYpIeMLIUk +gpzPang+1dJ4b1lYwbjO8BsiG7si24m5ILf2SMpNdEXvg5sY1jP X-Received: by 2002:a17:903:1c1:b0:1dd:7c4c:c6b6 with SMTP id e1-20020a17090301c100b001dd7c4cc6b6mr19251572plh.5.1710946526585; Wed, 20 Mar 2024 07:55:26 -0700 (PDT) Received: from visitorckw-System-Product-Name.. ([140.113.216.168]) by smtp.gmail.com with ESMTPSA id la11-20020a170902fa0b00b001dc30f13e6asm13719989plb.137.2024.03.20.07.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 07:55:26 -0700 (PDT) From: Kuan-Wei Chiu To: colyli@suse.de, kent.overstreet@linux.dev, msakai@redhat.com, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, namhyung@kernel.org, akpm@linux-foundation.org Cc: bfoster@redhat.com, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, irogers@google.com, adrian.hunter@intel.com, jserv@ccns.ncku.edu.tw, dm-devel@lists.linux.dev, linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-perf-users@vger.kernel.org, Kuan-Wei Chiu Subject: [PATCH v2 13/15] lib/test_min_heap: Use min_heap_init() for initializing Date: Wed, 20 Mar 2024 22:54:15 +0800 Message-Id: <20240320145417.336208-14-visitorckw@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240320145417.336208-1-visitorckw@gmail.com> References: <20240320145417.336208-1-visitorckw@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Replace direct assignment of values to heap data members with min_heap_init() for better code readability and maintainability. Link: https://lkml.kernel.org/CAP-5=fW+FvUu8JL+KrtVv5uC++4AW=VhyEOgmdWzpH1mswQNzw@mail.gmail.com Signed-off-by: Kuan-Wei Chiu --- lib/test_min_heap.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/test_min_heap.c b/lib/test_min_heap.c index 062e908e9fa3..8d25fc8256db 100644 --- a/lib/test_min_heap.c +++ b/lib/test_min_heap.c @@ -67,9 +67,8 @@ static __init int test_heapify_all(bool min_heap) -3, -1, -2, -4, 0x8000000, 0x7FFFFFF }; struct min_heap_test heap; - heap.heap.data = values; + min_heap_init(&heap, values, ARRAY_SIZE(values)); heap.heap.nr = ARRAY_SIZE(values); - heap.heap.size = ARRAY_SIZE(values); struct min_heap_callbacks funcs = { .less = min_heap ? less_than : greater_than, .swp = swap_ints, @@ -99,9 +98,7 @@ static __init int test_heap_push(bool min_heap) int values[ARRAY_SIZE(data)]; struct min_heap_test heap; - heap.heap.data = values; - heap.heap.nr = 0; - heap.heap.size = ARRAY_SIZE(values); + min_heap_init(&heap, values, ARRAY_SIZE(values)); struct min_heap_callbacks funcs = { .less = min_heap ? less_than : greater_than, .swp = swap_ints, @@ -131,9 +128,7 @@ static __init int test_heap_pop_push(bool min_heap) int values[ARRAY_SIZE(data)]; struct min_heap_test heap; - heap.heap.data = values; - heap.heap.nr = 0; - heap.heap.size = ARRAY_SIZE(values); + min_heap_init(&heap, values, ARRAY_SIZE(values)); struct min_heap_callbacks funcs = { .less = min_heap ? less_than : greater_than, .swp = swap_ints, -- 2.34.1