"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: use proper type for got_imsg_enumerated_commit
To:
gameoftrees@openbsd.org
Date:
Wed, 10 Jul 2024 18:25:56 +0200

Download raw body.

Thread
...and the same treatment for the closer got_imsg_enumerated_tree, ok?

commit 5be5c7ef58aa3bcce7a614ebfa33569829adc2bf (main)
from: Omar Polo <op@omarpolo.com>
date: Wed Jul 10 16:24:01 2024 UTC
 
 use proper type for got_imsg_enumerated_tree
 
diff 259994d85b8a255b5d9b1176870695cd5350bb19 5be5c7ef58aa3bcce7a614ebfa33569829adc2bf
commit - 259994d85b8a255b5d9b1176870695cd5350bb19
commit + 5be5c7ef58aa3bcce7a614ebfa33569829adc2bf
blob - 7511786325d8e67359b25d6e5a6983eaf0f84457
blob + b643ffc4d3b4304f1d21cd0eeb70e6170a63554e
--- lib/got_lib_privsep.h
+++ lib/got_lib_privsep.h
@@ -598,7 +598,7 @@ struct got_imsg_enumerated_commit {
 
 /* Structure for GOT_IMSG_ENUMERATED_TREE */
 struct got_imsg_enumerated_tree {
-	uint8_t id[SHA1_DIGEST_LENGTH]; /* tree ID */
+	struct got_object_id id;	/* tree ID */
 	int nentries;			/* number of tree entries */
 
 	/* Followed by tree's path in remaining data of imsg buffer. */
blob - e51908c9bc07441fc896089ee1c96ad436e9c94a
blob + 7e62208eb4b4a54c4cea9971137def3815fabedf
--- lib/privsep.c
+++ lib/privsep.c
@@ -2766,7 +2766,7 @@ got_privsep_send_enumerated_tree(size_t *totlen, struc
 	if (wbuf == NULL)
 		return got_error_from_errno("imsg_create ENUMERATED_TREE");
 
-	if (imsg_add(wbuf, tree_id->sha1, SHA1_DIGEST_LENGTH) == -1)
+	if (imsg_add(wbuf, tree_id, sizeof(*tree_id)) == -1)
 		return got_error_from_errno("imsg_add ENUMERATED_TREE");
 	if (imsg_add(wbuf, &nentries, sizeof(nentries)) == -1)
 		return got_error_from_errno("imsg_add ENUMERATED_TREE");
@@ -2900,7 +2900,7 @@ got_privsep_recv_enumerated_objects(int *found_all_obj
 				err = got_error(GOT_ERR_PRIVSEP_LEN);
 				break;
 			}
-			memcpy(tree_id.sha1, itree->id, sizeof(tree_id.sha1));
+			memcpy(&tree_id, &itree->id, sizeof(tree_id));
 			free(path);
 			path = strndup(imsg.data + sizeof(*itree), path_len);
 			if (path == NULL) {