svn commit: r323859 - head/sys/contrib/libnv

Mariusz Zaborski oshogbo at FreeBSD.org
Thu Sep 21 10:18:03 UTC 2017


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
 


More information about the svn-src-all mailing list