svn commit: r323853 - head/sys/contrib/libnv
Mariusz Zaborski
oshogbo at FreeBSD.org
Thu Sep 21 10:06:01 UTC 2017
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);
}
More information about the svn-src-all
mailing list