Page MenuHomeFreeBSD

Constify a number of accesses in drm2 to avoid -Wcast-qual warnings
ClosedPublic

Authored by dim on Jan 29 2015, 9:04 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Jan 23, 5:33 AM
Unknown Object (File)
Thu, Jan 23, 5:03 AM
Unknown Object (File)
Fri, Jan 17, 2:58 PM
Unknown Object (File)
Fri, Jan 17, 5:27 AM
Unknown Object (File)
Wed, Jan 8, 9:14 AM
Unknown Object (File)
Nov 28 2024, 6:50 AM
Unknown Object (File)
Nov 23 2024, 2:52 PM
Unknown Object (File)
Oct 30 2024, 1:24 AM
Subscribers
None

Details

Summary

When testing with clang 3.6.0, I got the following -Wcast-qual warnings in sys/dev/drm2:

sys/dev/drm2/radeon/ni.c:193:23: error: cast from 'unsigned int const (*)[29][2]' to 'unsigned int *' drops const qualifier [-Werror,-Wcast-qual]
                io_mc_regs = (u32 *)&barts_io_mc_regs;
                                    ^
sys/dev/drm2/radeon/ni.c:198:23: error: cast from 'unsigned int const (*)[29][2]' to 'unsigned int *' drops const qualifier [-Werror,-Wcast-qual]
                io_mc_regs = (u32 *)&turks_io_mc_regs;
                                    ^
sys/dev/drm2/radeon/ni.c:204:23: error: cast from 'unsigned int const (*)[29][2]' to 'unsigned int *' drops const qualifier [-Werror,-Wcast-qual]
                io_mc_regs = (u32 *)&caicos_io_mc_regs;
                                    ^
sys/dev/drm2/radeon/ni.c:209:23: error: cast from 'unsigned int const (*)[29][2]' to 'unsigned int *' drops const qualifier [-Werror,-Wcast-qual]
                io_mc_regs = (u32 *)&cayman_io_mc_regs;
                                    ^
sys/dev/drm2/radeon/si.c:193:23: error: cast from 'unsigned int const (*)[36][2]' to 'unsigned int *' drops const qualifier [-Werror,-Wcast-qual]
                io_mc_regs = (u32 *)&tahiti_io_mc_regs;
                                    ^
sys/dev/drm2/radeon/si.c:198:23: error: cast from 'unsigned int const (*)[36][2]' to 'unsigned int *' drops const qualifier [-Werror,-Wcast-qual]
                io_mc_regs = (u32 *)&pitcairn_io_mc_regs;
                                    ^
sys/dev/drm2/radeon/si.c:204:23: error: cast from 'unsigned int const (*)[36][2]' to 'unsigned int *' drops const qualifier [-Werror,-Wcast-qual]
                io_mc_regs = (u32 *)&verde_io_mc_regs;
                                    ^

Since the arrays pointed to by the local io_mc_regs variables are only ever read from, it should be no problem to make io_mc_regs a const u32 *, and change the casts accordingly.

Test Plan

Compile and boot

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dim retitled this revision from to Constify a number of accesses in drm2 to avoid -Wcast-qual warnings.
dim updated this object.
dim edited the test plan for this revision. (Show Details)
dim added reviewers: kib, dumbbell.
dumbbell edited edge metadata.
This revision is now accepted and ready to land.Jan 30 2015, 8:25 AM
dim updated this revision to Diff 3567.

Closed by commit rS278004 (authored by @dim).