| 392 | } |
| 393 | |
| 394 | nvlist_t * |
| 395 | nvlist_clone(const nvlist_t *nvl) |
| 396 | { |
| 397 | nvlist_t *newnvl; |
| 398 | nvpair_t *nvp, *newnvp; |
| 399 | |
| 400 | NVLIST_ASSERT(nvl); |
| 401 | |
| 402 | if (nvl->nvl_error != 0) { |
| 403 | ERRNO_SET(nvl->nvl_error); |
| 404 | return (NULL); |
| 405 | } |
| 406 | |
| 407 | newnvl = nvlist_create(nvl->nvl_flags & NV_FLAG_PUBLIC_MASK); |
| 408 | for (nvp = nvlist_first_nvpair(nvl); nvp != NULL; |
| 409 | nvp = nvlist_next_nvpair(nvl, nvp)) { |
| 410 | newnvp = nvpair_clone(nvp); |
| 411 | if (newnvp == NULL) |
| 412 | break; |
| 413 | (void)nvlist_move_nvpair(newnvl, newnvp); |
| 414 | } |
| 415 | if (nvp != NULL) { |
| 416 | nvlist_destroy(newnvl); |
| 417 | return (NULL); |
| 418 | } |
| 419 | return (newnvl); |
| 420 | } |
| 421 | |
| 422 | #ifndef _KERNEL |
| 423 | static bool |
no test coverage detected