From owner-svn-src-all@freebsd.org Tue Apr 26 19:57:38 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F2F21B19DCA; Tue, 26 Apr 2016 19:57:37 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A7BE61668; Tue, 26 Apr 2016 19:57:37 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u3QJvaEW025522; Tue, 26 Apr 2016 19:57:36 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u3QJvZAh025514; Tue, 26 Apr 2016 19:57:35 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201604261957.u3QJvZAh025514@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: "Conrad E. Meyer" Date: Tue, 26 Apr 2016 19:57:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298661 - in head: share/man/man9 sys/compat/linux sys/kern sys/sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Apr 2016 19:57:38 -0000 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);