summaryrefslogtreecommitdiffstats
path: root/sys/geom/cache
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2011-05-04 17:37:37 +0000
committerae <ae@FreeBSD.org>2011-05-04 17:37:37 +0000
commitf7ea6f62c3bd831f54d0c23223ca22e242f27867 (patch)
tree2a09965ca8c998fdcb0c14443a65aaf09dd4192b /sys/geom/cache
parent71e07486c49fffc33a8ef516cc52f9e50ca99cf4 (diff)
downloadFreeBSD-src-f7ea6f62c3bd831f54d0c23223ca22e242f27867.zip
FreeBSD-src-f7ea6f62c3bd831f54d0c23223ca22e242f27867.tar.gz
Remove unneeded checks, g_new_xxx functions can not fail.
MFC after: 1 week
Diffstat (limited to 'sys/geom/cache')
-rw-r--r--sys/geom/cache/g_cache.c37
1 files changed, 6 insertions, 31 deletions
diff --git a/sys/geom/cache/g_cache.c b/sys/geom/cache/g_cache.c
index 01c7873..ca05f14 100644
--- a/sys/geom/cache/g_cache.c
+++ b/sys/geom/cache/g_cache.c
@@ -501,12 +501,6 @@ g_cache_create(struct g_class *mp, struct g_provider *pp,
}
gp = g_new_geomf(mp, md->md_name);
- if (gp == NULL) {
- G_CACHE_DEBUG(0, "Cannot create geom %s.", md->md_name);
- return (NULL);
- }
- gp->softc = NULL; /* for a moment */
-
sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
sc->sc_type = type;
sc->sc_bshift = bshift;
@@ -527,10 +521,6 @@ g_cache_create(struct g_class *mp, struct g_provider *pp,
gp->dumpconf = g_cache_dumpconf;
newpp = g_new_providerf(gp, "cache/%s", gp->name);
- if (newpp == NULL) {
- G_CACHE_DEBUG(0, "Cannot create provider cache/%s.", gp->name);
- goto fail;
- }
newpp->sectorsize = pp->sectorsize;
newpp->mediasize = pp->mediasize;
if (type == G_CACHE_TYPE_AUTOMATIC)
@@ -538,35 +528,20 @@ g_cache_create(struct g_class *mp, struct g_provider *pp,
sc->sc_tail = BNO2OFF(OFF2BNO(newpp->mediasize, sc), sc);
cp = g_new_consumer(gp);
- if (cp == NULL) {
- G_CACHE_DEBUG(0, "Cannot create consumer for %s.", gp->name);
- goto fail;
- }
if (g_attach(cp, pp) != 0) {
G_CACHE_DEBUG(0, "Cannot attach to provider %s.", pp->name);
- goto fail;
+ g_destroy_consumer(cp);
+ g_destroy_provider(newpp);
+ mtx_destroy(&sc->sc_mtx);
+ g_free(sc);
+ g_destroy_geom(gp);
+ return (NULL);
}
g_error_provider(newpp, 0);
G_CACHE_DEBUG(0, "Device %s created.", gp->name);
callout_reset(&sc->sc_callout, g_cache_timeout * hz, g_cache_go, sc);
return (gp);
-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) {
- mtx_destroy(&sc->sc_mtx);
- g_free(gp->softc);
- }
- g_destroy_geom(gp);
- }
- return (NULL);
}
static int
OpenPOWER on IntegriCloud