Page MenuHomeFreeBSD

Fix build of ndis with base gcc on i386
ClosedPublic

Authored by dim on Jun 10 2018, 8:29 PM.
Tags
None
Referenced Files
F166757751: D15746.diff
Sun, Aug 16, 6:16 AM
F166745848: D15746.id43963.diff
Sun, Aug 16, 2:42 AM
Unknown Object (File)
Fri, Aug 14, 8:01 PM
Unknown Object (File)
Thu, Aug 13, 9:05 PM
Unknown Object (File)
Thu, Aug 13, 12:08 PM
Unknown Object (File)
Wed, Aug 12, 1:59 PM
Unknown Object (File)
Wed, Aug 12, 1:58 PM
Unknown Object (File)
Wed, Aug 12, 1:57 PM
Subscribers

Details

Summary

Base gcc fails to compile sys/compat/ndis/subr_ndis.c for i386, with
the following -Werror warnings:

cc1: warnings being treated as errors
/usr/src/sys/compat/ndis/subr_ndis.c: In function 'NdisMRegisterIoPortRange':
/usr/src/sys/compat/ndis/subr_ndis.c:1288: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

This is because on i386, the casts from rman_res_t (aka uintmax_t)
to a pointer reduces the value from 64 bit to 32 bit.

For gcc, this can be fixed by an intermediate cast to uintptr_t. Note
that I am assuming the incoming values will always fit into 32 bit!

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This is fine.
On x86, the resource I/O port is < 64k. the (void *) is to keep the compiler happy and is a bit of type-punning that the NDIS interface forces upon the user.

This revision is now accepted and ready to land.Jun 15 2018, 10:00 PM

ref: https://c9x.me/x86/html/file_module_x86_id_139.html
DX is used here, not EDX, for the I/O port giving a range of 0..65,535
Even though you can do 32-bit I/O to a port, the range of the ports is limited to 16-bits.

tl;dr: make it so and commit!

This revision was automatically updated to reflect the committed changes.