From f6f6004c292501eb91df20db08017496591b5f10 Mon Sep 17 00:00:00 2001 From: "Justin T. Gibbs" Date: Wed, 31 Jan 1996 18:05:19 +0000 Subject: [PATCH] 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. --- sys/kern/kern_devconf.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sys/kern/kern_devconf.c b/sys/kern/kern_devconf.c index 33becac9a3e0..c9c8ba5bff25 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;