Re: [PATCH v2 6/6] test-tool: add helper for name-hash values
- From
Patrick Steinhardt <ps@pks.im>
- Date
- Sep 24, 2024, 07:02 UTC
- Message-ID
- <ZvJj7PeB52m_1mG9@pks.im>
- In-Reply-To
- <7e47fc8cb53647ad92c86801204c3089a5dfe8e6.1726692382.git.gitgitgadget@gmail.com>
On Wed, Sep 18, 2024 at 08:46:21PM +0000, Derrick Stolee via GitGitGadget wrote:
Show 30 quoted lines
> From: Derrick Stolee <stolee@gmail.com>
> diff --git a/t/helper/test-name-hash.c b/t/helper/test-name-hash.c
> new file mode 100644
> index 00000000000..15fb8f853c1
> --- /dev/null
> +++ b/t/helper/test-name-hash.c
> @@ -0,0 +1,23 @@
> +/*
> + * test-name-hash.c: Read a list of paths over stdin and report on their
> + * name-hash and full name-hash.
> + */
> +
> +#include "test-tool.h"
> +#include "git-compat-util.h"
> +#include "pack-objects.h"
> +#include "strbuf.h"
> +
> +int cmd__name_hash(int argc UNUSED, const char **argv UNUSED)
> +{
> + struct strbuf line = STRBUF_INIT;
> +
> + while (!strbuf_getline(&line, stdin)) {
> + uint32_t name_hash = pack_name_hash(line.buf);
> + uint32_t full_hash = pack_full_name_hash(line.buf);
> +
> + printf("%10"PRIu32"\t%10"PRIu32"\t%s\n", name_hash, full_hash, line.buf);
> + }
> +
> + return 0;
> +}This patch breaks t5310 with the leak sanitizer enabled due to the leaking `struct strbuf line`. It needs the following diff on top:
diff --git a/t/helper/test-name-hash.c b/t/helper/test-name-hash.c index 15fb8f853c..e4ecd159b7 100644 --- a/t/helper/test-name-hash.c +++ b/t/helper/test-name-hash.c @@ -19,5 +19,6 @@ int cmd__name_hash(int argc UNUSED, const char **argv UNUSED) printf("%10"PRIu32"\t%10"PRIu32"\t%s\n", name_hash, full_hash, line.buf); } + strbuf_release(&line); return 0; } I also plan to eventually have a deeper look at your patch series, but didn't yet find the time to do so until now :( Patrick