From patchwork Thu Jan 11 10:06:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13517058 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) (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 1DD5814F70 for ; Thu, 11 Jan 2024 10:06:55 +0000 (UTC) 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="H7O5l9SH"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Z1L52lgA" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 0FB3B320034E; Thu, 11 Jan 2024 05:06:54 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 11 Jan 2024 05:06:55 -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=fm2; t=1704967614; x=1705054014; bh=/vD9005ykh MTzCKwvK6H6cu8M7XWK29+pcFlZZ0hbwk=; b=H7O5l9SHVE6/CUOW/cpTwsmoni TlPmH2kRVUKbLrJ+7ZVG6a8icZQdyNZjkGg5sWGLwr4+uZXlgSJvaIoCSZkC26id Jtit8qYU/VxxoxBFHFkKoAjvzzZ0lhnGtT8XjYDFqc+1Wjd2TmIZTagsPLyFtEtX nmK+WUAUCdEYgaHbdN9RMTuy/H7/Z6ctOUm6A8c4ZlbibAPxMKWCcTJ6lOya0z6E lR7BnEAr+r1LRv4oc8UEmcVZwZOPeld6ZOSyhP37T3YkW6kqe/jloD+11Ik8vTj7 hyD65ZjAmXo26TfMFQaI583HW5ukSsdeZwc2PHKckdkkuDZYiRPgB/MZUqXA== 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= fm2; t=1704967614; x=1705054014; bh=/vD9005ykhMTzCKwvK6H6cu8M7XW K29+pcFlZZ0hbwk=; b=Z1L52lgAPkbbMfEiUBTNBh6Isr1Bv4OFxORUQmXLysF5 v1PchzzW0wVJ7s3hdGGa0cArYC3NygA2IZvv8Psn9NModhOaoufCVoVfljv9kkv/ TMhrmELKzA99JnMJMRb08WkFlNSt7+Tb6umIT/fboej4TROx3WdUidugfYfdEMBF e8bG+nvqkG4Aldo++r4CXEOPi6HKTmEyx6XRrY+Q5OUhCUe7n5568tYlrWkXkI3G YGQ0LzTmQklGOnhOIV7De7AyrdAtXRmaXDE0TPf2uyqHa9ots5YRcn+Wr+oU3kfo d35UONcOYkYp4EKSWsGdxaTddK+EMzAGFj10SAflBA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdeifedguddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehgtd erredttddvnecuhfhrohhmpefrrghtrhhitghkucfuthgvihhnhhgrrhguthcuoehpshes phhkshdrihhmqeenucggtffrrghtthgvrhhnpeeukedtvedtffevleejtefgheehieegke eluddvfeefgeehgfeltddtheejleffteenucevlhhushhtvghrufhiiigvpedunecurfgr rhgrmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 11 Jan 2024 05:06:53 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 62dc9229 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Thu, 11 Jan 2024 10:04:12 +0000 (UTC) Date: Thu, 11 Jan 2024 11:06:52 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Junio C Hamano Subject: [PATCH v2 4/5] reftable/blocksource: refactor code to match our coding style Message-ID: <96e79dc3ba011915924a8a4766eba426ef83abb5.1704966670.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: Refactor `reftable_block_source_from_file()` to match our coding style better. Signed-off-by: Patrick Steinhardt --- reftable/blocksource.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/reftable/blocksource.c b/reftable/blocksource.c index a1ea304429..1e2fb5e9fd 100644 --- a/reftable/blocksource.c +++ b/reftable/blocksource.c @@ -125,24 +125,23 @@ static struct reftable_block_source_vtable file_vtable = { int reftable_block_source_from_file(struct reftable_block_source *bs, const char *name) { - struct stat st = { 0 }; - int err = 0; - int fd = open(name, O_RDONLY); - struct file_block_source *p = NULL; + struct file_block_source *p; + struct stat st; + int fd; + + fd = open(name, O_RDONLY); if (fd < 0) { - if (errno == ENOENT) { + if (errno == ENOENT) return REFTABLE_NOT_EXIST_ERROR; - } return -1; } - err = fstat(fd, &st); - if (err < 0) { + if (fstat(fd, &st) < 0) { close(fd); return REFTABLE_IO_ERROR; } - p = reftable_calloc(sizeof(struct file_block_source)); + p = reftable_calloc(sizeof(*p)); p->size = st.st_size; p->fd = fd;