osd(9): Change array pointer to array pointer type from void*

This is a minor follow-up to r297422, prompted by a Coverity warning.  (It's
not a real defect, just a code smell.)  OSD slot array reservations are an
array of pointers (void **) but were cast to void* and back unnecessarily.
Keep the correct type from reservation to use.

osd.9 is updated to match, along with a few trivial igor fixes.

Reported by:	Coverity
CID:		1353811
Sponsored by:	EMC / Isilon Storage Division
This commit is contained in:
Conrad Meyer 2016-04-26 19:57:35 +00:00
parent 605e9d2105
commit aa90aec270
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=298661
7 changed files with 20 additions and 19 deletions

View File

@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
.Dd March 30, 2016
.Dd April 26, 2016
.Dt OSD 9
.Os
.Sh NAME
@ -65,7 +65,7 @@
.Fa "u_int slot"
.Fa "void *value"
.Fc
.Ft void *
.Ft void **
.Fo osd_reserve
.Fa "u_int slot"
.Fc
@ -74,12 +74,12 @@
.Fa "u_int type"
.Fa "struct osd *osd"
.Fa "u_int slot"
.Fa "void *rsv"
.Fa "void **rsv"
.Fa "void *value"
.Fc
.Ft void
.Fo osd_free_reserved
.Fa "void *rsv"
.Fa "void **rsv"
.Fc
.Ft void *
.Fo osd_get
@ -314,8 +314,8 @@ the external data associated with a kernel data structure's
.Vt struct osd
member.
The type identifier is used as the index into the outer array, and the slot
identifier is used as the index into the inner array. To set or retrieve a data
pointer for a given type/slot identifier pair,
identifier is used as the index into the inner array.
To set or retrieve a data pointer for a given type/slot identifier pair,
.Fn osd_set
and
.Fn osd_get
@ -341,7 +341,7 @@ is used to grow the array to the appropriate size such that the slot identifier
can be used.
To maximise the efficiency of any code which calls
.Fn osd_set
sequentially on a number of different slot identifiers (e.g. during an
sequentially on a number of different slot identifiers (e.g., during an
initialisation phase) one should loop through the slot identifiers in descending
order from highest to lowest.
This will result in only a single
@ -354,7 +354,8 @@ calls.
.Pp
It is possible for
.Fn osd_set
to fail to allocate this array. To ensure that such allocation succeeds,
to fail to allocate this array.
To ensure that such allocation succeeds,
.Fn osd_reserve
may be called (in a non-blocking context), and it will pre-allocate the
memory via

View File

@ -192,7 +192,7 @@ linux_alloc_prison(struct prison *pr, struct linux_prison **lprp)
{
struct prison *ppr;
struct linux_prison *lpr, *nlpr;
void *rsv;
void **rsv;
/* If this prison already has Linux info, return that. */
lpr = linux_find_prison(pr, &ppr);

View File

@ -202,7 +202,7 @@ osd_set(u_int type, struct osd *osd, u_int slot, void *value)
return (osd_set_reserved(type, osd, slot, NULL, value));
}
void *
void **
osd_reserve(u_int slot)
{
@ -213,7 +213,7 @@ osd_reserve(u_int slot)
}
int
osd_set_reserved(u_int type, struct osd *osd, u_int slot, void *rsv,
osd_set_reserved(u_int type, struct osd *osd, u_int slot, void **rsv,
void *value)
{
struct rm_priotracker tracker;
@ -224,7 +224,7 @@ osd_set_reserved(u_int type, struct osd *osd, u_int slot, void *rsv,
rm_rlock(&osdm[type].osd_object_lock, &tracker);
if (slot > osd->osd_nslots) {
void *newptr;
void **newptr;
if (value == NULL) {
OSD_DEBUG(
@ -283,7 +283,7 @@ osd_set_reserved(u_int type, struct osd *osd, u_int slot, void *rsv,
}
void
osd_free_reserved(void *rsv)
osd_free_reserved(void **rsv)
{
OSD_DEBUG("Discarding reserved slot array.");

View File

@ -206,7 +206,7 @@ static int
msginit()
{
struct prison *pr;
void *rsv;
void **rsv;
int i, error;
osd_method_t methods[PR_MAXMETHOD] = {
[PR_METHOD_CHECK] = msg_prison_check,

View File

@ -260,7 +260,7 @@ static int
seminit(void)
{
struct prison *pr;
void *rsv;
void **rsv;
int i, error;
osd_method_t methods[PR_MAXMETHOD] = {
[PR_METHOD_CHECK] = sem_prison_check,

View File

@ -900,7 +900,7 @@ static int
shminit(void)
{
struct prison *pr;
void *rsv;
void **rsv;
int i, error;
osd_method_t methods[PR_MAXMETHOD] = {
[PR_METHOD_CHECK] = shm_prison_check,

View File

@ -59,10 +59,10 @@ int osd_register(u_int type, osd_destructor_t destructor,
void osd_deregister(u_int type, u_int slot);
int osd_set(u_int type, struct osd *osd, u_int slot, void *value);
void *osd_reserve(u_int slot);
int osd_set_reserved(u_int type, struct osd *osd, u_int slot, void *rsv,
void **osd_reserve(u_int slot);
int osd_set_reserved(u_int type, struct osd *osd, u_int slot, void **rsv,
void *value);
void osd_free_reserved(void *rsv);
void osd_free_reserved(void **rsv);
void *osd_get(u_int type, struct osd *osd, u_int slot);
void osd_del(u_int type, struct osd *osd, u_int slot);
int osd_call(u_int type, u_int method, void *obj, void *data);