svn commit: r298661 - in head: share/man/man9 sys/compat/linux sys/kern sys/sys

Conrad E. Meyer cem at FreeBSD.org
Tue Apr 26 19:57:38 UTC 2016


Author: cem
Date: Tue Apr 26 19:57:35 2016
New Revision: 298661
URL: https://svnweb.freebsd.org/changeset/base/298661

Log:
  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

Modified:
  head/share/man/man9/osd.9
  head/sys/compat/linux/linux_mib.c
  head/sys/kern/kern_osd.c
  head/sys/kern/sysv_msg.c
  head/sys/kern/sysv_sem.c
  head/sys/kern/sysv_shm.c
  head/sys/sys/osd.h

Modified: head/share/man/man9/osd.9
==============================================================================
--- head/share/man/man9/osd.9	Tue Apr 26 19:21:35 2016	(r298660)
+++ head/share/man/man9/osd.9	Tue Apr 26 19:57:35 2016	(r298661)
@@ -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 kern
 .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 appropr
 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

Modified: head/sys/compat/linux/linux_mib.c
==============================================================================
--- head/sys/compat/linux/linux_mib.c	Tue Apr 26 19:21:35 2016	(r298660)
+++ head/sys/compat/linux/linux_mib.c	Tue Apr 26 19:57:35 2016	(r298661)
@@ -192,7 +192,7 @@ linux_alloc_prison(struct prison *pr, st
 {
 	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);

Modified: head/sys/kern/kern_osd.c
==============================================================================
--- head/sys/kern/kern_osd.c	Tue Apr 26 19:21:35 2016	(r298660)
+++ head/sys/kern/kern_osd.c	Tue Apr 26 19:57:35 2016	(r298661)
@@ -202,7 +202,7 @@ osd_set(u_int type, struct osd *osd, u_i
 	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 
 
 	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 
 }
 
 void
-osd_free_reserved(void *rsv)
+osd_free_reserved(void **rsv)
 {
 
 	OSD_DEBUG("Discarding reserved slot array.");

Modified: head/sys/kern/sysv_msg.c
==============================================================================
--- head/sys/kern/sysv_msg.c	Tue Apr 26 19:21:35 2016	(r298660)
+++ head/sys/kern/sysv_msg.c	Tue Apr 26 19:57:35 2016	(r298661)
@@ -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,

Modified: head/sys/kern/sysv_sem.c
==============================================================================
--- head/sys/kern/sysv_sem.c	Tue Apr 26 19:21:35 2016	(r298660)
+++ head/sys/kern/sysv_sem.c	Tue Apr 26 19:57:35 2016	(r298661)
@@ -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,

Modified: head/sys/kern/sysv_shm.c
==============================================================================
--- head/sys/kern/sysv_shm.c	Tue Apr 26 19:21:35 2016	(r298660)
+++ head/sys/kern/sysv_shm.c	Tue Apr 26 19:57:35 2016	(r298661)
@@ -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,

Modified: head/sys/sys/osd.h
==============================================================================
--- head/sys/sys/osd.h	Tue Apr 26 19:21:35 2016	(r298660)
+++ head/sys/sys/osd.h	Tue Apr 26 19:57:35 2016	(r298661)
@@ -59,10 +59,10 @@ int osd_register(u_int type, osd_destruc
 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);


More information about the svn-src-head mailing list