From owner-svn-src-head@freebsd.org Thu Sep 21 10:18:03 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3BDEFE223AC; Thu, 21 Sep 2017 10:18:03 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0B30872E69; Thu, 21 Sep 2017 10:18:02 +0000 (UTC) (envelope-from oshogbo@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v8LAI2A3073155; Thu, 21 Sep 2017 10:18:02 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v8LAI2Yp073154; Thu, 21 Sep 2017 10:18:02 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201709211018.v8LAI2Yp073154@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: oshogbo set sender to oshogbo@FreeBSD.org using -f From: Mariusz Zaborski Date: Thu, 21 Sep 2017 10:18:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323859 - head/sys/contrib/libnv X-SVN-Group: head X-SVN-Commit-Author: oshogbo X-SVN-Commit-Paths: head/sys/contrib/libnv X-SVN-Commit-Revision: 323859 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Sep 2017 10:18:03 -0000 Author: oshogbo Date: Thu Sep 21 10:18:02 2017 New Revision: 323859 URL: https://svnweb.freebsd.org/changeset/base/323859 Log: Simplify the code by _not_ expecting success under 'fail'. Submitted by: pjd@ and oshogbo@ MFC after: 1 month Sponsored by: Wheel Systems Modified: head/sys/contrib/libnv/nvpair.c Modified: head/sys/contrib/libnv/nvpair.c ============================================================================== --- head/sys/contrib/libnv/nvpair.c Thu Sep 21 10:16:44 2017 (r323858) +++ head/sys/contrib/libnv/nvpair.c Thu Sep 21 10:18:02 2017 (r323859) @@ -1748,7 +1748,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); @@ -1763,19 +1762,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