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
Unknown Object (File)
Thu, Mar 21, 5:18 PM
Unknown Object (File)
Feb 22 2024, 8:41 AM
Unknown Object (File)
Jan 4 2024, 6:34 PM
Unknown Object (File)
Dec 19 2023, 2:51 AM
Unknown Object (File)
Nov 16 2023, 1:17 AM
Unknown Object (File)
Oct 25 2023, 1:17 AM
Unknown Object (File)
Oct 18 2023, 1:14 AM
Unknown Object (File)
Sep 22 2023, 3:52 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.