From owner-svn-src-all@freebsd.org Thu Sep 21 10:06:01 2017 Return-Path: Delivered-To: svn-src-all@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 97E6BE21791; Thu, 21 Sep 2017 10:06:01 +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 72A607222A; Thu, 21 Sep 2017 10:06:01 +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 v8LA60aj068341; Thu, 21 Sep 2017 10:06:00 GMT (envelope-from oshogbo@FreeBSD.org) Received: (from oshogbo@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v8LA60B7068339; Thu, 21 Sep 2017 10:06:00 GMT (envelope-from oshogbo@FreeBSD.org) Message-Id: <201709211006.v8LA60B7068339@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:06:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323853 - 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: 323853 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Sep 2017 10:06:01 -0000 Author: oshogbo Date: Thu Sep 21 10:06:00 2017 New Revision: 323853 URL: https://svnweb.freebsd.org/changeset/base/323853 Log: Make the code consistent by always using 'fail' label. Submitted by: pjd@ and oshogbo@ MFC after: 1 month Sponsored by: Wheel Systems Modified: head/sys/contrib/libnv/nvlist.c head/sys/contrib/libnv/nvpair.c Modified: head/sys/contrib/libnv/nvlist.c ============================================================================== --- head/sys/contrib/libnv/nvlist.c Thu Sep 21 10:03:14 2017 (r323852) +++ head/sys/contrib/libnv/nvlist.c Thu Sep 21 10:06:00 2017 (r323853) @@ -1067,24 +1067,24 @@ nvlist_unpack_header(nvlist_t *nvl, const unsigned cha int inarrayf; if (*leftp < sizeof(nvlhdr)) - goto failed; + goto fail; memcpy(&nvlhdr, ptr, sizeof(nvlhdr)); if (!nvlist_check_header(&nvlhdr)) - goto failed; + goto fail; if (nvlhdr.nvlh_size != *leftp - sizeof(nvlhdr)) - goto failed; + goto fail; /* * nvlh_descriptors might be smaller than nfds in embedded nvlists. */ if (nvlhdr.nvlh_descriptors > nfds) - goto failed; + goto fail; if ((nvlhdr.nvlh_flags & ~NV_FLAG_ALL_MASK) != 0) - goto failed; + goto fail; inarrayf = (nvl->nvl_flags & NV_FLAG_IN_ARRAY); nvl->nvl_flags = (nvlhdr.nvlh_flags & NV_FLAG_PUBLIC_MASK) | inarrayf; @@ -1095,7 +1095,7 @@ nvlist_unpack_header(nvlist_t *nvl, const unsigned cha *leftp -= sizeof(nvlhdr); return (ptr); -failed: +fail: ERRNO_SET(EINVAL); return (NULL); } @@ -1118,20 +1118,20 @@ nvlist_xunpack(const void *buf, size_t size, const int tmpnvl = array = NULL; nvl = retnvl = nvlist_create(0); if (nvl == NULL) - goto failed; + goto fail; ptr = nvlist_unpack_header(nvl, ptr, nfds, &isbe, &left); if (ptr == NULL) - goto failed; + goto fail; if (nvl->nvl_flags != flags) { ERRNO_SET(EILSEQ); - goto failed; + goto fail; } while (left > 0) { ptr = nvpair_unpack(isbe, ptr, &left, &nvp); if (ptr == NULL) - goto failed; + goto fail; switch (nvpair_type(nvp)) { case NV_TYPE_NULL: ptr = nvpair_unpack_null(isbe, nvp, ptr, &left); @@ -1149,7 +1149,7 @@ nvlist_xunpack(const void *buf, size_t size, const int ptr = nvpair_unpack_nvlist(isbe, nvp, ptr, &left, nfds, &tmpnvl); if (tmpnvl == NULL || ptr == NULL) - goto failed; + goto fail; nvlist_set_parent(tmpnvl, nvp); break; #ifndef _KERNEL @@ -1167,14 +1167,14 @@ nvlist_xunpack(const void *buf, size_t size, const int break; case NV_TYPE_NVLIST_UP: if (nvl->nvl_parent == NULL) - goto failed; + goto fail; nvl = nvpair_nvlist(nvl->nvl_parent); nvpair_free_structure(nvp); continue; case NV_TYPE_NVLIST_ARRAY_NEXT: if (nvl->nvl_array_next == NULL) { if (nvl->nvl_parent == NULL) - goto failed; + goto fail; nvl = nvpair_nvlist(nvl->nvl_parent); } else { nvl = __DECONST(nvlist_t *, @@ -1182,7 +1182,7 @@ nvlist_xunpack(const void *buf, size_t size, const int ptr = nvlist_unpack_header(nvl, ptr, nfds, &isbe, &left); if (ptr == NULL) - goto failed; + goto fail; } nvpair_free_structure(nvp); continue; @@ -1199,7 +1199,7 @@ nvlist_xunpack(const void *buf, size_t size, const int ptr = nvpair_unpack_nvlist_array(isbe, nvp, ptr, &left, &array); if (ptr == NULL) - goto failed; + goto fail; PJDLOG_ASSERT(array != NULL); tmpnvl = array; do { @@ -1214,9 +1214,9 @@ nvlist_xunpack(const void *buf, size_t size, const int PJDLOG_ABORT("Invalid type (%d).", nvpair_type(nvp)); } if (ptr == NULL) - goto failed; + goto fail; if (!nvlist_move_nvpair(nvl, nvp)) - goto failed; + goto fail; if (tmpnvl != NULL) { nvl = tmpnvl; tmpnvl = NULL; @@ -1224,7 +1224,7 @@ nvlist_xunpack(const void *buf, size_t size, const int } return (retnvl); -failed: +fail: nvlist_destroy(retnvl); return (NULL); } Modified: head/sys/contrib/libnv/nvpair.c ============================================================================== --- head/sys/contrib/libnv/nvpair.c Thu Sep 21 10:03:14 2017 (r323852) +++ head/sys/contrib/libnv/nvpair.c Thu Sep 21 10:06:00 2017 (r323853) @@ -614,7 +614,7 @@ nvpair_unpack_header(bool isbe, nvpair_t *nvp, const u struct nvpair_header nvphdr; if (*leftp < sizeof(nvphdr)) - goto failed; + goto fail; memcpy(&nvphdr, ptr, sizeof(nvphdr)); ptr += sizeof(nvphdr); @@ -622,12 +622,12 @@ nvpair_unpack_header(bool isbe, nvpair_t *nvp, const u #if NV_TYPE_FIRST > 0 if (nvphdr.nvph_type < NV_TYPE_FIRST) - goto failed; + goto fail; #endif if (nvphdr.nvph_type > NV_TYPE_LAST && nvphdr.nvph_type != NV_TYPE_NVLIST_UP && nvphdr.nvph_type != NV_TYPE_NVLIST_ARRAY_NEXT) { - goto failed; + goto fail; } #if BYTE_ORDER == BIG_ENDIAN @@ -643,14 +643,14 @@ nvpair_unpack_header(bool isbe, nvpair_t *nvp, const u #endif if (nvphdr.nvph_namesize > NV_NAME_MAX) - goto failed; + goto fail; if (*leftp < nvphdr.nvph_namesize) - goto failed; + goto fail; if (nvphdr.nvph_namesize < 1) - goto failed; + goto fail; if (strnlen((const char *)ptr, nvphdr.nvph_namesize) != (size_t)(nvphdr.nvph_namesize - 1)) { - goto failed; + goto fail; } memcpy(nvp->nvp_name, ptr, nvphdr.nvph_namesize); @@ -658,7 +658,7 @@ nvpair_unpack_header(bool isbe, nvpair_t *nvp, const u *leftp -= nvphdr.nvph_namesize; if (*leftp < nvphdr.nvph_datasize) - goto failed; + goto fail; nvp->nvp_type = nvphdr.nvph_type; nvp->nvp_data = 0; @@ -666,7 +666,7 @@ nvpair_unpack_header(bool isbe, nvpair_t *nvp, const u nvp->nvp_nitems = nvphdr.nvph_nitems; return (ptr); -failed: +fail: ERRNO_SET(EINVAL); return (NULL); } @@ -1108,10 +1108,10 @@ nvpair_unpack(bool isbe, const unsigned char *ptr, siz ptr = nvpair_unpack_header(isbe, nvp, ptr, leftp); if (ptr == NULL) - goto failed; + goto fail; tmp = nv_realloc(nvp, sizeof(*nvp) + strlen(nvp->nvp_name) + 1); if (tmp == NULL) - goto failed; + goto fail; nvp = tmp; /* Update nvp_name after realloc(). */ @@ -1120,7 +1120,7 @@ nvpair_unpack(bool isbe, const unsigned char *ptr, siz nvp->nvp_magic = NVPAIR_MAGIC; *nvpp = nvp; return (ptr); -failed: +fail: nv_free(nvp); return (NULL); }