Date: Sat, 21 Oct 2017 19:26:47 +0000 (UTC) From: Mariusz Zaborski <oshogbo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r324827 - stable/11/sys/contrib/libnv Message-ID: <201710211926.v9LJQls7015195@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: oshogbo Date: Sat Oct 21 19:26:47 2017 New Revision: 324827 URL: https://svnweb.freebsd.org/changeset/base/324827 Log: MFC r323859: Simplify the code by _not_ expecting success under 'fail'. Submitted by: pjd@ and oshogbo@ MFC after: 1 month Sponsored by: Wheel Systems Modified: stable/11/sys/contrib/libnv/nvpair.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/contrib/libnv/nvpair.c ============================================================================== --- stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:14:45 2017 (r324826) +++ stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:26:47 2017 (r324827) @@ -1740,7 +1740,6 @@ nvpair_move_descriptor_array(const char *name, int *va nvpair_t *nvp; size_t i; - nvp = NULL; if (value == NULL || nitems == 0) { ERRNO_SET(EINVAL); return (NULL); @@ -1755,19 +1754,20 @@ nvpair_move_descriptor_array(const char *name, int *va nvp = nvpair_allocv(name, NV_TYPE_DESCRIPTOR_ARRAY, (uint64_t)(uintptr_t)value, sizeof(value[0]) * nitems, nitems); + if (nvp == NULL) + goto fail; + return (nvp); fail: - if (nvp == NULL) { - ERRNO_SAVE(); - for (i = 0; i < nitems; i++) { - if (fd_is_valid(value[i])) - close(value[i]); - } - nv_free(value); - ERRNO_RESTORE(); + ERRNO_SAVE(); + for (i = 0; i < nitems; i++) { + if (fd_is_valid(value[i])) + close(value[i]); } + nv_free(value); + ERRNO_RESTORE(); - return (nvp); + return (NULL); } #endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710211926.v9LJQls7015195>