diff options
author | gibbs <gibbs@FreeBSD.org> | 1996-01-31 18:05:19 +0000 |
---|---|---|
committer | gibbs <gibbs@FreeBSD.org> | 1996-01-31 18:05:19 +0000 |
commit | 7117d2e0cf16a0c2fd3222367e3a6591cd388493 (patch) | |
tree | a43eb13a5aa08fcc0e64c13dd5e06059ba6ca1b9 | |
parent | c1d13430cfd29fcef939277cf8365873e4ef6035 (diff) | |
download | FreeBSD-src-7117d2e0cf16a0c2fd3222367e3a6591cd388493.zip FreeBSD-src-7117d2e0cf16a0c2fd3222367e3a6591cd388493.tar.gz |
Properly calculate the amount of the devconf to output in SYSCTL_OUT.
The code outputs the dc then calls the device specific externalize
routines to fill in the dc_data area. The old code assumed that dc_data
started one byte from the end of the dc, but with the compiler optimizing
alignment and padding, this isn't always the case. Do an explicit
&(dc.dc_data) - &dc. This fixes lsdev -c which must have been broken
for some time.
-rw-r--r-- | sys/kern/kern_devconf.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/kern/kern_devconf.c b/sys/kern/kern_devconf.c index 33becac..c9c8ba5 100644 --- a/sys/kern/kern_devconf.c +++ b/sys/kern/kern_devconf.c @@ -22,7 +22,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: kern_devconf.c,v 1.12 1995/12/06 23:37:06 bde Exp $ + * $Id: kern_devconf.c,v 1.13 1995/12/14 08:31:17 phk Exp $ */ /* @@ -151,7 +151,15 @@ sysctl_hw_devconfig SYSCTL_HANDLER_ARGS make_devconf(kdc, &dc); - rv = SYSCTL_OUT(req, &dc, (sizeof dc) -1); + /* + * Let the device specific externalization routines + * handle the variable length data at the end of the + * dc. Since the compiler may optimize alignment and + * perform padding, we must do the subtraction to + * determine the proper length. (dc_datalen includes the + * externalized data so it can't be used) + */ + rv = SYSCTL_OUT(req, &dc, (void *)&dc.dc_data - (void *)&dc); if(rv) return rv; |