From: Elijah Newren <newren@gmail.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH 2/2] string-list API users: manually use string_list_init_*()
Date: Thu, 21 Jul 2022 00:48:51 -0700 [thread overview]
Message-ID: <CABPp-BFiNXM_2kfOQ+BnC5bWVEVZTk2kiFNuPSPPsz+5owM9kA@mail.gmail.com> (raw)
In-Reply-To: <patch-2.2-5d8baa9cbc4-20220721T063543Z-avarab@gmail.com>
On Wed, Jul 20, 2022 at 11:39 PM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
> Convert various code that didn't use string_list_init_*() to do so, in
> cases where the only thing being allocated was the string list we can
> change from CALLOC_ARRAY() to ALLOC_ARRAY(), the string_list_init_*()
> function will zero out the memory.
>
> This covers cases that weren't matched by tho coccinelle rule in the
s/tho/the/ ?
> preceding commit, which is conservative enough to care about the type
> of what we're modifying.
>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
> notes-utils.c | 4 ++--
> reflog-walk.c | 2 +-
> 2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/notes-utils.c b/notes-utils.c
> index d7d18e30f5a..73559d24ec8 100644
> --- a/notes-utils.c
> +++ b/notes-utils.c
> @@ -129,8 +129,8 @@ struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd)
> c->cmd = cmd;
> c->enabled = 1;
> c->combine = combine_notes_concatenate;
> - CALLOC_ARRAY(c->refs, 1);
> - c->refs->strdup_strings = 1;
> + ALLOC_ARRAY(c->refs, 1);
> + string_list_init_dup(c->refs);
But c->refs is a struct string_list *; why doesn't cocci recognize
this one and convert it?
> c->refs_from_env = 0;
> c->mode_from_env = 0;
> if (rewrite_mode_env) {
> diff --git a/reflog-walk.c b/reflog-walk.c
> index 7aa6595a51f..2b17408f9a4 100644
> --- a/reflog-walk.c
> +++ b/reflog-walk.c
> @@ -120,7 +120,7 @@ struct reflog_walk_info {
> void init_reflog_walk(struct reflog_walk_info **info)
> {
> CALLOC_ARRAY(*info, 1);
> - (*info)->complete_reflogs.strdup_strings = 1;
> + string_list_init_dup(&((*info)->complete_reflogs));
Makes sense.
> }
>
> void reflog_walk_info_release(struct reflog_walk_info *info)
> --
> 2.37.1.1095.g64a1e8362fd
>
next prev parent reply other threads:[~2022-07-21 7:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-21 6:39 [PATCH 0/2] string_list API users: use alloc + init, not calloc + strdup_strings Ævar Arnfjörð Bjarmason
2022-07-21 6:39 ` [PATCH 1/2] string_list API users + cocci: use string_list_init_dup() Ævar Arnfjörð Bjarmason
2022-07-21 6:39 ` [PATCH 2/2] string-list API users: manually use string_list_init_*() Ævar Arnfjörð Bjarmason
2022-07-21 7:48 ` Elijah Newren [this message]
2022-07-21 12:00 ` [PATCH v2 0/6] string-list API user: fix API use, some with coccinelle Ævar Arnfjörð Bjarmason
2022-07-21 12:00 ` [PATCH v2 1/6] string_list API users + cocci: use string_list_init_dup() Ævar Arnfjörð Bjarmason
2022-07-21 12:00 ` [PATCH v2 2/6] cocci: apply string_list.cocci with --disable-worth-trying-opt Ævar Arnfjörð Bjarmason
2022-07-21 12:00 ` [PATCH v2 3/6] reflog-walk.c: use string_list_init_dup() Ævar Arnfjörð Bjarmason
2022-07-21 12:00 ` [PATCH v2 4/6] cocci: add "string_list" rule to swap "DUP" <-> "NODUP" Ævar Arnfjörð Bjarmason
2022-07-21 12:00 ` [PATCH v2 5/6] string-list API users: don't tweak "strdup_strings" to free dupes Ævar Arnfjörð Bjarmason
2022-07-21 12:00 ` [PATCH v2 6/6] notes.c: make "struct string_list display_notes_refs" non-static Ævar Arnfjörð Bjarmason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABPp-BFiNXM_2kfOQ+BnC5bWVEVZTk2kiFNuPSPPsz+5owM9kA@mail.gmail.com \
--to=newren@gmail.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).