[PATCH 2/5] zfs: Add a comment to clarify nvlist memory layout

mwleeds at mailtundra.com mwleeds at mailtundra.com
Sun Apr 7 03:47:26 CEST 2024


Signed-off-by: Phaedrus Leeds <mwleeds at mailtundra.com>
Tested-by: Phaedrus Leeds <mwleeds at mailtundra.com>
---
 fs/zfs/zfs.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/zfs/zfs.c b/fs/zfs/zfs.c
index 14779dee32..61d58fce68 100644
--- a/fs/zfs/zfs.c
+++ b/fs/zfs/zfs.c
@@ -1610,20 +1610,25 @@ zfs_nvlist_lookup_nvlist(char *nvlist, char *name)
 {
 	char *nvpair;
 	char *ret;
 	size_t size;
 	int found;
 
 	found = nvlist_find_value(nvlist, name, DATA_TYPE_NVLIST, &nvpair,
 							  &size, 0);
 	if (!found)
 		return 0;
+
+	/* Allocate 12 bytes in addition to the nvlist size: One uint32 before the
+	 * nvlist to hold the encoding method, and two zero uint32's after the
+	 * nvlist as the NULL terminator.
+	 */
 	ret = calloc(1, size + 3 * sizeof(uint32_t));
 	if (!ret)
 		return 0;
 	memcpy(ret, nvlist, sizeof(uint32_t));
 
 	memcpy(ret + sizeof(uint32_t), nvpair, size);
 	return ret;
 }
 
 int
-- 
2.44.0



More information about the U-Boot mailing list