From 54b85919051bb6508b53ce98116608196573cfe7 Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Sat, 29 Mar 2025 01:08:16 +0000 Subject: move_descriptor should use nv_fd --- libnvxx/nv_list.cc | 6 ++++-- libnvxx/nvxx.3 | 2 +- libnvxx/nvxx_base.h | 2 +- libnvxx/tests/nvxx_iterator.cc | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libnvxx/nv_list.cc b/libnvxx/nv_list.cc index 780c9de..72fc937 100644 --- a/libnvxx/nv_list.cc +++ b/libnvxx/nv_list.cc @@ -735,11 +735,13 @@ __nv_list::add_descriptor(std::string_view key, int value) } void -__nv_list::move_descriptor(std::string_view key, int value) +__nv_list::move_descriptor(std::string_view key, nv_fd &&fd) { __throw_if_error(); - ::nvlist_move_descriptor(__m_nv, std::string(key).c_str(), value); + ::nvlist_move_descriptor(__m_nv, + std::string(key).c_str(), + std::move(fd).release()); } void diff --git a/libnvxx/nvxx.3 b/libnvxx/nvxx.3 index b252768..73e880f 100644 --- a/libnvxx/nvxx.3 +++ b/libnvxx/nvxx.3 @@ -144,7 +144,7 @@ struct nv_list : { void add_binary_range(std::string_view key, std::ranges::range auto &&); void move_string(std::string_view key, char *); - void move_descriptor(std::string_view key, int); + void move_descriptor(std::string_view key, nv_fd &&); void move_binary(std::string_view key, std::span); void move_nvlist(std::string_view key, nv_list &&); void move_nvlist(std::string_view key, ::nvlist_t *); diff --git a/libnvxx/nvxx_base.h b/libnvxx/nvxx_base.h index 126f944..0817f0a 100644 --- a/libnvxx/nvxx_base.h +++ b/libnvxx/nvxx_base.h @@ -268,7 +268,7 @@ struct __nv_list : virtual __nv_list_base { void move_string(std::string_view, char *); void move_nvlist(std::string_view, nv_list &&); void move_nvlist(std::string_view, ::nvlist_t *); - void move_descriptor(std::string_view, int); + void move_descriptor(std::string_view, nv_fd &&); void move_binary(std::string_view, std::span); void move_bool_array(std::string_view, std::span); diff --git a/libnvxx/tests/nvxx_iterator.cc b/libnvxx/tests/nvxx_iterator.cc index 07e9aa6..12511e9 100644 --- a/libnvxx/tests/nvxx_iterator.cc +++ b/libnvxx/tests/nvxx_iterator.cc @@ -52,7 +52,7 @@ TEST_CASE(nvxx_basic_iterate) nvl.add_string_range("a string array", string_array); auto fdesc = fds[0]; - nvl.move_descriptor("an fd", fdesc); + nvl.move_descriptor("an fd", bsd::nv_fd(fdesc)); nvl.add_descriptor_range("a descriptor array", fds2); -- cgit v1.2.3