From 77f29fa0214db3d9e4f2c8311a2ccd419a2725d4 Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Fri, 9 Mar 2018 16:18:40 -0800 Subject: [PATCH] scoutfs: allow null val in scoutfs_item_lookup Some callers may want to just test if an item is present and not necessarily want to setup storage for copying the value in. Signed-off-by: Zach Brown --- kmod/src/item.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kmod/src/item.c b/kmod/src/item.c index a5714e2d..9ea9727d 100644 --- a/kmod/src/item.c +++ b/kmod/src/item.c @@ -764,7 +764,7 @@ static bool lock_coverage(struct scoutfs_lock *lock, /* * Find an item with the given key and copy its value into the caller's * value vector. The amount of bytes copied is returned which can be 0 - * or truncated if the caller's buffer isn't big enough. + * or truncated if the caller's buffer isn't big enough or if val is null. * * The end key limits how many keys after the search key can be read * and inserted into the cache. @@ -789,7 +789,10 @@ int scoutfs_item_lookup(struct super_block *sb, struct scoutfs_key_buf *key, item = find_item(sb, &cac->items, key); if (item) { item_referenced(cac, item); - ret = scoutfs_kvec_memcpy(val, item->val); + if (val) + ret = scoutfs_kvec_memcpy(val, item->val); + else + ret = 0; } else if (check_range(sb, &cac->ranges, key, NULL)) { ret = -ENOENT; } else {