svn commit: r324829 - stable/11/sys/contrib/libnv
Mariusz Zaborski
oshogbo at FreeBSD.org
Sat Oct 21 19:32:01 UTC 2017
Author: oshogbo
Date: Sat Oct 21 19:31:59 2017
New Revision: 324829
URL: https://svnweb.freebsd.org/changeset/base/324829
Log:
MFC r323853:
Make the code consistent by always using 'fail' label.
Submitted by: pjd@ and oshogbo@
Sponsored by: Wheel Systems
Modified:
stable/11/sys/contrib/libnv/nvlist.c
stable/11/sys/contrib/libnv/nvpair.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/contrib/libnv/nvlist.c
==============================================================================
--- stable/11/sys/contrib/libnv/nvlist.c Sat Oct 21 19:30:33 2017 (r324828)
+++ stable/11/sys/contrib/libnv/nvlist.c Sat Oct 21 19:31:59 2017 (r324829)
@@ -1071,24 +1071,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;
@@ -1099,7 +1099,7 @@ nvlist_unpack_header(nvlist_t *nvl, const unsigned cha
*leftp -= sizeof(nvlhdr);
return (ptr);
-failed:
+fail:
ERRNO_SET(EINVAL);
return (NULL);
}
@@ -1122,20 +1122,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);
@@ -1153,7 +1153,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
@@ -1171,14 +1171,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 *,
@@ -1186,7 +1186,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;
@@ -1203,7 +1203,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 {
@@ -1218,9 +1218,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;
@@ -1228,7 +1228,7 @@ nvlist_xunpack(const void *buf, size_t size, const int
}
return (retnvl);
-failed:
+fail:
nvlist_destroy(retnvl);
return (NULL);
}
Modified: stable/11/sys/contrib/libnv/nvpair.c
==============================================================================
--- stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:30:33 2017 (r324828)
+++ stable/11/sys/contrib/libnv/nvpair.c Sat Oct 21 19:31:59 2017 (r324829)
@@ -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);
}
More information about the svn-src-stable-11
mailing list