Subject: Re: [PATCH 12/13] strvec: implement swapping two strvecs

From: Junio C Hamano <[email-masked]>
Date: Wed, 27 Mar 2024 14:22:17 -0700

Patrick Steinhardt <[email-masked]> writes:

>> +
>> +void strvec_swap(struct strvec *a, struct strvec *b)
>> +{
>> +	struct strvec t = *a;
>> +	*a = *b;
>> +	*b = t;
>> +}
>
> Isn't this equivalent to `SWAP(*a, *b)`?

Yes.  "make coccicheck" does flag this one.

Let's drop this step, and tweak the 13/13 patch to make its sole
caller directly use SWAP() instead, perhaps like so:

 credential.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git c/credential.c w/credential.c
index 9a08efe113..5ea52ddd68 100644
--- c/credential.c
+++ w/credential.c
@@ -39,7 +39,7 @@ void credential_clear(struct credential *c)
 void credential_next_state(struct credential *c)
 {
 	strvec_clear(&c->state_headers_to_send);
-	strvec_swap(&c->state_headers, &c->state_headers_to_send);
+	SWAP(c->state_headers, c->state_headers_to_send);
 }
 
 void credential_clear_secrets(struct credential *c)