Remove unneeded checks, g_new_xxx functions can not return NULL.
Reviewed by: pjd MFC after: 1 week
This commit is contained in:
parent
c882f2145b
commit
fa6777f630
@ -189,10 +189,6 @@ g_nop_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
|
||||
}
|
||||
}
|
||||
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, struct g_class *mp, struct g_provider *pp,
|
||||
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, struct g_class *mp, struct g_provider *pp,
|
||||
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user