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.
This commit is contained in:
parent
5ae5e472e2
commit
f6f6004c29
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=13805
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user