Functions:
- g_new_geomf(), - g_new_providerf(), - g_new_consumer() cannot failed (by returning NULL), so don't scare programmers.
This commit is contained in:
parent
7456822f82
commit
d1d0abbffa
@ -100,8 +100,6 @@ some_function(struct g_geom *mygeom, struct g_provider *pp)
|
||||
|
||||
/* Create new consumer on 'mygeom' geom. */
|
||||
cp = g_new_consumer(mygeom);
|
||||
if (cp == NULL)
|
||||
return;
|
||||
/* Attach newly created consumer to given provider. */
|
||||
if (g_attach(cp, pp) != 0) {
|
||||
g_destroy_consumer(cp);
|
||||
|
@ -93,8 +93,6 @@ some_function(struct g_geom *mygeom, struct g_provider *pp)
|
||||
|
||||
/* Create new consumer on 'mygeom' geom. */
|
||||
cp = g_new_consumer(mygeom);
|
||||
if (cp == NULL)
|
||||
return;
|
||||
/* Attach newly created consumer to given provider. */
|
||||
if (g_attach(cp, pp) != 0) {
|
||||
g_destroy_consumer(cp);
|
||||
|
@ -81,9 +81,7 @@ The topology lock has to be held.
|
||||
.El
|
||||
.Sh RETURN VALUES
|
||||
.Fn g_new_consumer
|
||||
returns a pointer to the newly created consumer or
|
||||
.Dv NULL
|
||||
if an error occured.
|
||||
returns a pointer to the newly created consumer.
|
||||
.Sh EXAMPLES
|
||||
Create consumer, attach it to given provider, gain read access and clean up.
|
||||
.Bd -literal -offset indent
|
||||
@ -96,8 +94,6 @@ some_function(struct g_geom *mygeom, struct g_provider *pp)
|
||||
|
||||
/* Create new consumer on 'mygeom' geom. */
|
||||
cp = g_new_consumer(mygeom);
|
||||
if (cp == NULL)
|
||||
return;
|
||||
/* Attach newly created consumer to given provider. */
|
||||
if (g_attach(cp, pp) != 0) {
|
||||
g_destroy_consumer(cp);
|
||||
|
@ -112,9 +112,7 @@ The topology lock has to be held.
|
||||
.El
|
||||
.Sh RETURN VALUES
|
||||
.Fn g_new_geomf
|
||||
returns a pointer to the newly created geom or
|
||||
.Dv NULL
|
||||
if an error occured.
|
||||
returns a pointer to the newly created geom.
|
||||
.Sh EXAMPLES
|
||||
Create an example geom.
|
||||
.Bd -literal -offset indent
|
||||
@ -158,13 +156,11 @@ create_example_geom(struct g_class *myclass)
|
||||
g_topology_lock();
|
||||
gp = g_new_geomf(myclass, "example_geom");
|
||||
g_topology_unlock();
|
||||
if (gp != NULL) {
|
||||
gp->start = g_example_start;
|
||||
gp->orphan = g_example_orphan;
|
||||
gp->spoiled = g_example_spoiled;
|
||||
gp->access = g_example_access;
|
||||
gp->softc = NULL;
|
||||
}
|
||||
gp->start = g_example_start;
|
||||
gp->orphan = g_example_orphan;
|
||||
gp->spoiled = g_example_spoiled;
|
||||
gp->access = g_example_access;
|
||||
gp->softc = NULL;
|
||||
|
||||
return (gp);
|
||||
}
|
||||
|
@ -104,9 +104,7 @@ The topology lock has to be held.
|
||||
.El
|
||||
.Sh RETURN VALUES
|
||||
.Fn g_new_providerf
|
||||
returns a pointer to the newly created provider or
|
||||
.Dv NULL
|
||||
if an error occured.
|
||||
returns a pointer to the newly created provider.
|
||||
.Sh EXAMPLES
|
||||
Create an example provider, set its parameters and make it usable.
|
||||
.Bd -literal -offset indent
|
||||
@ -117,12 +115,10 @@ create_example_provider(struct g_geom *gp)
|
||||
|
||||
g_topology_lock();
|
||||
pp = g_new_providerf(gp, "example_provider");
|
||||
pp->mediasize = 65536;
|
||||
pp->sectorsize = 512;
|
||||
g_error_provider(pp, 0);
|
||||
g_topology_unlock();
|
||||
if (pp != NULL) {
|
||||
pp->mediasize = 65536;
|
||||
pp->sectorsize = 512;
|
||||
g_error_provider(pp, 0);
|
||||
}
|
||||
|
||||
return (pp);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user