From patchwork Mon Feb 21 18:46:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12754055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BE736C433EF for ; Mon, 21 Feb 2022 18:46:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232254AbiBUSqr (ORCPT ); Mon, 21 Feb 2022 13:46:47 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232053AbiBUSqh (ORCPT ); Mon, 21 Feb 2022 13:46:37 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86D50CDF for ; Mon, 21 Feb 2022 10:46:13 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id n8so10025580wms.3 for ; Mon, 21 Feb 2022 10:46:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=W5Yj2jthDENAX/pjHPe/3jF4bTw09ifuA6lPu72S2Y4=; b=e/dJuRPdx+mLDqGWMd0jXuYljLyXFjbUj+35emoXH9MlA60cXkgL3+upQBn8NjJJQe fQSwn6ETFvGPNP0vq1UK57D9+vYKddNavVIRJNwVLLiQ2yXNV568aN11AXU+wX0aTLdC kBh8mgn97FwvgTvoa7OlCzFY1pnUP735jcEqobBBtTS+75biMywXQVMQlL3Xno7OTYS8 cPPcX2+LnnlNNYcOGRMJlHZvpx7X+ZUMvfVZj32Ci55MRttkGoMIm3DyCUrmkO6RXc45 SZgMxD5887v4kIQX4uK3jk4/D2Wfx7ol/90hr/+fhrXkhOBBGR0qSgcuNtEeWpJXtA9+ TysQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=W5Yj2jthDENAX/pjHPe/3jF4bTw09ifuA6lPu72S2Y4=; b=41xNJuRBn8DCTf+By2TKzreikf0EjcLIAGdy8Dv44C07gR81I7WWROJihOnA65p0lu AOkzSXcHPssduFgwM7wGV/K0oYMTgFgVzFo18IRu1sV+hRPf76D5GdQhN5M/vaNZD2ri MCkV0LsaadQr1WYmLQuPRG74g9OwgpVmYllOsyAThVyu7X1gyWn44yqMPWl/VC4s9IYM T9Vu4UKPE/NQxk5kiTdmpqYdhqV5tLU6Ls/Z5tKr5ORlx2lmM81jHCxUYVNmup2TZbui /LYokNqgiQ8lj1Q4yEzVoZKkftL+bUo40VkuuudB+39JT0zYXLGszq5o4FdVFogravgA oX0A== X-Gm-Message-State: AOAM530NSYi9fcuIgISIBn1f0cemdxJ3CRTyTM7CmdeUQ2cByBB+0Opu 4rLi+7fu4OtkePE/39o4ZUOKAOXP2s0= X-Google-Smtp-Source: ABdhPJx4zp3X3OZAzSiRD65VFWLyt9wjP4vx1T3ujmeOUL/yIj/VLatCDvra/v/7QplSElW31IenfA== X-Received: by 2002:a7b:c055:0:b0:37b:dc5f:7f48 with SMTP id u21-20020a7bc055000000b0037bdc5f7f48mr289788wmc.110.1645469171852; Mon, 21 Feb 2022 10:46:11 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o12sm1060999wrq.117.2022.02.21.10.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 10:46:11 -0800 (PST) Message-Id: <80d29e8f269bf0888d5b1db5f941d1a9bf89c86a.1645469170.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 21 Feb 2022 18:46:04 +0000 Subject: [PATCH v3 1/7] Documentation: object_id_len goes up to 31 Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys The value is stored in a 5-bit field, so we can't support more without a format version upgrade. Signed-off-by: Han-Wen Nienhuys --- Documentation/technical/reftable.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/technical/reftable.txt b/Documentation/technical/reftable.txt index d7c3b645cfb..6a67cc4174f 100644 --- a/Documentation/technical/reftable.txt +++ b/Documentation/technical/reftable.txt @@ -443,7 +443,7 @@ Obj block format Object blocks are optional. Writers may choose to omit object blocks, especially if readers will not use the object name to ref mapping. -Object blocks use unique, abbreviated 2-32 object name keys, mapping to +Object blocks use unique, abbreviated 2-31 byte object name keys, mapping to ref blocks containing references pointing to that object directly, or as the peeled value of an annotated tag. Like ref blocks, object blocks use the file's standard block size. The abbreviation length is available in From patchwork Mon Feb 21 18:46:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12754054 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C480EC433FE for ; Mon, 21 Feb 2022 18:46:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232187AbiBUSqo (ORCPT ); Mon, 21 Feb 2022 13:46:44 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232113AbiBUSqj (ORCPT ); Mon, 21 Feb 2022 13:46:39 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59B53D91 for ; Mon, 21 Feb 2022 10:46:14 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id d3so13008754wrf.1 for ; Mon, 21 Feb 2022 10:46:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=wcUoTutOvmdou1OMl+VGJ/zx0UEqyZ+p8oBLOioNDqU=; b=oxJXY+NR2NzhxvjafBX/7GeGGT29kQ6CUw9HYCmn8MKClQaimzb/+uEeKioqK1kpQ4 zk3R8teilxUUFVLLxo1BpM1q4HVLMuhS493hsDukxVwrXBDs4oqUpFFx9dUsFmZjlLbP qpltKjgjo4PkhA0PZzs4r6C8wlL9cFWkvtKhfPIwTsDZO0NJAAAqDxbrCikaRHzpnAMX OH2x9te2mV0BlYFhP17f3KEZSDpCr3aFSB9WFZSDbiSjSEjLFRcTxBz6Z83XYTUO9OCb DYqVm2NfoiBLcdPua5I4hDipUKWzckAexmK0SV9w5nei7mV6Yd31aqAqoLw24QdNCQST 1OuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=wcUoTutOvmdou1OMl+VGJ/zx0UEqyZ+p8oBLOioNDqU=; b=ghtbqWp1rC03GjHcjgV3jZjfcDHnZEZq5Kpxhg3p5rkMQjb/+v/fYhGsQ4RMAXGAIe wmPeINIQVsyuKZ6y65PBRsWWa+LfXZuUf46Zi0757BzHb79jQs/NVaTLN0F+d682wR8c E6KWvtrq+PPJoZj5/Rlmk0INW/aR+/nXQkwiZKktuVYnUNPvwmYdq+MYno3mJcT84HiD jwmM8gUB8moXzxt8fSXXKguIyMIGvskn9AMF7E/7p6/XFq7QURtO3YlFEcItk9JaRdlA M7Fl2xOCZwOw853D40FKKOdFxPiTVUdiWqICwMzDKD3pH2Mz9zhQZZzIvw2mFLJEXJf+ NCSQ== X-Gm-Message-State: AOAM531AGkactYj9SFKcp1rfyWtZeqWJ2X0UKufgUnLVaBbf+JT2qwWe E1pOW7LtOSYcxOWuiaoZV2GqVsHnZeQ= X-Google-Smtp-Source: ABdhPJzKUpJ3b5nT4mKeH+QiE6VCgvhKdwRCtGfj7zOLkd/KcgAS93G0eto7oAttEoBbVUKp31AlUw== X-Received: by 2002:adf:cf0c:0:b0:1e6:22fe:4580 with SMTP id o12-20020adfcf0c000000b001e622fe4580mr16661085wrj.12.1645469172744; Mon, 21 Feb 2022 10:46:12 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id ay41sm153579wmb.44.2022.02.21.10.46.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 10:46:12 -0800 (PST) Message-Id: <68e7bc32ff88da04c66993f68a84bbb401bc54c8.1645469170.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 21 Feb 2022 18:46:05 +0000 Subject: [PATCH v3 2/7] reftable: reject 0 object_id_len Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys The spec says 2 <= object_id_len <= 31. We are lenient and allow 1, but we forbid 0, so we can be sure that we never read a 0-length key. Signed-off-by: Han-Wen Nienhuys --- reftable/reader.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/reftable/reader.c b/reftable/reader.c index 00906e7a2de..54b4025105c 100644 --- a/reftable/reader.c +++ b/reftable/reader.c @@ -155,6 +155,11 @@ static int parse_footer(struct reftable_reader *r, uint8_t *footer, r->log_offsets.is_present = (first_block_typ == BLOCK_TYPE_LOG || r->log_offsets.offset > 0); r->obj_offsets.is_present = r->obj_offsets.offset > 0; + if (r->obj_offsets.is_present && !r->object_id_len) { + err = REFTABLE_FORMAT_ERROR; + goto done; + } + err = 0; done: return err; From patchwork Mon Feb 21 18:46:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12754057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D0CDC433EF for ; Mon, 21 Feb 2022 18:46:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232312AbiBUSrA (ORCPT ); Mon, 21 Feb 2022 13:47:00 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232166AbiBUSqk (ORCPT ); Mon, 21 Feb 2022 13:46:40 -0500 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EB7DC65 for ; Mon, 21 Feb 2022 10:46:15 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id az13-20020a05600c600d00b003808a3380faso17148wmb.1 for ; Mon, 21 Feb 2022 10:46:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=hZ3HRfDEndCA7wAlrfkPT7VVFBdUs+XxOFdsJK7f9GM=; b=o4vHeSQ0NDEDSzIq3WEDRMXYzhGQvh61ennof3kLyMZwJgkWqwxR756aTClSd8DcFu 5r7y4CQpVaSNjP3NATEZ/Tr2uXgYW5PYpU1gXJWM4aliWPZFQXy72AP+eF91qI9o4wXf BtEhJgh/U6pA57VcSWz2bns3Dh6Bn82InM9qQeZFpYP8hrCBVB6aaCa4qrbNv1pDm7+5 Kv2levjCzIsVKl1XbyUTTwkEjz7CEHTAXsAgrG8TdZEy4kXZXHEwiGYH7S3cuXIOuWi+ bAkwzq9OQ/FYRmGnOZau4a2/wyqNBub3QSQefKvKUaZRK8S3ldwBrIngxsoeQ7kILrvw StgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=hZ3HRfDEndCA7wAlrfkPT7VVFBdUs+XxOFdsJK7f9GM=; b=h0E7jS1mfdHav/yluAFQIHbirhAVGHLTh/KTGTrWrm1Jta1vixyWNityoEWQGupn1f rrTK66uyoH0Ruk9T1bWzARAYzGtChkwxx4/QtYRgWRlf4T1ykXW90zcIQuQ7FkeUOOow KAFUkTKTn2IYJvA1Ibx8yGtlHJK4SOcYoeL7lR9MFWORKZFCaaxUOn7HarYCfXHcs9N2 Bvlo6i2s5KjAVGIKUAy2wHkYbRKToVoaBhyokSMrzS1Q+M3Qu3w8GMCur17gZrbU4EVf HOiSbC+8CBxE+Lslf2Di9C3uTuJY8SmDlOQGRceYPtXeeqbD63s4rQp8mWfG+7ZNdw0e rmeQ== X-Gm-Message-State: AOAM530RY+yiJjZUPA4cM9QE3rP1xDxeQKmXK62u6HiwtkX5yEvVd2Kv QCeqB4mBzoR/zjO65NHsddCxFtVoAKU= X-Google-Smtp-Source: ABdhPJyaATF/NshxxgcNOfQbXvM947Qjo1zbpLbVuHYh0ZDa/V54+tfRABJRSqk6dEjmqIayg1S8pQ== X-Received: by 2002:a05:600c:2192:b0:380:9319:2eb1 with SMTP id e18-20020a05600c219200b0038093192eb1mr283682wme.156.1645469173585; Mon, 21 Feb 2022 10:46:13 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j10sm227213wmq.20.2022.02.21.10.46.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 10:46:13 -0800 (PST) Message-Id: <8b5aebdb07a6182196217f6750fbda95c17d1402.1645469170.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 21 Feb 2022 18:46:06 +0000 Subject: [PATCH v3 3/7] reftable: add a test that verifies that writing empty keys fails Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys Empty keys can only be written as ref records with empty names. The log record has a logical timestamp in the key, so the key is never empty. Signed-off-by: Han-Wen Nienhuys --- reftable/readwrite_test.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/reftable/readwrite_test.c b/reftable/readwrite_test.c index 605ba0f9fd4..fd5922e55f6 100644 --- a/reftable/readwrite_test.c +++ b/reftable/readwrite_test.c @@ -667,6 +667,29 @@ static void test_write_empty_table(void) strbuf_release(&buf); } +static void test_write_empty_key(void) +{ + struct reftable_write_options opts = { 0 }; + struct strbuf buf = STRBUF_INIT; + struct reftable_writer *w = + reftable_new_writer(&strbuf_add_void, &buf, &opts); + struct reftable_ref_record ref = { + .refname = "", + .update_index = 1, + .value_type = REFTABLE_REF_DELETION, + }; + int err; + + reftable_writer_set_limits(w, 1, 1); + err = reftable_writer_add_ref(w, &ref); + EXPECT(err == REFTABLE_API_ERROR); + + err = reftable_writer_close(w); + EXPECT(err == REFTABLE_EMPTY_TABLE_ERROR); + reftable_writer_free(w); + strbuf_release(&buf); +} + static void test_write_key_order(void) { struct reftable_write_options opts = { 0 }; @@ -746,6 +769,7 @@ int readwrite_test_main(int argc, const char *argv[]) RUN_TEST(test_table_read_write_seek_index); RUN_TEST(test_table_refs_for_no_index); RUN_TEST(test_table_refs_for_obj_index); + RUN_TEST(test_write_empty_key); RUN_TEST(test_write_empty_table); RUN_TEST(test_log_overflow); return 0; From patchwork Mon Feb 21 18:46:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12754056 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 387DBC433F5 for ; Mon, 21 Feb 2022 18:46:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232034AbiBUSq6 (ORCPT ); Mon, 21 Feb 2022 13:46:58 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232122AbiBUSqk (ORCPT ); Mon, 21 Feb 2022 13:46:40 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD119D97 for ; Mon, 21 Feb 2022 10:46:15 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id x3-20020a05600c21c300b0037c01ad715bso14521wmj.2 for ; Mon, 21 Feb 2022 10:46:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=EJMTl4RYf8XttOYhM1W6xIcCDcfqzEssxfiBN7t2fsM=; b=BzPtLDeEtl8MIFjHTHW/XvJXRiw8tXonUzgfcDS5QN5CmzMhFqxzsvaayw8ZLgW2Vp 0eWnWUip4rVDN6UWew94fLQRA4nQmEy4Ost4/H90nvz/LBLHlB+x8rEbJ7c1K1pwkhSQ oqq7U+gl/JeMh/Px5Epam/rUkWYZyKB1xNsmODb8eRWvgOHthiuAMewHQO49iwasgtkG a7Vs/HhaBwNaAlwXTcc2cRhxBZJAUgWK/E6eMGzRinccG+4cfIBwGN9PITu0rPp0XdGF Pc0534SJYZsqJqICPF49Osm6DOHToxhCzsdk6Lo+3xzQ4RtYlyeeCVDj9wxZt4BSl12b 0ceA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=EJMTl4RYf8XttOYhM1W6xIcCDcfqzEssxfiBN7t2fsM=; b=sAiC76NHOK5djPBIHOiVCMPRi3+5Nb6J+Cc7xBXcO5Z6KQjlfCR6xqCR6LLF56BmaM awqe/Fe/sLgPSkN3Rnr070kxpQRDgyr8h0qnSN4grFiO8TG5sFUbNC3lM5w4iNbXFLA/ Lsnal+i/HW7DXO+VcEzEmwEttT1ND7tOzhjv8FE5W+KIYmZQCyI5Q/UPu2hZ/UF1rkPM 3lmc0Uv4f2NjfyEv5ek05YrS3M7GlT+oFCxQivR+aZnYOkpKSyrgBBZ41lqcifUZlaHY eeryaO/apxqRkbre8DPkoNHWOl8CHT1ANkIpLvteL2lnXkAAy8SIKjTfdbxPRSF+4gE1 XqNw== X-Gm-Message-State: AOAM532M4EIoc0TPSFb3Sruyt+onVCjVCeDv0uSdbGwFm0eiftxvyrd4 BZCt1ghCbehfo3SsVSJn3N3gXgsF24E= X-Google-Smtp-Source: ABdhPJzjzoj8T09Ig68VAAzjcgm065b7h//Kuln+6d3vmBiFVjv/6Wy8nNqe9U+QrCoQ1EdC+6Cg/Q== X-Received: by 2002:a1c:5445:0:b0:34f:30d6:99b9 with SMTP id p5-20020a1c5445000000b0034f30d699b9mr301039wmi.76.1645469174311; Mon, 21 Feb 2022 10:46:14 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bk5sm37356333wrb.10.2022.02.21.10.46.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 10:46:13 -0800 (PST) Message-Id: In-Reply-To: References: Date: Mon, 21 Feb 2022 18:46:07 +0000 Subject: [PATCH v3 4/7] reftable: avoid writing empty keys at the block layer Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys The public interface (reftable_writer) already ensures that keys are written in strictly increasing order, and an empty key by definition fails this check. However, by also enforcing this at the block layer, it is easier to verify that records (which are written into blocks) never have to consider the possibility of empty keys. Signed-off-by: Han-Wen Nienhuys --- reftable/block.c | 27 +++++++++++++++++---------- reftable/block_test.c | 5 +++++ reftable/writer.c | 3 +-- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/reftable/block.c b/reftable/block.c index 2170748c5e9..34d4d073692 100644 --- a/reftable/block.c +++ b/reftable/block.c @@ -88,8 +88,9 @@ uint8_t block_writer_type(struct block_writer *bw) return bw->buf[bw->header_off]; } -/* adds the reftable_record to the block. Returns -1 if it does not fit, 0 on - success */ +/* Adds the reftable_record to the block. Returns -1 if it does not fit, 0 on + success. Returns REFTABLE_API_ERROR if attempting to write a record with + empty key. */ int block_writer_add(struct block_writer *w, struct reftable_record *rec) { struct strbuf empty = STRBUF_INIT; @@ -105,8 +106,14 @@ int block_writer_add(struct block_writer *w, struct reftable_record *rec) int is_restart = 0; struct strbuf key = STRBUF_INIT; int n = 0; + int err = -1; reftable_record_key(rec, &key); + if (!key.len) { + err = REFTABLE_API_ERROR; + goto done; + } + n = reftable_encode_key(&is_restart, out, last, key, reftable_record_val_type(rec)); if (n < 0) @@ -118,16 +125,11 @@ int block_writer_add(struct block_writer *w, struct reftable_record *rec) goto done; string_view_consume(&out, n); - if (block_writer_register_restart(w, start.len - out.len, is_restart, - &key) < 0) - goto done; - - strbuf_release(&key); - return 0; - + err = block_writer_register_restart(w, start.len - out.len, is_restart, + &key); done: strbuf_release(&key); - return -1; + return err; } int block_writer_finish(struct block_writer *w) @@ -332,6 +334,9 @@ int block_iter_next(struct block_iter *it, struct reftable_record *rec) if (n < 0) return -1; + if (!key.len) + return REFTABLE_FORMAT_ERROR; + string_view_consume(&in, n); n = reftable_record_decode(rec, key, extra, in, it->br->hash_size); if (n < 0) @@ -358,6 +363,8 @@ int block_reader_first_key(struct block_reader *br, struct strbuf *key) int n = reftable_decode_key(key, &extra, empty, in); if (n < 0) return n; + if (!key->len) + return REFTABLE_FORMAT_ERROR; return 0; } diff --git a/reftable/block_test.c b/reftable/block_test.c index fa2ee092ec0..cb88af4a563 100644 --- a/reftable/block_test.c +++ b/reftable/block_test.c @@ -42,6 +42,11 @@ static void test_block_read_write(void) block_writer_init(&bw, BLOCK_TYPE_REF, block.data, block_size, header_off, hash_size(GIT_SHA1_FORMAT_ID)); + rec.u.ref.refname = ""; + rec.u.ref.value_type = REFTABLE_REF_DELETION; + n = block_writer_add(&bw, &rec); + EXPECT(n == REFTABLE_API_ERROR); + for (i = 0; i < N; i++) { char name[100]; uint8_t hash[GIT_SHA1_RAWSZ]; diff --git a/reftable/writer.c b/reftable/writer.c index 944c2329ab5..d54215a50dc 100644 --- a/reftable/writer.c +++ b/reftable/writer.c @@ -240,14 +240,13 @@ static int writer_add_record(struct reftable_writer *w, writer_reinit_block_writer(w, reftable_record_type(rec)); err = block_writer_add(w->block_writer, rec); - if (err < 0) { + if (err == -1) { /* we are writing into memory, so an error can only mean it * doesn't fit. */ err = REFTABLE_ENTRY_TOO_BIG_ERROR; goto done; } - err = 0; done: strbuf_release(&key); return err; From patchwork Mon Feb 21 18:46:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12754058 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86FFFC433F5 for ; Mon, 21 Feb 2022 18:46:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231829AbiBUSrC (ORCPT ); Mon, 21 Feb 2022 13:47:02 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231893AbiBUSql (ORCPT ); Mon, 21 Feb 2022 13:46:41 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE41A195 for ; Mon, 21 Feb 2022 10:46:16 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id s13so96387wrb.6 for ; Mon, 21 Feb 2022 10:46:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=MNyfzPgLuL1AhBGd7/JnxDDNU29085If/CkNixlO+Tg=; b=DY7U1Vmku5NJcly5rG9M7kKdIaeR0YULptyMOUXoQYwePDQL+1rBLsjMTGCQYYRC6N fuufd2MdQnvzgWn3storXe29bhp3UvjX5EXNVEMVToqQvRc2ZBhx0RF4kp8MNZ0AgMFb JRRdyNmigDP5QrdTckwHd8qwwObplYy9P6LnOFgxLnpHZDqdk7mtwvORCd9/5IKi7/nZ svgD/BUKnqSiKfGr2Um5YhWEc1q2yUl/VsTGer/p8H3aopKLabZFhU8pCPTgHeOxWR+7 tDyeQYZwC3dK+DNY7Uuamb3NfeZpdCmxOcY4LyNVR4Pok5alyurlAb5ng5HiQzTOydG6 gz+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=MNyfzPgLuL1AhBGd7/JnxDDNU29085If/CkNixlO+Tg=; b=7czh8h2oklTgN0N/hd8HKn+89NuVfjUbRzbOgr9Ab8hFuXLqLAe9VncN6omuDWfY6L FVZzLguoYiaeq/UrMoyVpglUCRgMqVhX49qrfjBdtksdv8PhzIOvuzh+M2vAkwKjuDT7 XCNKjAY2EQSAT1ESWKY6f4d4cI3RaqFdNExR28ckHdc0v1P0F3T1ZjwBMce0subR+V/q L+wT/pFgd8PBOmY/D4c5QzhU3dhGVNhizA5lNrisd16F+IodVZYXAGeLDFQ5rDVI+w0+ E0p3APUjuRDgJK005MrumCvDayMnnKPX5nX9eLE2yMn9qQSvnycwNcjQYLukcMdYJZ0u omjw== X-Gm-Message-State: AOAM533BuvjUkcbgeIybicrcIK6vKLLx18laS6Y2WAIhbam4L97jHGfu A9t6vHilb2eS3I6Yjv70PKk/mn2UvQY= X-Google-Smtp-Source: ABdhPJxCN5qI/YtniP3nfejk0i+O55URRs5OwpiLZl5pu4VpoKJ/5eJG/6i+ZjZyDNVXrd5bKDULcQ== X-Received: by 2002:adf:d20c:0:b0:1e5:952c:34b5 with SMTP id j12-20020adfd20c000000b001e5952c34b5mr17251873wrh.82.1645469175120; Mon, 21 Feb 2022 10:46:15 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n15sm22958057wri.33.2022.02.21.10.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 10:46:14 -0800 (PST) Message-Id: <0b8a42399dd7aa04fdc791d25969a3b085190c6f.1645469170.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 21 Feb 2022 18:46:08 +0000 Subject: [PATCH v3 5/7] reftable: ensure that obj_id_len is >= 2 on writing Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys When writing the same hash many times, we might decide to use a length-1 object ID prefix for the ObjectID => ref table, which is out of spec. Signed-off-by: Han-Wen Nienhuys --- reftable/readwrite_test.c | 37 +++++++++++++++++++++++++++++++++++++ reftable/writer.c | 4 +++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/reftable/readwrite_test.c b/reftable/readwrite_test.c index fd5922e55f6..35142eb070e 100644 --- a/reftable/readwrite_test.c +++ b/reftable/readwrite_test.c @@ -667,6 +667,42 @@ static void test_write_empty_table(void) strbuf_release(&buf); } +static void test_write_object_id_min_length(void) +{ + struct reftable_write_options opts = { + .block_size = 75, + }; + struct strbuf buf = STRBUF_INIT; + struct reftable_writer *w = + reftable_new_writer(&strbuf_add_void, &buf, &opts); + uint8_t hash[GIT_SHA1_RAWSZ] = {42}; + struct reftable_ref_record ref = { + .update_index = 1, + .value_type = REFTABLE_REF_VAL1, + .value.val1 = hash, + }; + int err; + int i; + + reftable_writer_set_limits(w, 1, 1); + + /* Write the same hash in many refs. If there is only 1 hash, the + * disambiguating prefix is length 0 */ + for (i = 0; i < 256; i++) { + char name[256]; + snprintf(name, sizeof(name), "ref%05d", i); + ref.refname = name; + err = reftable_writer_add_ref(w, &ref); + EXPECT_ERR(err); + } + + err = reftable_writer_close(w); + EXPECT_ERR(err); + EXPECT(writer_stats(w)->object_id_len == 2); + reftable_writer_free(w); + strbuf_release(&buf); +} + static void test_write_empty_key(void) { struct reftable_write_options opts = { 0 }; @@ -772,5 +808,6 @@ int readwrite_test_main(int argc, const char *argv[]) RUN_TEST(test_write_empty_key); RUN_TEST(test_write_empty_table); RUN_TEST(test_log_overflow); + RUN_TEST(test_write_object_id_min_length); return 0; } diff --git a/reftable/writer.c b/reftable/writer.c index d54215a50dc..5e4e6e93416 100644 --- a/reftable/writer.c +++ b/reftable/writer.c @@ -515,7 +515,9 @@ static void object_record_free(void *void_arg, void *key) static int writer_dump_object_index(struct reftable_writer *w) { struct write_record_arg closure = { .w = w }; - struct common_prefix_arg common = { NULL }; + struct common_prefix_arg common = { + .max = 1, /* obj_id_len should be >= 2. */ + }; if (w->obj_index_tree) { infix_walk(w->obj_index_tree, &update_common, &common); } From patchwork Mon Feb 21 18:46:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12754059 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D268C433EF for ; Mon, 21 Feb 2022 18:46:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232270AbiBUSrG (ORCPT ); Mon, 21 Feb 2022 13:47:06 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232079AbiBUSql (ORCPT ); Mon, 21 Feb 2022 13:46:41 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69A69C76 for ; Mon, 21 Feb 2022 10:46:17 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id s1so2230982wrg.10 for ; Mon, 21 Feb 2022 10:46:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=XxbM2A5F4fQmhL+gCS+SwLotSFUOUYIK9jyUgxWcDks=; b=IA7h7HBdLHpgup0R6MfjLeFyzsE5Iz0sReD8Q3Q2bry+SUSE4bCFtqYoVrOnXK12W+ jCzvTaphMUCjs355hQvL32shHsUFSM6sakOI3VnjsYD0oBOLqDCi9TaNIu3oZaKNfnao fiX4wHS5yxGNSqs68mlOxFRVHqTTw4R11vnmm94lvY6/+1A3/cDxYM44aEyChQVOKhzz OSwZGXUHKpO6EbveswwqSCpl1tiYO0phXlv6yDVqSUNi+Ks69Z/IBeqtw0Cfopo0uiT4 qejOAdmiYv9dUsHzsu53aeQZ7dvZKi3X6ddhWilnpjsbb8BGXiRdrbxXbnQJR6d0b0I6 hXmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=XxbM2A5F4fQmhL+gCS+SwLotSFUOUYIK9jyUgxWcDks=; b=hb8mf+JGTRU/OVKwJhncuSy8lAYbTZ+u/WX/DSWpD+C9UCt/tCD8roNOSudEyBgdoa CJE+WF5nDk/pxjBUTKMDtMa4cbd+Zue3pQQqoxoDwjIrRt1VCDR28zXlWK6gUSxAtZ2/ N+8cXqq6j3y2HjiWr2KbfziMvNIDPKcdIdEYZqDILxLYYC1xRH0xWBMK9Hj/7hItCAAI Gtghc3ZYlLY0ZcoW7oQqSVNjWJGu9ZCkoNl0UKXPtdludqLdIoSSxu85MCn9QkG9uvZ2 YmjbM1fq/MPFnR9v7xc2Ks5912Of7DpVlKpxgflHr+sLxoN8QF0QEsCPS7Y3Y+hDJ2v0 2ObA== X-Gm-Message-State: AOAM533vNX/6LudEjV24mHpV0sLUvXpWG19kp6lnSm8PDkdhdDnuzsGM JouRsuVnQPSjI7aS8G9gThtU8Zo+Nkw= X-Google-Smtp-Source: ABdhPJzd7Cn78FGzVrjS0K3+eJDwPpTpp1fb9PhLPN/FnQzhLW7TPUe/YZzT8F0DmIPnqzPoNznQtg== X-Received: by 2002:a5d:5885:0:b0:1ea:8099:1ed6 with SMTP id n5-20020a5d5885000000b001ea80991ed6mr778420wrf.494.1645469175908; Mon, 21 Feb 2022 10:46:15 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id r4-20020a05600c35c400b0037e9868e364sm159870wmq.33.2022.02.21.10.46.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 10:46:15 -0800 (PST) Message-Id: In-Reply-To: References: Date: Mon, 21 Feb 2022 18:46:09 +0000 Subject: [PATCH v3 6/7] reftable: add test for length of disambiguating prefix Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys The ID => ref map is trimming object IDs to a disambiguating prefix. Check that we are computing their length correctly. Signed-off-by: Han-Wen Nienhuys --- reftable/readwrite_test.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/reftable/readwrite_test.c b/reftable/readwrite_test.c index 35142eb070e..a1b835785a3 100644 --- a/reftable/readwrite_test.c +++ b/reftable/readwrite_test.c @@ -703,6 +703,43 @@ static void test_write_object_id_min_length(void) strbuf_release(&buf); } +static void test_write_object_id_length(void) +{ + struct reftable_write_options opts = { + .block_size = 75, + }; + struct strbuf buf = STRBUF_INIT; + struct reftable_writer *w = + reftable_new_writer(&strbuf_add_void, &buf, &opts); + uint8_t hash[GIT_SHA1_RAWSZ] = {42}; + struct reftable_ref_record ref = { + .update_index = 1, + .value_type = REFTABLE_REF_VAL1, + .value.val1 = hash, + }; + int err; + int i; + + reftable_writer_set_limits(w, 1, 1); + + /* Write the same hash in many refs. If there is only 1 hash, the + * disambiguating prefix is length 0 */ + for (i = 0; i < 256; i++) { + char name[256]; + snprintf(name, sizeof(name), "ref%05d", i); + ref.refname = name; + ref.value.val1[15] = i; + err = reftable_writer_add_ref(w, &ref); + EXPECT_ERR(err); + } + + err = reftable_writer_close(w); + EXPECT_ERR(err); + EXPECT(writer_stats(w)->object_id_len == 16); + reftable_writer_free(w); + strbuf_release(&buf); +} + static void test_write_empty_key(void) { struct reftable_write_options opts = { 0 }; @@ -808,6 +845,7 @@ int readwrite_test_main(int argc, const char *argv[]) RUN_TEST(test_write_empty_key); RUN_TEST(test_write_empty_table); RUN_TEST(test_log_overflow); + RUN_TEST(test_write_object_id_length); RUN_TEST(test_write_object_id_min_length); return 0; } From patchwork Mon Feb 21 18:46:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han-Wen Nienhuys X-Patchwork-Id: 12754060 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 092D7C433EF for ; Mon, 21 Feb 2022 18:46:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232272AbiBUSrK (ORCPT ); Mon, 21 Feb 2022 13:47:10 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:60670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232105AbiBUSql (ORCPT ); Mon, 21 Feb 2022 13:46:41 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 484DBCDF for ; Mon, 21 Feb 2022 10:46:18 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id s1so2231032wrg.10 for ; Mon, 21 Feb 2022 10:46:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=tlgoVWle0gi+6bs+gWGo0KCzoCzZ1VwyzTZVbVPDUtI=; b=SQeOOqyl5/TLoJCfJgKcimQRNtnf4hCsylEolIHnSrZN2w6UwJiAA3W1urFrFMScq+ 5sdhgiF6SfyIqiBTFQHpKrrx+ilK0wzp1+yzz5KjWtSd+PXxGZLKMFmRC0U9m3tVvKmF fZ4P7F5btwZe9cv1PSLCns1lS8McfltULOLkIW+qMCjiAA+/wptBVuC6/V2Oqrj7R8Rj lTAx4U+gs/JvKkfcIQGLQUrRfbOPE4IW0QrVBXzJUbGCMg4fOvJE63s4o01QzRpiwUzZ 68XZbx4bLsW4iKkZcZ410u9qGynzfmEcMxpDkC50rE6xue8GyIL+FVEbS9CpDSF3EPsm 2wIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=tlgoVWle0gi+6bs+gWGo0KCzoCzZ1VwyzTZVbVPDUtI=; b=OgFQq4GISE7Zxm6D+PJcEF08gG6uwyOdClqJVzy6nnpe0LQYVmtncU2XV1Sl+e8Dnx +8SbE+P0Kjr+uIS4a7HLHTshswyrF6buaxOtZQBIHF8hB6pqtqPPWxKbpbAhJFs+I0bE Oq8HOu2WRSKIS40quiEoCx66hPG0VGjVA7YWVorDSkvuUGMjkFlAVrWPYPhfcP/Xo4+Y SO3mkgwdsgAl7f8MS+CtVL8L7/y4ZAAoCXrlU+z+SdusPXy0lDpHpyGHT84wmaTOs9vt Yw74bILVOCsM/BQGUTZqk7ClQw9pL9hl+athsk1UHNE1jKOLpNmtqvezypKKeKh/dUr1 WRHw== X-Gm-Message-State: AOAM533evRxAdD4o9udneQhcSwDVzwz78NeiIxHxdQq8CfgvHoyQLY6O 59yfRtdvH1RE1U93pH0A/ibiHkr12m8= X-Google-Smtp-Source: ABdhPJzbqunMDa8hU6mzDDz/kceQN4qJjw6fJcATw2Yf+qk3EqcM6wnOUjpyK13NxNrRsSj3qezLMQ== X-Received: by 2002:a5d:6a0f:0:b0:1e5:53db:4ddd with SMTP id m15-20020a5d6a0f000000b001e553db4dddmr16749816wru.614.1645469176740; Mon, 21 Feb 2022 10:46:16 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x15sm5313567wrp.109.2022.02.21.10.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Feb 2022 10:46:16 -0800 (PST) Message-Id: <72499a14e383ef81e717692002ed68959774c7da.1645469170.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Mon, 21 Feb 2022 18:46:10 +0000 Subject: [PATCH v3 7/7] reftable: rename writer_stats to reftable_writer_stats Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Han-Wen Nienhuys , Han-Wen Nienhuys , Han-Wen Nienhuys Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Han-Wen Nienhuys From: Han-Wen Nienhuys This function is part of the reftable API, so it should use the reftable_ prefix Signed-off-by: Han-Wen Nienhuys --- reftable/readwrite_test.c | 10 +++++----- reftable/reftable-writer.h | 2 +- reftable/writer.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/reftable/readwrite_test.c b/reftable/readwrite_test.c index a1b835785a3..469ab79a5ad 100644 --- a/reftable/readwrite_test.c +++ b/reftable/readwrite_test.c @@ -100,7 +100,7 @@ static void write_table(char ***names, struct strbuf *buf, int N, n = reftable_writer_close(w); EXPECT(n == 0); - stats = writer_stats(w); + stats = reftable_writer_stats(w); for (i = 0; i < stats->ref_stats.blocks; i++) { int off = i * opts.block_size; if (off == 0) { @@ -239,7 +239,7 @@ static void test_log_write_read(void) n = reftable_writer_close(w); EXPECT(n == 0); - stats = writer_stats(w); + stats = reftable_writer_stats(w); EXPECT(stats->log_stats.blocks > 0); reftable_writer_free(w); w = NULL; @@ -330,7 +330,7 @@ static void test_log_zlib_corruption(void) n = reftable_writer_close(w); EXPECT(n == 0); - stats = writer_stats(w); + stats = reftable_writer_stats(w); EXPECT(stats->log_stats.blocks > 0); reftable_writer_free(w); w = NULL; @@ -698,7 +698,7 @@ static void test_write_object_id_min_length(void) err = reftable_writer_close(w); EXPECT_ERR(err); - EXPECT(writer_stats(w)->object_id_len == 2); + EXPECT(reftable_writer_stats(w)->object_id_len == 2); reftable_writer_free(w); strbuf_release(&buf); } @@ -735,7 +735,7 @@ static void test_write_object_id_length(void) err = reftable_writer_close(w); EXPECT_ERR(err); - EXPECT(writer_stats(w)->object_id_len == 16); + EXPECT(reftable_writer_stats(w)->object_id_len == 16); reftable_writer_free(w); strbuf_release(&buf); } diff --git a/reftable/reftable-writer.h b/reftable/reftable-writer.h index a560dc17255..db8de197f6c 100644 --- a/reftable/reftable-writer.h +++ b/reftable/reftable-writer.h @@ -143,7 +143,7 @@ int reftable_writer_close(struct reftable_writer *w); This struct becomes invalid when the writer is freed. */ -const struct reftable_stats *writer_stats(struct reftable_writer *w); +const struct reftable_stats *reftable_writer_stats(struct reftable_writer *w); /* reftable_writer_free deallocates memory for the writer */ void reftable_writer_free(struct reftable_writer *w); diff --git a/reftable/writer.c b/reftable/writer.c index 5e4e6e93416..6d979e245ff 100644 --- a/reftable/writer.c +++ b/reftable/writer.c @@ -695,7 +695,7 @@ static int writer_flush_block(struct reftable_writer *w) return writer_flush_nonempty_block(w); } -const struct reftable_stats *writer_stats(struct reftable_writer *w) +const struct reftable_stats *reftable_writer_stats(struct reftable_writer *w) { return &w->stats; }