Thread (1 message) 1 message, 1 author, 2023-06-23

Re: [PATCH v3 10/12] config.c: remove config_reader from configsets

From: Junio C Hamano <hidden>
Date: 2023-06-23 21:33:11

Jonathan Tan [off-list ref] writes:
"Glen Choo via GitGitGadget" [off-list ref] writes:
quoted
@@ -2429,11 +2427,7 @@ static int configset_add_value(const struct key_value_info *kvi_p,
 	l_item->e = e;
 	l_item->value_index = e->value_list.nr - 1;
 
-	if (reader->source->name) {
-		kvi_from_source(reader->source, kvi_p->scope, kv_info);
-	} else {
-		kvi_from_param(kv_info);
-	}
+	memcpy(kv_info, kvi_p, sizeof(struct key_value_info));
 	si->util = kv_info;
 
 	return 0;
Ah, I remember seeing this memcpy from the previous round, but forgot to
comment on it (I only commented on another instance, [1]).
Yeah, I noticed this and recalled seeing a comment on structure
assignment.  As both are pointers,

    *kv_info = *kvi_p;

would sufficiently stand out to notify us that we are doing a
not-trivial assignment here, and would avoid (slight) risks of typos
by type checking.
Other than that, up to here looks good.

[1] https://lore.kernel.org/git/20230601233550.429921-1-jonathantanmy@google.com/ (local)
 
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help