From patchwork Thu Feb 1 07:52:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13540762 Received: from wfhigh3-smtp.messagingengine.com (wfhigh3-smtp.messagingengine.com [64.147.123.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0915158D8B for ; Thu, 1 Feb 2024 07:52:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706773927; cv=none; b=nQC/h0wFRRegjyZ5DzFMe9xLpxmFYvQ6u+ge2Mj2XDjWkKaIJvEJJ9NzzibQzBqkZDzVBYcT/faY9bL+YPN8QnTMgv/NOoTTA9Kjd/Tmbk3Qmb1IJUX2X0aAK1kLKfWn/NvFUjgyjaZuOSJg1MyY2vTLoiZsUr5GzPgC3B1iUFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706773927; c=relaxed/simple; bh=LEZIHfuVjYRw/3uEB7/dB6ODg8nZZizDMWIl2X5goJk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OTcWAw69MTSFJu1kkwP/AtJXkWx/ZK0dIONyY1BUSsnFd52d8HRXhVDnj8C3kr9L4aq9KoinrW8FpVVQt40TXSNfmUKHFdXdzwA+s8AidUh2BXJGA0G6qJvMejGH3N6/Js3YyXyhcrwsmOI2WUR9OXr3fYWGHb3lk2eyb7XxggE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=MN+ow+At; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=XSProfIP; arc=none smtp.client-ip=64.147.123.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="MN+ow+At"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="XSProfIP" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.west.internal (Postfix) with ESMTP id A9F261800079; Thu, 1 Feb 2024 02:52:04 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 01 Feb 2024 02:52:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1706773924; x=1706860324; bh=dhvGIyfDC7 3YbY4Qip7QO1UmZanFqNCV3put3TaN2Ts=; b=MN+ow+At+gZKT52TNIpy2C3Ge4 +7ME5SS1ZJrhOxO4u5MMEaZVpiyAc83e5CAhgHFbXTt6D8CeDDd33agEzzftIzWM 9P3TrNkxH2RiwWZkVYBszfMbhfGbES4f+ngLb5tQ1PrS5MjGZRegsenbWYLL5Lg8 9r/BT+D0H2gANnWDF08NQ+rH2aXj6ZHE/MXgtYv/ZwLChtHPa+WYfWdglXzBFTTu +ghyFKOeDZbbcvaUNuFlSlfMajF02QyJkvMg8d9ePw3JDlTXooQA9ukJkvbkQJvR 7qoZEdy0aHRWuGNVZ94DUzvJfTjtEUBccYV2cbF+SooO8GvhI0nIJS8eMS1w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1706773924; x=1706860324; bh=dhvGIyfDC73YbY4Qip7QO1UmZanF qNCV3put3TaN2Ts=; b=XSProfIPZD4YZR/FBuHuDF9SzDAGXPe94VGyj6SS+oFc ksMMdCQ26jmtU8iZb2Ih4t+LHn+obsTpeQzd4XLwBaR0x0GapnHSqBntsEOldrFh 2KdZR1ysGmPRU+AvSyE0NgwiL18p8v+SZEEejvIZIpbLZv48RFH/qncQOC19YahJ 6qOFaAtHq68RM04xRQPdI1kuVWqC3yR74uCA8nQGreIBLkRv0/8Xh2IcvXDwiFzO aaKSxmp+d+a1drOyIQKZzB2+Qr73AerlboxkNG1k3wL0PbdA2P+hJ3gE4toxqVkt glDxRKhSuYerhwfPjpvtfyIlLyJWZiI6DXKaZ/YV7g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrfedutddguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrght rhhitghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtth gvrhhnpeeukedtvedtffevleejtefgheehieegkeeluddvfeefgeehgfeltddtheejleff teenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpsh esphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 1 Feb 2024 02:52:02 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 51865484 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 1 Feb 2024 07:48:40 +0000 (UTC) Date: Thu, 1 Feb 2024 08:52:00 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Junio C Hamano , Toon Claes , Kristoffer Haugsbakk Subject: [PATCH v2 2/5] reftable/writer: use correct type to iterate through index entries Message-ID: <88541d03bef7c6ff425d330b153f3e3d94ca7567.1706773842.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The reftable writer is tracking the number of blocks it has to index via the `index_len` variable. But while this variable is of type `size_t`, some sites use an `int` to loop through the index entries. Convert the code to consistently use `size_t`. Signed-off-by: Patrick Steinhardt --- reftable/writer.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/reftable/writer.c b/reftable/writer.c index 92935baa70..5a0b87b406 100644 --- a/reftable/writer.c +++ b/reftable/writer.c @@ -379,20 +379,21 @@ int reftable_writer_add_logs(struct reftable_writer *w, static int writer_finish_section(struct reftable_writer *w) { + struct reftable_block_stats *bstats = NULL; uint8_t typ = block_writer_type(w->block_writer); uint64_t index_start = 0; int max_level = 0; - int threshold = w->opts.unpadded ? 1 : 3; + size_t threshold = w->opts.unpadded ? 1 : 3; int before_blocks = w->stats.idx_stats.blocks; - int err = writer_flush_block(w); - int i = 0; - struct reftable_block_stats *bstats = NULL; + int err; + + err = writer_flush_block(w); if (err < 0) return err; while (w->index_len > threshold) { struct reftable_index_record *idx = NULL; - int idx_len = 0; + size_t i, idx_len; max_level++; index_start = w->next; @@ -630,11 +631,8 @@ int reftable_writer_close(struct reftable_writer *w) static void writer_clear_index(struct reftable_writer *w) { - int i = 0; - for (i = 0; i < w->index_len; i++) { + for (size_t i = 0; i < w->index_len; i++) strbuf_release(&w->index[i].last_key); - } - FREE_AND_NULL(w->index); w->index_len = 0; w->index_cap = 0;