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)
Wed, Oct 30, 1:24 AM
Unknown Object (File)
Sun, Oct 27, 4:46 AM
Unknown Object (File)
Sun, Oct 27, 4:46 AM
Unknown Object (File)
Sun, Oct 27, 4:30 AM
Unknown Object (File)
Sat, Oct 26, 9:54 PM
Unknown Object (File)
Oct 3 2024, 10:01 AM
Unknown Object (File)
Sep 27 2024, 2:01 PM
Unknown Object (File)
Sep 13 2024, 10:38 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).