Page MenuHomeFreeBSD

Fix build of bxe with base gcc on i386
ClosedPublic

Authored by dim on Jun 10 2018, 8:17 AM.
Tags
None
Referenced Files
F155022751: D15733.id43590.diff
Thu, Apr 30, 6:13 PM
F154967084: D15733.diff
Thu, Apr 30, 9:05 AM
Unknown Object (File)
Mon, Apr 27, 9:08 PM
Unknown Object (File)
Mon, Apr 27, 7:08 AM
Unknown Object (File)
Mon, Apr 27, 3:18 AM
Unknown Object (File)
Tue, Apr 21, 8:49 AM
Unknown Object (File)
Sat, Apr 11, 8:07 PM
Unknown Object (File)
Thu, Apr 9, 6:19 PM
Subscribers

Details

Summary

Base gcc fails to compile sys/dev/bxe/bxe.c for i386, with the
following -Werror warnings:

cc1: warnings being treated as errors
/usr/src/sys/dev/bxe/bxe.c: In function 'bxe_allocate_bars':
/usr/src/sys/dev/bxe/bxe.c:12822: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/usr/src/sys/dev/bxe/bxe.c:12822: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/usr/src/sys/dev/bxe/bxe.c:12822: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
/usr/src/sys/dev/bxe/bxe.c:12822: 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, and similar for
the kva member of struct bxe_bar, which is a vm_offset_t (aka
uint32_t).

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 revision is now accepted and ready to land.Jun 10 2018, 2:07 PM

64bit BARs can have addresses and lengths bigger than 32bits, so I would rather cast to uint64_t and use PRIx64 in order to print them. Or cast to uintmax_t and print with PRIxMAX.

This revision was automatically updated to reflect the committed changes.