Re: [PATCH v2 04/17] refs/files: remove useless indirection
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Jan 12, 2026, 10:01 UTC
- Message-ID
- <CAOLa=ZSGd76M=Dj0E512w23rtGM2eEvYeMMCzFffh-oNJ4br-Q@mail.gmail.com>
- In-Reply-To
- <20260112-pks-refs-verify-fixes-v2-4-2e9e453bd6c3@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 43 quoted lines
> The function `files_fsck_refs()` only has a single callsite and forwards
> all of its arguments as-is, so it's basically a useless indirection.
> Inline the function call.
>
> While at it, also remove the bitwise or that we have for return values.
> We don't really want to or them at all, but rather just want to return
> an error in case either of the functions has failed.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> refs/files-backend.c | 16 +++++++---------
> 1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/refs/files-backend.c b/refs/files-backend.c
> index 0a104c7bf6..4cbee23dad 100644
> --- a/refs/files-backend.c
> +++ b/refs/files-backend.c
> @@ -3954,22 +3954,20 @@ static int files_fsck_refs_dir(struct ref_store *ref_store,
> return ret;
> }
>
> -static int files_fsck_refs(struct ref_store *ref_store,
> - struct fsck_options *o,
> - struct worktree *wt)
> -{
> - return files_fsck_refs_dir(ref_store, o, wt);
> -}
> -
> static int files_fsck(struct ref_store *ref_store,
> struct fsck_options *o,
> struct worktree *wt)
> {
> struct files_ref_store *refs =
> files_downcast(ref_store, REF_STORE_READ, "fsck");
> + int ret = 0;
>
> - return files_fsck_refs(ref_store, o, wt) |
> - refs->packed_ref_store->be->fsck(refs->packed_ref_store, o, wt);
> + if (files_fsck_refs_dir(ref_store, o, wt) < 0)
> + ret = -1;
> + if (refs->packed_ref_store->be->fsck(refs->packed_ref_store, o, wt) < 0)
> + ret = -1;
> +I wonder if this should have been a logical or instead of the bitwise or, but then we directly return so even that wouldn't work. This looks good! Thanks