]> git.ipfire.org Git - thirdparty/git.git/commitdiff
ref: initialize "fsck_ref_report" with zero
authorshejialuo <shejialuo@gmail.com>
Wed, 20 Nov 2024 11:51:08 +0000 (19:51 +0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Nov 2024 23:21:31 +0000 (08:21 +0900)
In "fsck.c::fsck_refs_error_function", we need to tell whether "oid" and
"referent" is NULL. So, we need to always initialize these parameters to
NULL instead of letting them point to anywhere when creating a new
"fsck_ref_report" structure.

The original code explicitly initializes the "path" member in the
"struct fsck_ref_report" to NULL (which implicitly 0-initializes other
members in the struct). It is more customary to use "{ 0 }" to express
that we are 0-initializing everything. In order to align with the
codebase, initialize "fsck_ref_report" with zero.

Mentored-by: Patrick Steinhardt <ps@pks.im>
Mentored-by: Karthik Nayak <karthik.188@gmail.com>
Signed-off-by: shejialuo <shejialuo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
refs/files-backend.c

index 0824c0b8a946909791da36ddb4171db4ad98913b..03d250327699dcc7ef449fe4f4d410ac5c8ddb0e 100644 (file)
@@ -3520,7 +3520,7 @@ static int files_fsck_refs_name(struct ref_store *ref_store UNUSED,
                goto cleanup;
 
        if (check_refname_format(iter->basename, REFNAME_ALLOW_ONELEVEL)) {
-               struct fsck_ref_report report = { .path = NULL };
+               struct fsck_ref_report report = { 0 };
 
                strbuf_addf(&sb, "%s/%s", refs_check_dir, iter->relative_path);
                report.path = sb.buf;