Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Mar 2011 06:31:00 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r220184 - head/sys/geom/nop
Message-ID:  <201103310631.p2V6V0ap093991@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Thu Mar 31 06:30:59 2011
New Revision: 220184
URL: http://svn.freebsd.org/changeset/base/220184

Log:
  Remove unneeded checks, g_new_xxx functions can not return NULL.
  
  Reviewed by:	pjd
  MFC after:	1 week

Modified:
  head/sys/geom/nop/g_nop.c

Modified: head/sys/geom/nop/g_nop.c
==============================================================================
--- head/sys/geom/nop/g_nop.c	Thu Mar 31 06:29:15 2011	(r220183)
+++ head/sys/geom/nop/g_nop.c	Thu Mar 31 06:30:59 2011	(r220184)
@@ -189,10 +189,6 @@ g_nop_create(struct gctl_req *req, struc
 		}
 	}
 	gp = g_new_geomf(mp, name);
-	if (gp == NULL) {
-		gctl_error(req, "Cannot create geom %s.", name);
-		return (ENOMEM);
-	}
 	sc = g_malloc(sizeof(*sc), M_WAITOK);
 	sc->sc_offset = offset;
 	sc->sc_error = ioerror;
@@ -209,20 +205,10 @@ g_nop_create(struct gctl_req *req, struc
 	gp->dumpconf = g_nop_dumpconf;
 
 	newpp = g_new_providerf(gp, gp->name);
-	if (newpp == NULL) {
-		gctl_error(req, "Cannot create provider %s.", name);
-		error = ENOMEM;
-		goto fail;
-	}
 	newpp->mediasize = size;
 	newpp->sectorsize = secsize;
 
 	cp = g_new_consumer(gp);
-	if (cp == NULL) {
-		gctl_error(req, "Cannot create consumer for %s.", gp->name);
-		error = ENOMEM;
-		goto fail;
-	}
 	error = g_attach(cp, pp);
 	if (error != 0) {
 		gctl_error(req, "Cannot attach to provider %s.", pp->name);
@@ -233,18 +219,12 @@ g_nop_create(struct gctl_req *req, struc
 	G_NOP_DEBUG(0, "Device %s created.", gp->name);
 	return (0);
 fail:
-	if (cp != NULL) {
-		if (cp->provider != NULL)
-			g_detach(cp);
-		g_destroy_consumer(cp);
-	}
-	if (newpp != NULL)
-		g_destroy_provider(newpp);
-	if (gp != NULL) {
-		if (gp->softc != NULL)
-			g_free(gp->softc);
-		g_destroy_geom(gp);
-	}
+	if (cp->provider != NULL)
+		g_detach(cp);
+	g_destroy_consumer(cp);
+	g_destroy_provider(newpp);
+	g_free(gp->softc);
+	g_destroy_geom(gp);
 	return (error);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103310631.p2V6V0ap093991>