From patchwork Wed Jan 12 18:07:42 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: 12711828 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 E0673C433F5 for ; Wed, 12 Jan 2022 18:08:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356008AbiALSIE (ORCPT ); Wed, 12 Jan 2022 13:08:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355991AbiALSHz (ORCPT ); Wed, 12 Jan 2022 13:07:55 -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 6DDF7C06173F for ; Wed, 12 Jan 2022 10:07:55 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id 25-20020a05600c231900b003497473a9c4so3952715wmo.5 for ; Wed, 12 Jan 2022 10:07:55 -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=lJ7b3bBv3b3uG3BqchnoNyGMYXOjb4U73VFWyZtFG9MW4R3tl1bESKi03XI+ZNK/sn Aly5pZgJFwNp8e8YkyBdDZrrZCyIu6lIKhmh+m5vYkAAc8Qr43Z2Hw69MNB5ngPs3Y6q 2mdfc+2XzOHGEq1eocsqdUnjFOL4eYb3wGgVr2iMLgp7A6+wbKXNA7T38wQxekbbO7jI 3m5awcZ+63t/l3FMg9SbU8ia4m17v6pA8XYfvFhesmyqTO2Kbx5V0qqJCAdLeqlsvxr0 DIAIb9gs9ipB+teL+574EsVCN5w2S7eZw4T47U2r+Q5RcMGEEXaeYp/lJByCDxA/bwtO FwWg== 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=MSqfskx1HhzCBrYxx9dARl2/cAg0BWOdk2BUkESlAUxsgXy8WfmgSZzEGVAU1wgxel sSyJsTD3gVflwiVdoHcDi9Y4EEIe75e+kjIF/M+sk0XZWXcVmuD9MLq7GzoAeVywubUU j8/FuAvVJnPp+TrYGpcX2ciuhHv0PdOGnifuUpuRdeJp9B2/06WJFz5pweyLKFJ+GfcT c5dYBxfysRW8LmIZztNu2U1V3ibhcCkDYFEKiGQIHXXZcNtBb5WJPcrwZS9lfNz9BmUX hqEKcP6l4EHVlTGp2ZgSmORGmic16hjVRblSr9OzP/rZRqJ+w6FBobes2fWd2O31ezu5 RcUQ== X-Gm-Message-State: AOAM532Uyukps5ZRUXPkel9gRmr9iY5SOUl1F/FoGpg7hgxwB+KcEZCQ goYLZRnmxjPqCHglXgUHBHC1C3gN2iQ= X-Google-Smtp-Source: ABdhPJxfk/503VFdz24ohiRKZWUwyxj/cg2ql/h3gF/hFbCFOTz6lbcf8l8TT6YNeTo/KwWQB60lFQ== X-Received: by 2002:a05:600c:19d4:: with SMTP id u20mr590973wmq.138.1642010873870; Wed, 12 Jan 2022 10:07:53 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v13sm385834wmh.45.2022.01.12.10.07.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 10:07:52 -0800 (PST) Message-Id: <2d2e1177ff7c15f9a026ebe1e1be17791d9930f0.1642010868.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 12 Jan 2022 18:07:42 +0000 Subject: [PATCH 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 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 Wed Jan 12 18:07:43 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: 12711829 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 14D14C433F5 for ; Wed, 12 Jan 2022 18:08:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356041AbiALSIL (ORCPT ); Wed, 12 Jan 2022 13:08:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356013AbiALSH5 (ORCPT ); Wed, 12 Jan 2022 13:07:57 -0500 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44012C061748 for ; Wed, 12 Jan 2022 10:07:57 -0800 (PST) Received: by mail-wm1-x336.google.com with SMTP id f141-20020a1c1f93000000b003497aec3f86so2126657wmf.3 for ; Wed, 12 Jan 2022 10:07:57 -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=GYvg7uphK81AcsqWjOpqtQOfvse9uVnaNdVSOr9lEPk=; b=JLX/q8u+2qGz6Et8y6XflrxcK9P16UvOudR1YNhrYagg7GZWbOihr9mBshQYzSOavR 1BkiRvinjXRWOh/8kdSinT7LFOjhM+vAumjaaZQgr/fbPOgtJr+TK/xVkYjqOt+xyVkh QHdmO8EqWgMgXI86YDqetMpvWY0lft1ZsdR8EDHfOY67rCJw3dYfUmPjsUQ5EEl5kO4X oDgZGxKJQoZs4zrWGyULNLzZCe2oP27OL4NZGcrJsZ7jpSeOoejTUJ0gFFKFcSEp1pf+ uby+3e5u7Q9LpDKrZpQ6sWhL41OGTV3gEEpCcZI4eLuTGCb4yhXA2DWhz0hspkAVsM+l Z3jw== 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=GYvg7uphK81AcsqWjOpqtQOfvse9uVnaNdVSOr9lEPk=; b=ULbFnKdt91szTv+FtEPRiC+Z5HDhnqlpRZx/GyHExi3Z/UwFNoR0Hc09DxAnxTN7lS Nr76UMGjgD4ZRUJVjVSyK/SyYpihVXlS8QRzUe2VHR9eiWgxmaSLN/bX4kWxpFN38PV7 QAsVN3IZGCeH/iz9JF3DzSX0OxtnUwxw68Ly5/D64RgeU1LaAkEzHWsEDWFQhfMN1Ebl 6ijm9ejSjfSmsBCSPtAy4f8Y3gvpqp/HuyDHEONvcd643vgbNzkmLbD4xuHVIVSePnKi JOrBimHNebN0tS9Wd7FovVkIPFN2gnJygU7etlpUXCVK1CMKwn/Kgbr24S7SQRpAJ2jt p2NA== X-Gm-Message-State: AOAM532bH26eQpFUaqcuaJqdV0HcdqV4QI7KOAA67geprKJF0DrpuG2w 0GVfUVtZceoDfdN4qy+dBXREzQVRQzU= X-Google-Smtp-Source: ABdhPJxtIs+ZOTZEzHcjAoHVKa3jgIVnxNNsygmc37ESrd/lfdFUD0js4C5P+l2lLBEnpj6bcIwKdg== X-Received: by 2002:a05:600c:34d2:: with SMTP id d18mr594400wmq.71.1642010875714; Wed, 12 Jan 2022 10:07:55 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id q206sm493999wme.8.2022.01.12.10.07.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 10:07:54 -0800 (PST) Message-Id: <747c9e9a4c8f18c324535ca0ab620d41c1dcc38b.1642010868.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 12 Jan 2022 18:07:43 +0000 Subject: [PATCH 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 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 006709a645a..21843f5e935 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 Wed Jan 12 18:07:44 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: 12711830 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 17C19C433EF for ; Wed, 12 Jan 2022 18:08:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356061AbiALSIP (ORCPT ); Wed, 12 Jan 2022 13:08:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356020AbiALSH7 (ORCPT ); Wed, 12 Jan 2022 13:07:59 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3BC2C061756 for ; Wed, 12 Jan 2022 10:07:58 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id t28so5746730wrb.4 for ; Wed, 12 Jan 2022 10:07:58 -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=6MkNuKv4G1pDWUPPSlqjs1wH3HAiX3o8gHdGijEbdcg=; b=qQ7WAWaAZ7NOMUqxjs5ZE4CkR66y//AFn6j8yYbtbU2QT8k+GMUB3Kk4xzZtnFsib9 /lpZw3+Msn3upIVIZs2C7YG1xbykiOujr38EXMKrul8UyP4F61dSsXv3IhXZkRWUiuoc R784dnBJ8WP8ZeZ/bP4GyBQ51aN9uzMrzUrs26tVbwnhbnvY7AwYhpmlfeBdV7O1G7Pw VfWN8nKoZJwza5IGbpNIUl9U3R6X6c6cIwXTqIhahDbFHoWLMmWjuRth8D2qZW/0SEaR 0JngUmnleIg81spniEkS1KpwbkiWGrzs7kf+hELFJUUuznwevs+o2UEe8SNlbss3wlhK Cg5g== 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=6MkNuKv4G1pDWUPPSlqjs1wH3HAiX3o8gHdGijEbdcg=; b=pIugM4N/ZFYYv43e9/MtiExAcXzf/vmkJs+vj7DhGMQSm6DGndw8/0vpQmybqiZjk2 iLpeub+WQnuD4Fv01Zofd7AUDfVuKrFoHX2n5lzQD5Qx03MF5B1PAXd3KmtUmAveEwrp +QCcRfHx5MZSp+jknq2Lvwhe0RZKcskYaoo/pbRoBVfVm5R9+iKh1SVQWCBzExJFL++n +UFEIznz/7bZ564uawdTj/4tof3cSODaax0i40+Xn3fZfXVz3WVKpEkGzlLfKS2bs4oa u28w2RutG5GwRSH5Nq8JVuGmVfQQoTf9UUg8gRXetSiGdsDnMYzKZ+JEdMF5yZah48WQ p/WA== X-Gm-Message-State: AOAM53320ApUD3Og9V54bSWmy6v4UcQrbsWm4cS6ptitu8ZQF2xA0Rn3 AuKfqjKB3iQn29JZJZzwlEDV/YnMwas= X-Google-Smtp-Source: ABdhPJz1Xp6y9CRj47YVX61igqds/5THr+mtkbrmkmOFyJ2PwmAeHZ/Sjc6wwemuvMdVIcN4gLFZgg== X-Received: by 2002:a05:6000:1191:: with SMTP id g17mr807482wrx.512.1642010877383; Wed, 12 Jan 2022 10:07:57 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h205sm2481058wmh.19.2022.01.12.10.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 10:07:56 -0800 (PST) Message-Id: <4eefedb0d07f762c98e8699c56a58b80df36ebe9.1642010868.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 12 Jan 2022 18:07:44 +0000 Subject: [PATCH 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 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 70c7aedba2c..a315c8992e8 100644 --- a/reftable/readwrite_test.c +++ b/reftable/readwrite_test.c @@ -602,6 +602,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 }; @@ -681,6 +704,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 Wed Jan 12 18:07:45 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: 12711831 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 2A431C433EF for ; Wed, 12 Jan 2022 18:08:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356064AbiALSIT (ORCPT ); Wed, 12 Jan 2022 13:08:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356010AbiALSIB (ORCPT ); Wed, 12 Jan 2022 13:08:01 -0500 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C802CC061748 for ; Wed, 12 Jan 2022 10:08:00 -0800 (PST) Received: by mail-wr1-x429.google.com with SMTP id t28so5746874wrb.4 for ; Wed, 12 Jan 2022 10:08:00 -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=Nflc5OL0l2+WTlx5voRLLLe810fY06mgtUWSK/SMGUk=; b=EQ+Bmucs9jUzK4XSOG17kBpg9JapfijWRtnO7RelcOJZN0vtQr+H54GU0Z+TyBpHBc i9H43iH8auZOHZoV2mk2QP3QAoGvvGtCClT5LQ8tedQ8Qm4r/9MuQ5jzonVQh2Ku4aAu x/iseQd3rWoKrgQqsMymm9TPs7AnkvblvT/lPenn5UNy7o/0k8bylaGq54QgVm1PT/9u 55Re+2H2x/L6o9BQ9OQVfdxrQEstPjOQSXrxLVks5FV+MaBTUJgUgnzaLs8+Bn4AMjaM J1h5Pdb3ZnDXxNvs/q4TP/9oYAgm0R0ufSWHseGlCY688QWu6DvlGH2WBwMROomwmrPL NCKw== 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=Nflc5OL0l2+WTlx5voRLLLe810fY06mgtUWSK/SMGUk=; b=SGI7jIaLFVOCBsgzsg3G05smdoRBThaaJJyysbYApP0G4ucp78VcsPmnYmuTb6ukPc gw48eVLREFYqi0fXp9vnDTmHWyQKBoT2XdNeQ42UProB1FDmLRLEswie17rQzk0+duxo 99zT37YdPAx5Xaj3DT8nl6UA/aOXNijJIdD52x7Guy7mfSWtCY3U80oHMwE80RH1QgV5 gOm8lc0hy29WjE1E8y06dKz5pTkuV06H6jcH3+pqYcI+4rdUBlFDweRYu6MVU1TZDfUA xcmrOVQpn0TQoYzZxN3cfNfMhz2ZGgAMYzS9a9yHJWJSpbriZ8U3oyTXbIZKZJwLny4r 2gkA== X-Gm-Message-State: AOAM530dtEYcw3jvlYXVSwLEq2crTdRiyUm2hqWW6zmX6Vd6Np1UshyP iPqzXL1xfVD3MbQzDPVhkPetgsV84Tg= X-Google-Smtp-Source: ABdhPJz6jeZ8Hn2HwwQ8gnmsZDyqhHhu8ff6Pa7xgh5PX2IfJ2fDzCXXMgEKClNeaPcXW1iWMzq/uQ== X-Received: by 2002:a5d:608e:: with SMTP id w14mr123618wrt.40.1642010879248; Wed, 12 Jan 2022 10:07:59 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u3sm668892wrs.0.2022.01.12.10.07.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 10:07:58 -0800 (PST) Message-Id: In-Reply-To: References: Date: Wed, 12 Jan 2022 18:07:45 +0000 Subject: [PATCH 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 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 855e3f5c947..8725eaaf64f 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) @@ -324,6 +326,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) @@ -350,6 +355,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 4b3ea262dcb..5112ddbf468 100644 --- a/reftable/block_test.c +++ b/reftable/block_test.c @@ -42,6 +42,11 @@ static void test_block_read_write(void) header_off, hash_size(GIT_SHA1_FORMAT_ID)); reftable_record_from_ref(&rec, &ref); + ref.refname = ""; + 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 35c8649c9b7..e3c042b9d84 100644 --- a/reftable/writer.c +++ b/reftable/writer.c @@ -238,14 +238,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 Wed Jan 12 18:07:46 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: 12711832 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 137CEC433F5 for ; Wed, 12 Jan 2022 18:08:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343832AbiALSIY (ORCPT ); Wed, 12 Jan 2022 13:08:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356045AbiALSIC (ORCPT ); Wed, 12 Jan 2022 13:08:02 -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 853AAC061751 for ; Wed, 12 Jan 2022 10:08:02 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id k18so5695285wrg.11 for ; Wed, 12 Jan 2022 10:08:02 -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=wLutDQefu1ycD6mtB8C9FX3UTtjhlPxPgIFoAKuN6Dk=; b=l8hwrj2jXZ+FQjweKlRbJyrJHrCPJyGQTS/iYHI71UJRfCOQcmRp+nyaCMlbt0xPmh 1SisoCvjy5L+1IrN5sAEwbl2nYqtziGK4xosh9xzoIYvM4NWrLq1PfGrb/YM/eY/86FZ I4jb3T3e7ZYqhWpFqFwbO2EpSWwlp+ShQePa+WVsasIEGq56dJG6wbeRXwTfLPvLZr0c LnoTUGWAprZrhdNvnnZZU1cRp5YBkQVoJAT0EFEcVxT0zkibNvtW/hojBEzTrmbGN2Gt zwBCw6e4dObGmFQMOlCJLiqSzmCV8IGt3jY/g7RhH6kyZlRkEbJIOx5jkKaapt1IXq+Z 9GLA== 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=wLutDQefu1ycD6mtB8C9FX3UTtjhlPxPgIFoAKuN6Dk=; b=UhJulK5No2wHTVdgPfr4OpQ0Q59M5WFXPmy6FW8LTUQ0hwINOu8IWoe/XzkacLG57M ViLsKM8pi1TerzjdJhjoR/xBwLQ9ikxXdvNn+jNaBB3GMVtkPu+Gcw/kL+kU9crVPulY P3HDBCUNVVBqRRZLYT3Tdy967dO+uswQzT6T7Bn7jWG91/tPmv/W8rsxCCjUVOgc5jxA HgVZWGTnOdlCqTVWQekZjDgleITaSPKHtcJSwJp3eWymd8w/dcv6DcjAs7HzRAxQe7oY wFJRWFXdB2fivsbXp9TxMrIhVbKOWFulkShTpvnotzrhnwO5zQW+V8a14I3FNjsOpsIw ZQOQ== X-Gm-Message-State: AOAM532QNXZNCQw7IPt668qYi9aeVR/5HPl4VMKkqr6jTh3NUsUDlB2c rCOqjNNjYvEAw+8R9HRro75dORDJaUY= X-Google-Smtp-Source: ABdhPJx07OEybRsHcI3uKTQa4h0iOH9kv7ZblT3YSGEwK+irUhl9t/gjSiYYi/Plx8Tkr051HJelqw== X-Received: by 2002:adf:ce03:: with SMTP id p3mr795534wrn.674.1642010880862; Wed, 12 Jan 2022 10:08:00 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z4sm386533wmf.44.2022.01.12.10.07.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 10:08:00 -0800 (PST) Message-Id: <3a72aba447c1405595922bc64b7f7a1a873a033a.1642010868.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 12 Jan 2022 18:07:46 +0000 Subject: [PATCH 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 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 a315c8992e8..b4371b75724 100644 --- a/reftable/readwrite_test.c +++ b/reftable/readwrite_test.c @@ -602,6 +602,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 }; @@ -707,5 +743,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 e3c042b9d84..f94af531351 100644 --- a/reftable/writer.c +++ b/reftable/writer.c @@ -508,7 +508,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 Wed Jan 12 18:07:47 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: 12711833 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 736F0C433EF for ; Wed, 12 Jan 2022 18:08:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348673AbiALSIe (ORCPT ); Wed, 12 Jan 2022 13:08:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356048AbiALSIF (ORCPT ); Wed, 12 Jan 2022 13:08:05 -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 A1AFEC06175B for ; Wed, 12 Jan 2022 10:08:04 -0800 (PST) Received: by mail-wm1-x333.google.com with SMTP id d187-20020a1c1dc4000000b003474b4b7ebcso2114831wmd.5 for ; Wed, 12 Jan 2022 10:08:04 -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=vwJx8iRTPLmFeX12/wh6IKg6If3i52naEEkxm1fRYVQ=; b=W2s2lFpChYedcLchYIpoLUd/u6Ev/12tlecwEFAgY4IuHfhzYhpjZC9XxCnoevPie4 H1cZto/G4+GHaKBau8fYFHukp6xVEaLyZm6tETqFyNMBg8seBq5iiOHrFstGQNW7X/qb zS9b935ubWxzU7fr3SoWMOubhkIDO4hVfWA/VPgqR/bkPmmWPVYUx8cOqlJJJVkztZ/A y6Vp2FUPQuWJ9u1WUBTqAHBkimF8YBqv5UXpTkhYwzY1OaVKBcWGc0g9CDz3aMD5gWIw yTb5Z/KNP4x2sYQOV2cmeLHIJyYehTiK8ll1STxJeTIQP6nKeQaUOrMbqYndSTkEPaq4 n1HA== 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=vwJx8iRTPLmFeX12/wh6IKg6If3i52naEEkxm1fRYVQ=; b=CgbJNu3SoKqKwF7URDfUXDhUdd890ZzD+3Yu9oqCugL3+UhyGm1mYdKxKH9e/PRMR7 wwQ6VhUzuaZaHXIVe4FLleCYpyAR2abLHFKRp2PWatZh0vgB3q4y4qriH7rTjJ44XRBN 26NPAJCQNkRTeYx9jwT2XngYxmUERgKCL61cESTbf4fPGC7A7so8CLLb6HlLZ7A/ntQs hrQP9zxempAYCMi8OLm/tUNtN12Bejqv1/p8LqZD7wZ1YtDKNUMdY8z2oqO9fzFyUhU3 /yXwkYsMs9W2549QqlRw6olSMV6UkNRxjzeXR4F3wBCsVmqztdGJol2xJlV1jmBVwj1k visA== X-Gm-Message-State: AOAM532fWRddA6C5qW0OKQRmUX8qKKLizHSc3Z4ou0jaimT6iDTLhwyt dGqgV7rhzAP0Nvw+Xs0PIXyLSSK3EyY= X-Google-Smtp-Source: ABdhPJz3sCnCgntyzeS7GCwot2xwUhVbqvgLMErgqzvm2VaeIF9RYiRltEzWL4Xs7pMJLGSlS5ZRKQ== X-Received: by 2002:a1c:f613:: with SMTP id w19mr7806568wmc.58.1642010883080; Wed, 12 Jan 2022 10:08:03 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d5sm470555wrs.61.2022.01.12.10.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 10:08:01 -0800 (PST) Message-Id: In-Reply-To: References: Date: Wed, 12 Jan 2022 18:07:47 +0000 Subject: [PATCH 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 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 b4371b75724..5f45cee39d6 100644 --- a/reftable/readwrite_test.c +++ b/reftable/readwrite_test.c @@ -638,6 +638,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 }; @@ -743,6 +780,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 Wed Jan 12 18:07:48 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: 12711834 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 F36D5C433EF for ; Wed, 12 Jan 2022 18:09:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356054AbiALSJF (ORCPT ); Wed, 12 Jan 2022 13:09:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356050AbiALSIK (ORCPT ); Wed, 12 Jan 2022 13:08:10 -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 B0FF4C06173F for ; Wed, 12 Jan 2022 10:08:05 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id e9so5771742wra.2 for ; Wed, 12 Jan 2022 10:08:05 -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=+z3yk49eb9SiUj3sMvBsLD82Avj1LArAl/R1zWEclUg=; b=bxIEleTtmVMKEiBOxbT9L28hLMuVteC7Vdm80L7HdOKOUEs8CzE+UUzg1SQx+45vTQ 2zdQlTxFE0qtya2n5B4bYZukBCgeDyCC5XkRb8fbCoEtl2nsQJGcXokicfJQQmDq4vus IST0VAHDh4oG6DNJuekxUB+NWKAVmi8J5+psdlwJU2s6j7EQzsLXzJ0/G1+HZ/S5gKti sAcYz0VNhSM1Q4GNwZqQVN9gxtkvYmZKIuClmdAoM1RoQ0kfnYYhLCDQa61OAWA/7hip Cj2hvUa446HIWopCos/QpUiCAHiCHdlZYlqRHPE1k11bIvpQaWkyQ0f80VQ+8bdNgxv5 BGBw== 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=+z3yk49eb9SiUj3sMvBsLD82Avj1LArAl/R1zWEclUg=; b=4eEgoIbzGrgoAJNDjwIOn/FzBYLgkuuDIjNx5LJeMkgYFGb/3Kguqgw0czsBKlfrwm xGKOAesLePKOjp4+GUN6MGummgeIOWbdwhfGGJRPS2sjaMEcRz2fAVy92vMYnvInmdO4 jF+eGIRR2FQ4XG8V6Kv6cllOqtEApicf6XyCtJnfVBs3wiIOn5UxChI5MqEly0D0Gfco TImEccixn41eLATfqYyQ7W/DR25wxOR24/BoBLnyiVpr5a9LAWYjucFbOjqHDxx2nDod ct+Lk1c9Rpqr43R78NaY7EIl1C0m9CaqZDkLIcY6TF7aiDrAC82J47+RifFvucNSwJhD 6m6w== X-Gm-Message-State: AOAM531WSQIojzm56/2NnwriwwYOVFbX4RnT53lPEFJ4UsM7rMj8B90Q HcuO3SjdYUOQU8HzA5S53YV5OIwDWt4= X-Google-Smtp-Source: ABdhPJxqDOVIZ4C/6WIbf27IPMbRzSvT9USpf7p39YrSN6meIVZZZ8O6Lc7t2vRlpnToebTCs7+Ohw== X-Received: by 2002:adf:8b50:: with SMTP id v16mr864767wra.44.1642010884193; Wed, 12 Jan 2022 10:08:04 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 1sm681559wrb.13.2022.01.12.10.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jan 2022 10:08:03 -0800 (PST) Message-Id: <37aa7744c844f040995eca93d3b794d3af3087a9.1642010868.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 12 Jan 2022 18:07:48 +0000 Subject: [PATCH 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 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 | 8 ++++---- reftable/reftable-writer.h | 2 +- reftable/writer.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/reftable/readwrite_test.c b/reftable/readwrite_test.c index 5f45cee39d6..b1ff46c18a9 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; @@ -633,7 +633,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); } @@ -670,7 +670,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 f94af531351..495784e6294 100644 --- a/reftable/writer.c +++ b/reftable/writer.c @@ -688,7 +688,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; }