From patchwork Sat Apr 6 16:47:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuan-Wei Chiu X-Patchwork-Id: 13619885 X-Patchwork-Delegate: snitzer@redhat.com Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 A739B54FAF for ; Sat, 6 Apr 2024 16:48:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712422130; cv=none; b=tmJINdDmW0ey3ydAvDOmg5Ud0lXH3d8wSejuYP5YeR+qVHwoT+rAwhKav+qEXkvlPQu7+iPy0RHdEyngplXL5xlpXO0HeGQ834jGftTUp179DIldKrXcrXb5Ku+QQQyG9oY+foc+dLvTbEUCf70zFEnZwQG4p8zbcskYEPTV5uM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712422130; c=relaxed/simple; bh=cUOXm8PUXZY6Fju9709/MeuRssUa9uu6mwCwvhFly6U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=koxH7+gZvAXJp/QZr28at5OFK65yEcR2+D3p9ceBVG5jm0FnChVbpDWyeg2iszmE5EvL5TdDFdX5MuO7W9FOommmt7GzVQkBI5cJVjADXZkKqkVcsNu7BS80mcmirUzPkYmaYItpupVQRe86z+66ki3CwggqMIDQVAt1pDt1ue4= 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=RtqckcS+; arc=none smtp.client-ip=209.85.210.174 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RtqckcS+" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6ea729f2e38so813051b3a.1 for ; Sat, 06 Apr 2024 09:48:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712422128; x=1713026928; darn=lists.linux.dev; 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=AHNxZpx8u+XjZvJ2GIg35GcXEPPNsfxng7fyYMZIxlQ=; b=RtqckcS+T/QqvZLBG0O6GF10E0RtTf8I2gPCgcrUwx9DfSiVf7EjFMdfbfBON3SCAQ 1kaj//x4LChu91D4y9puEJZ50jCi/Wwuvc67YRxfMd8QCfd19I6am9tbFkCbCRjzUYwN QZIhreDRk60DoUWFkVwm1u6L56rtfgzjUftiBqdlTsGHZ+x0QwlGBIshnvlqGgWJ+MbN TaJvm4Nz5b6q5BuHIU2sR2nfQnxIC6XnUMvGWTr/7peXfoBK36+oViL+MYPNwj8u3btA HL+O868j5vtnluzIpLELHaSednZKhune4e9LYjvh5nxFWUfreX4lak14nwapbln8QTRS ZcrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712422128; x=1713026928; 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=AHNxZpx8u+XjZvJ2GIg35GcXEPPNsfxng7fyYMZIxlQ=; b=C5G/3uJeDvAkl0FXKNzQtsouE+xVwNBYl+ju8rOugiwOtxCJpaFKSlaTSJJKpensC6 vIkwNjlhsx1brHf/L2BusP55ZsS4Rx+8MZWD3HvDhThVA94Cl5lkoHcSqXNknR97FACZ tVc97uM2VCuquN+sH5qxOPKLcQO1u99v6G60zdivFS0fDuytfZs7LzEuAmGppZ/eOm6f 3H594T/ZfCaWcOb3KABIVQf9FFv1uJ3VzRZV44uTTBduT7l+Y0aJ/Q1N/UqvJAbfEurt 9bHDs4MaPYpOthQocpk95C6KK8yE9wlVDN8m5Fl2bbmEwLyAiq/nCAGwedUPalGBZrHC 9stA== X-Forwarded-Encrypted: i=1; AJvYcCUOiKZ2t0ddZR8d1+K2Djwj9A4ZzgN3OXdrS+cM/D1RSIRFvUVT5x3ba555KKGC5eL8gDQSo1dkRQM8o9DjaCLfmsgh1D7xB6s= X-Gm-Message-State: AOJu0YwUWzwJWwOQ+8/WzALWUUB5QZ1T5KaKumcou4lH2TxZdHdzhvBT cALhvkyyMTIZpU1EblfO2re9MN7+BuP6qon/3LtROYj+iEGnym8S X-Google-Smtp-Source: AGHT+IERQEN3/6uksLr3AQKyXLHAVa4zgVwAOUohwmgfNl0NRAk+e2fuL1w5v1WlyH3tZ6/U0YsU8Q== X-Received: by 2002:a17:902:e811:b0:1e0:c887:f93f with SMTP id u17-20020a170902e81100b001e0c887f93fmr5627092plg.1.1712422127887; Sat, 06 Apr 2024 09:48:47 -0700 (PDT) Received: from visitorckw-System-Product-Name.. ([140.113.216.168]) by smtp.gmail.com with ESMTPSA id q14-20020a170902a3ce00b001e2b8c91f04sm3665068plb.22.2024.04.06.09.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Apr 2024 09:48:47 -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, linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org, dm-devel@lists.linux.dev, linux-bcachefs@vger.kernel.org, linux-perf-users@vger.kernel.org, Kuan-Wei Chiu Subject: [PATCH v3 14/17] lib/test_min_heap: Use min_heap_init() for initializing Date: Sun, 7 Apr 2024 00:47:24 +0800 Message-Id: <20240406164727.577914-15-visitorckw@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240406164727.577914-1-visitorckw@gmail.com> References: <20240406164727.577914-1-visitorckw@gmail.com> Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 Reviewed-by: Ian Rogers --- 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 cc7219b49ba7..67dd4f644f6c 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.data = values; + min_heap_init(&heap, values, ARRAY_SIZE(values)); heap.nr = ARRAY_SIZE(values); - 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.data = values; - heap.nr = 0; - 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.data = values; - heap.nr = 0; - 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,