From patchwork Thu Feb 17 13:55:18 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: 12750161 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 C9176C43219 for ; Thu, 17 Feb 2022 13:55:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241489AbiBQNzu (ORCPT ); Thu, 17 Feb 2022 08:55:50 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241126AbiBQNzn (ORCPT ); Thu, 17 Feb 2022 08:55:43 -0500 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FF2F2731CB for ; Thu, 17 Feb 2022 05:55:29 -0800 (PST) Received: by mail-wm1-x32f.google.com with SMTP id k127-20020a1ca185000000b0037bc4be8713so6253147wme.3 for ; Thu, 17 Feb 2022 05:55:28 -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=d+zqP5JpXU3b2S6IZycsthQ/BsrBt9JgY8IkKb1IUPibVct2paNEpBowCALNNcP7p7 n4hWXpH3lt/7Za9XAeFlZbk9qG0L7OyFzUjaqK5VLcwcojT9vZpfIbKUdYs/tm6Rslj5 SaVHaARZcPIWQYyVG4kImDuv3C5axRJj2ZF7Lw1p+xWmtI9ACSKdXM57XTrCEbt8z0W4 9To3j22Uzl4XffoZYrLp1ozmIBLeJbWwCujenPNfvQ7u/2rbV0khVcCa3BLdJLBRORfo Nd3Iejt+/vHWjGMJcy3Hk7yrgSzSXtWvO14j3qFOQjb4NBfnXbdJ19cK7D+3BUHNCzBW N3BQ== 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=VCVH3U8KcM9HR6fQ9Iu4FYz+LkjwjaIBAEu4DjphEOvP8m1c+aLu4UtLE4fIQ7mZXp ijQNWbr0A8bE4VJKs1445iWWzuwV5zFc0FA8ZFw0yoMpzA2J5OzsR8WenCPHCdshLbrQ awqlVlS37eSiQEV2nPB129VWXDgY7Id9KkZZGehxtQtsTRFTa/gEe20SuDuDrr/alzvA DUQebLkEwWCuHVfnPnkxCnrK4SonZqJijVQZsbMQsXGnaFCL1/N2IuhT7k1xkmZm+fM2 Q5Co1DAB63T4bo9VxVAUBJWww69MTzoOJxKzsSGcvYm5RoIWm0TcawRMWbiaPRpf2Auf RLdQ== X-Gm-Message-State: AOAM5315e1ljGkk2o7vRjBal888eiJZt6WegCVj76HumDVVE8FtGsG8k HeB/9D+kepOqVbbdkMGDqSIGTBqxqMY= X-Google-Smtp-Source: ABdhPJwnjhk8V/z8/s5GaMvdQ6htIrBbdfpseht4j5WjyGmVlGUwcXIVJlMUyqJjZeo53D3yW4xBLQ== X-Received: by 2002:a05:600c:154f:b0:37d:f2e5:d89b with SMTP id f15-20020a05600c154f00b0037df2e5d89bmr2841261wmg.92.1645106126659; Thu, 17 Feb 2022 05:55:26 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o16sm1314707wmc.25.2022.02.17.05.55.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 05:55:26 -0800 (PST) Message-Id: <80d29e8f269bf0888d5b1db5f941d1a9bf89c86a.1645106124.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 17 Feb 2022 13:55:18 +0000 Subject: [PATCH v2 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 Thu Feb 17 13:55:19 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: 12750162 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 5CC78C4321E for ; Thu, 17 Feb 2022 13:55:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241490AbiBQNzw (ORCPT ); Thu, 17 Feb 2022 08:55:52 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241395AbiBQNzo (ORCPT ); Thu, 17 Feb 2022 08:55:44 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 744BB272DA3 for ; Thu, 17 Feb 2022 05:55:30 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id d27so9177101wrc.6 for ; Thu, 17 Feb 2022 05:55:30 -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=7x4uCn/FbLLnXOpxQxwOKZWEYHfXkWZ+5D871Kaw7Sg=; b=ki40QNa9LV6p2wyfiyyL4eP0MlLXUnVheJrIcSEVHbKfyXssh1zCSOjx63CKwefHF6 nlMGhDCsAimQNW/rcL9gdZw305ONdnRZkyWY50R3tMxUdZgxK1+r038K8fKZyYdLl+k0 UZ1/RIJlPeicD4SkwIW9+i1/gFVeBFCTPyeyLp5AtWeIZSWApmFZ1yNL8CHuyZR4flZ3 iZqhXQNju8bJxIcv7kk3EGy2o4W41IE7MLD6iOWmo/fx4VhS+VnBn8jPj4TcFkMZ8Q6U 9uJ7fX8jLtbLVlZGS6sgxOz91P9C6GKAHezwCX4G1H8kAA5crLryflgTkqJSJ8smQMEU e0gw== 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=7x4uCn/FbLLnXOpxQxwOKZWEYHfXkWZ+5D871Kaw7Sg=; b=h2uFYu8W7ikzWrqNZ+0CHpuFwQeq+5DTh/i+DMTNbEzwEMB9D0NoXvF1TRVIvIo7W4 fXNC4HfNibFrFqWU4W8K837mVGvEdBiO1E7lOriGdGHw4L4jSOCAlt2zNr8V5107tnWl D3jrutFjbll1iGvE6Kb5M2q7Dy/79BZS2qx+hUrjSJmiEpxYogrIsnDjY8sP0lrmbU3O eNZTQbF9q11oW/04ORZ9eWIpVB9TGETPS4OH7xlGiFeKnznbG6f0cC29MzcNPdx+QGnQ rGApzCESMYKQLLVH0nc+4Sk87rAeUP2PIF+K5qTU4l6cQ6PE6R2MrM6oG5HPk0XNyzE2 wviA== X-Gm-Message-State: AOAM53200KqbDZF6Fqy0fRx4emOp0aEixC0o6pl9iOG4kpJYfK5QrVpo Im4BITcEpukaQgfYb9EKYceZlGeZi7w= X-Google-Smtp-Source: ABdhPJxbkcEg7RBYqV90+MppIw1WLf9AjkRKFx2wvFClLFDqPPNDOBfkXtxxEN09bcFrO9TPChp1BQ== X-Received: by 2002:adf:e4c2:0:b0:1e3:3e5d:bd65 with SMTP id v2-20020adfe4c2000000b001e33e5dbd65mr2466305wrm.422.1645106128839; Thu, 17 Feb 2022 05:55:28 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g4sm13754420wri.88.2022.02.17.05.55.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 05:55:28 -0800 (PST) Message-Id: <4c1a19fc4aef2742e2733b804221186aa164f721.1645106124.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 17 Feb 2022 13:55:19 +0000 Subject: [PATCH v2 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 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 Thu Feb 17 13:55:20 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: 12750163 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 D361BC4167B for ; Thu, 17 Feb 2022 13:55:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241495AbiBQNzx (ORCPT ); Thu, 17 Feb 2022 08:55:53 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241406AbiBQNzp (ORCPT ); Thu, 17 Feb 2022 08:55:45 -0500 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC601273756 for ; Thu, 17 Feb 2022 05:55:31 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id y6-20020a7bc186000000b0037bdc5a531eso4586586wmi.0 for ; Thu, 17 Feb 2022 05:55:31 -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=Drbr9vdmigJDqD2KbuRRpvzTH8HY312jfl3WW6FxaHeXWCnzlPDGAjegWMBunjGNZT De3A/ESmqIgNvfH7jYZGohXIs6Xr9CeKzy6j40XL3gTF6HN3LBzrDcRmCd+Yk3zYGFbc 4FNhAHMHwVep5ydy1IyQ0i+f8H8pWHLk8DrXf93vvVgzIlzix9D68RAZ8isAEgXqsUZJ X9tKzkUDDMdDqlRbCOOoyUqoDyTvCLDRfsB/hlQUHH3YFVwBNu/IkcmMEiOB9Czmitwh LlyMBWSYLu73uxw6Troz/d/CXFAcFn9xCsT9gloNSiIbfeFNHCsyWkPR9XZxvAzP+Lyk OF1g== 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=k/PgHqOn6aFW3ili9jomNSRK6ZFB+LL4mJ9KZMHt0NOqrhWDFCCDINzYoHjCPTs4iJ FqW+VrLY6yGfH7uS8Apy/UJjv2aIYzQCzJMrqXg0HyCE7PhTLjFHFpJ//tNkpYtlwLWa Wm5tYdgo5nGbMGKGzYJ5x1Sxn+JFgR9pwy9h994RFN8ff0OQ6dHd00gBTRUOLFomt+il BfGUbxOAOHcyDSAQYbZn6EC2OFAC4yJoAyN0NAcwVGk/XQCaR8Q/wpF+TsysiS+8DKz1 QIFeoJsrvp+/igIC4qTYLj4XVH5B37sofrteH4iongEO7jq6u1Pn8JGvHwUMOPPG8ac7 2H+Q== X-Gm-Message-State: AOAM532wqJPjGO8BxcsiH0BGC/WHAM+jc7xT8cdqP2lKymNCiIBnF//i xKpIHoi422g3m0gSIDR+CChbDVKojg8= X-Google-Smtp-Source: ABdhPJykkWLjIvl1QpzmzYvbafChu3jYjHvTW0RDqUkNBSedmnJAN+ww99cBpIQ+PtLXQG95Ep1s7w== X-Received: by 2002:a05:600c:3b87:b0:37c:af2b:4f36 with SMTP id n7-20020a05600c3b8700b0037caf2b4f36mr6271982wms.132.1645106129765; Thu, 17 Feb 2022 05:55:29 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v18sm34451297wrm.105.2022.02.17.05.55.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 05:55:29 -0800 (PST) Message-Id: <600b115f8b17322997bef9092349c13d32b6a121.1645106124.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 17 Feb 2022 13:55:20 +0000 Subject: [PATCH v2 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 Thu Feb 17 13:55:21 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: 12750164 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 F1268C433FE for ; Thu, 17 Feb 2022 13:55:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235260AbiBQNzy (ORCPT ); Thu, 17 Feb 2022 08:55:54 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241417AbiBQNzq (ORCPT ); Thu, 17 Feb 2022 08:55:46 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C52D273774 for ; Thu, 17 Feb 2022 05:55:32 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id f3so9027341wrh.7 for ; Thu, 17 Feb 2022 05:55:32 -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=NsrdF5h2PxUorHU1VNro3oVuNlc4F0V+1ZFMTw9yO6Y=; b=AhZRJYmZ3o3t9VkIVYJdzNnmPOt9yCpALcPjUAgLgFqR6oaimmNFuDH9kbhlR7o5jR cFTIut+PEqMCujwd+l0lzZGOdTCUBsXR2Xz7LLNuDzXcF3KhluotmXcs9gG+7kbY0ZR3 wsXcEy2D6m4DeWsKwc+EMwRtqKfQv+fe2H00Xww7D5PlOrM4RpKZtpegasjPB+LDTesi mKwW2rbolVais4KHNKSX8XVqq5ryh/ZU7CriOgGD6xkhBGgfDwjwLe/FZNTQGjegjaup KwhZviFnzNPv6Div3MGc2G6PRdPIgGVjLkv3CaYF83S+uPc2pNWnwV6RoghfftHaUGE5 xPUQ== 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=NsrdF5h2PxUorHU1VNro3oVuNlc4F0V+1ZFMTw9yO6Y=; b=ogW0prNZoSzfYjp9OU8xgG5+O9gzI08R+nE1LGj4/yPneNDJjFfOVDI2ryaRMu65i7 CBJ5TDLIClsGlAlWDYSSBb19dCBaaXlCe2ec8Y5t7n0rkmVgVykjuWXAzPAsxDDriP44 grkFuFXaKOrABcwd5z4Jnvbd/FhItO4VlBNqbIUkwIIv/3V4Tp5xINbpyv487010IJIj nvqjt2od4IQi0fFyv53T9iPdn/nBTojifGn+talsTyCQxXsbZt11ZOs9GmtxyEs+duOd qL4+U2mEAnv/CJsLDhZtm5i+cJjJZ6NLmyVjrlLVdz3iQDVTXVmIpfrWvgvCp6FEhs7W h4pQ== X-Gm-Message-State: AOAM532IxCbaNDwSRXC3nJawrCVtzgnltfud2UQJr6PtzARw9Q8e1u8V GAd/aAd8b1WCP7x09sWmi2c967dnTS0= X-Google-Smtp-Source: ABdhPJwtOpDqCPlYoKupYqPV93+m7Qa0H0RGf+X5ciHy7fpp9dJaWgpHoqAHpLUN3csXYZKknLnZgQ== X-Received: by 2002:a5d:4b4c:0:b0:1dc:f34a:548 with SMTP id w12-20020a5d4b4c000000b001dcf34a0548mr2417797wrs.554.1645106130918; Thu, 17 Feb 2022 05:55:30 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z2sm20630336wrn.60.2022.02.17.05.55.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 05:55:30 -0800 (PST) Message-Id: In-Reply-To: References: Date: Thu, 17 Feb 2022 13:55:21 +0000 Subject: [PATCH v2 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..4a095afe1e2 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 -1; 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 Thu Feb 17 13:55:22 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: 12750165 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 47C7DC433F5 for ; Thu, 17 Feb 2022 13:55:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241499AbiBQNz4 (ORCPT ); Thu, 17 Feb 2022 08:55:56 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241479AbiBQNzs (ORCPT ); Thu, 17 Feb 2022 08:55:48 -0500 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3EA7272DA3 for ; Thu, 17 Feb 2022 05:55:33 -0800 (PST) Received: by mail-wr1-x42c.google.com with SMTP id d27so9196109wrb.5 for ; Thu, 17 Feb 2022 05:55:33 -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=Pg0udte9IQFcqcsixdxh3iAkpKkZvmb1/7at0TY93/8OYw5jaIvvhcMUMcG4YnK/WA 6MYvqY2kHW1+h4L4lxGkdvLCUPcBHajQRQ+iORRoagPRdhJqpvOwWfjB40XGOaBjF/il E81Sdq9ZHF997hcz3TClG+144PWE22QXMD9k4GUnZdee+6WgpGGJJ9bfextEL2LlAfMv LY4gpW60Heh1Pscz+kZ2cSFXbYt5whrdYogcoSEVtnBRiAf/ML8QXOMxqlSdEm8ZtPCe ktmIwEvQJkozUD1+rN3NTASZSq+wpDmckS+VcdCnukOCvN1cfRKkwKZ7BrwV5sVQCha5 KLfw== 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=PrJiaRI3Ch6Yo83pZv4WNPRv7mWs/cOYj1CjaSSyKDbcLjiNLm//QBUG8h9j2w+wu+ ddgDcOjjgzGnR8wQhQNRACxqChCgfJigjjAbAGk0MJiQi7dfNHtEn5gpCcUEKZN+JB04 j+R9oT/SWY1tqNgy3pmgOBnGLHn1x+4UZZuhgxRqsuyC1pMjm00fohJ4uAsXu15AgxuS +EaFStvZ2lDVr8N+LlVVwnrUR/Alwd3/Vowi7MvPZ01K8D2ZvdeIqSgAtoxRdYMeVYuf 3O90+wvQCJJIXFRXC0YK8lfjwfbfcfqcm3jBCOt8eddcziVUL7C1nMFXNzxMcGLJf/rN C+Gw== X-Gm-Message-State: AOAM533hppiw+9+a6/76HIdyO5UiLyt9jwWV3Yowa7d6haxScObMGs4Z mlXoi1rMms95L6e3xi1/ilv9UNMD8vg= X-Google-Smtp-Source: ABdhPJze3++BcbDH2DcS8qefgAjU/K2ilbycq/PHSs9HlOJqP4jqMjY6Pi716p1t21PAzQtR3wZ3sg== X-Received: by 2002:a5d:62c3:0:b0:1e3:2d29:fc3f with SMTP id o3-20020a5d62c3000000b001e32d29fc3fmr2414795wrv.331.1645106132023; Thu, 17 Feb 2022 05:55:32 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x1sm9949734wrn.12.2022.02.17.05.55.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 05:55:31 -0800 (PST) Message-Id: <2bd3d44ba57ddb43c09367b45a8f056233d465e9.1645106124.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 17 Feb 2022 13:55:22 +0000 Subject: [PATCH v2 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 Thu Feb 17 13:55:23 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: 12750166 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 6FC49C433EF for ; Thu, 17 Feb 2022 13:55:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241504AbiBQNz6 (ORCPT ); Thu, 17 Feb 2022 08:55:58 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241485AbiBQNzt (ORCPT ); Thu, 17 Feb 2022 08:55:49 -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 5C61E2740E9 for ; Thu, 17 Feb 2022 05:55:34 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id p9so9137799wra.12 for ; Thu, 17 Feb 2022 05:55:34 -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=SGXg44M9a7KJzl1OrS7MrfrbseKtTwpwbDIGKGp/EhqTXJsPJ5n1S4akXLrPnC5Drd 7Y3DZRQ8qPVaOTUpQyyKMduVAVSKfYOyLJ5Mw+clx0jF66GB8e/bwYzdIqXYt3thXQ/4 fiQ5tlqUgmtKgvwhJQbrL4m0gWL0GhEg1mKS36lvnvJ9ehpraj+tjHWh2QzegdOOZDua rztdht+LcpPdy1ksjCDm4t89uiVFz1hFQxn3C9en5xnxJ6du89akgQh305txtrQB0JIT J6TlmkIwlqinP34oJ/XdsyYMyKo1LBwcGOKUmHsxzfeF/M1i+a8mCthOroAGiiRd3Eko I/eA== 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=OgPOi66GMUcSqMSgPhFHHbyWKNFmQue+A3DMDsj1Rbccrm/z/zg8xN/pBtEq4z32Tw pKUAkTnLnVs5foOVjJwEzW6UWIwv4fYX0zksDSMwGQ/Ahse0pxqW42CjlHkneaFQ7AXf V7YkAqRVDF+FNI4Q8B4Bp/WitV+f81fIYVMdUa/GOXGUjWLsHxwAVk7hEbDYlbmr/KqM /ot9hKpJY/vgfot79g0JwMerTHHNMF1JpNLsOrdwB4dEkvP47/1xdCjNG4hdPJ3n9NIL 4GtcPAICJwx2d2d1S+a8porc5MuqB3LWCKkFegnciept7a17STABnm5R9lFD9AOVOEOU QJvQ== X-Gm-Message-State: AOAM532flT/gA3TySD5SXFGLj+BjhwGJIew/XahtLzZPdZYLzLoE3jaf 2RllWJCqH3f7aTsH9GYaTxK34Aj9xac= X-Google-Smtp-Source: ABdhPJzl3Quop9mI0M/ivRjd4sWfb/hVEQxi+rSt5HW+1voBxFJymOacXuW9rHwAJWIRZh03/roHkQ== X-Received: by 2002:a05:6000:2c5:b0:1e6:2be7:b0fc with SMTP id o5-20020a05600002c500b001e62be7b0fcmr2399145wry.154.1645106132844; Thu, 17 Feb 2022 05:55:32 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m22sm1506899wmq.35.2022.02.17.05.55.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 05:55:32 -0800 (PST) Message-Id: <82d36ee0e0d7fedd40e4cc9013dbf469218fb68f.1645106124.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Thu, 17 Feb 2022 13:55:23 +0000 Subject: [PATCH v2 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 Thu Feb 17 13:55:24 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: 12750167 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 44029C433F5 for ; Thu, 17 Feb 2022 13:55:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241497AbiBQN4D (ORCPT ); Thu, 17 Feb 2022 08:56:03 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:42802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241486AbiBQNzt (ORCPT ); Thu, 17 Feb 2022 08:55:49 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A721274C8C for ; Thu, 17 Feb 2022 05:55:35 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id d27so9177508wrc.6 for ; Thu, 17 Feb 2022 05:55:35 -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=G493jZIVnfsS+DVM7TpWtvtj7ZQC6bBC+PD9EVWo9WNKr8o0t29AKlTZrvOsm836R9 DCXTKnsiW2PwxzOsbASFqCNQKI9C5URe9zrWkbU7H9xzQioEFC7expRE9NFngT0mNoLG yRO8A4tY48aR2B96jNf6hdN19aS3OCF1VWEl0Q9AxEydWEyuIzD+PEZWUkB+A+oY6qOt 4YiS70knrE3756OSEBAxh3IZ5IaietFexdahFn9RB9UX1bKCJaXVoGoQxin/HFoqlbIc lT9fo2impf0hxhh6dNb1NQzc6nWVSzIlsl8lKSxyf8kwIMvAGSaFHeiNL0B9kfQReSmd mjKg== 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=Lm1F03WQybsofmtJf+9Bjd76m3hjZPYZQ/2uhTA+/FoMoiUNzo4YX8Yz5W8e3a2ZyV Etwkj3AZs4m5gk3SXBaNERqjvXpxU2rFZP+dI8l9ID0Fa3Rb72megNGOtIspmb5SIu+e jE1Rxne1lg4Z90jMB0y7Hvd5fR5BsiIVvF9/Lq1ZG50N7Jx2hbas3AXAxSHTX59K02dI 9Nmy+T2kGE+eNmLxphhu6OVbLPoyNpBO0OrfMnUXB/VYFySnQqQ1I4UAhsrVEreswjiI bZhmEMEMtwnATMAU4NBLQ3OJYYVCGrTJMI0uA5yjop84oHMaRAH2T0Qqd81TSe5jCkGp z7XA== X-Gm-Message-State: AOAM532eblzQGYr/9cBXUNu2HS0IEtS2z16xonsUkrNitj1ewtSBz/46 lX9jofdrg7xa/vHR8JdODvlg191EYZs= X-Google-Smtp-Source: ABdhPJwqb5Ds8vqbALh+DYGMg5oEX80eawnsDLGCquk9GCIMQUqtNThd4C/BjSu/PfFAWf4O42PT2w== X-Received: by 2002:adf:dd92:0:b0:1e4:eee1:91be with SMTP id x18-20020adfdd92000000b001e4eee191bemr2474253wrl.414.1645106133654; Thu, 17 Feb 2022 05:55:33 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j10sm1824960wmq.20.2022.02.17.05.55.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 05:55:33 -0800 (PST) Message-Id: In-Reply-To: References: Date: Thu, 17 Feb 2022 13:55:24 +0000 Subject: [PATCH v2 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; }