git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] reftable: avoid initializing structs from structs

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jan 13, 2022, 17:13 UTC
Message-ID
<220113.86r19btv5a.gmgdl@evledraar.gmail.com>
In-Reply-To
<pull.1188.git.git.1642092934523.gitgitgadget@gmail.com>
On Thu, Jan 13 2022, Han-Wen Nienhuys via GitGitGadget wrote:
> From: Han-Wen Nienhuys <hanwen@google.com>

Ah, nevermind <220113.86v8yntxfb.gmgdl@evledraar.gmail.com>, so you meant *want[] :)

I can confirm that this works on the xlc version that errored on this before, the reftable tests even pass!

> Apparently, the IBM xlc compiler doesn't like this.

Would make sense to steal the compiler version etc. details from my <patch-1.1-7425b64c0a0-20220113T113821Z-avarab@gmail.com>. I.e. eventually we'll be able to change this & other code back, as nobody will care about that older compiler version. It worked before in the pre-image on a more recent xlc.

Show 71 quoted lines
> Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
> ---
>     reftable: avoid initializing structs from structs
>     
>     Apparently, the IBM xlc compiler doesn't like this.
>     
>     Signed-off-by: Han-Wen Nienhuys hanwen@google.com
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1188%2Fhanwen%2Freftable-xlc-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1188/hanwen/reftable-xlc-v1
> Pull-Request: https://github.com/git/git/pull/1188
>
>  reftable/merged_test.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/reftable/merged_test.c b/reftable/merged_test.c
> index 24461e8a802..abd34849fca 100644
> --- a/reftable/merged_test.c
> +++ b/reftable/merged_test.c
> @@ -207,11 +207,11 @@ static void test_merged(void)
>  		},
>  	};
>  
> -	struct reftable_ref_record want[] = {
> -		r2[0],
> -		r1[1],
> -		r3[0],
> -		r3[1],
> +	struct reftable_ref_record *want[] = {
> +		&r2[0],
> +		&r1[1],
> +		&r3[0],
> +		&r3[1],
>  	};
>  
>  	struct reftable_ref_record *refs[] = { r1, r2, r3 };
> @@ -250,7 +250,7 @@ static void test_merged(void)
>  
>  	EXPECT(ARRAY_SIZE(want) == len);
>  	for (i = 0; i < len; i++) {
> -		EXPECT(reftable_ref_record_equal(&want[i], &out[i],
> +		EXPECT(reftable_ref_record_equal(want[i], &out[i],
>  						 GIT_SHA1_RAWSZ));
>  	}
>  	for (i = 0; i < len; i++) {
> @@ -345,10 +345,10 @@ static void test_merged_logs(void)
>  			.value_type = REFTABLE_LOG_DELETION,
>  		},
>  	};
> -	struct reftable_log_record want[] = {
> -		r2[0],
> -		r3[0],
> -		r1[1],
> +	struct reftable_log_record *want[] = {
> +		&r2[0],
> +		&r3[0],
> +		&r1[1],
>  	};
>  
>  	struct reftable_log_record *logs[] = { r1, r2, r3 };
> @@ -387,7 +387,7 @@ static void test_merged_logs(void)
>  
>  	EXPECT(ARRAY_SIZE(want) == len);
>  	for (i = 0; i < len; i++) {
> -		EXPECT(reftable_log_record_equal(&want[i], &out[i],
> +		EXPECT(reftable_log_record_equal(want[i], &out[i],
>  						 GIT_SHA1_RAWSZ));
>  	}
>  
>
> base-commit: 1ffcbaa1a5f10c9f706314d77f88de20a4a498c2
Previous: Han-Wen Nienhuys via GitGitGadgetNext: Han-Wen Nienhuys
Message 2 of 7 in “reftable: avoid initializing structs from structs”
  1. reftable: avoid initializing structs from structsHan-Wen Nienhuys via GitGitGadget, Jan 13, 2022
  2. Ævar Arnfjörð BjarmasonJan 13, 2022
  3. Han-Wen NienhuysJan 13, 2022
  4. Junio C HamanoJan 13, 2022
  5. Junio C HamanoJan 13, 2022
  6. Han-Wen NienhuysJan 17, 2022
  7. Junio C HamanoJan 17, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.