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, Apr 18, 10:13 AM
Unknown Object (File)
Thu, Apr 18, 10:12 AM
Unknown Object (File)
Mar 16 2024, 4:24 PM
Unknown Object (File)
Dec 22 2023, 8:46 PM
Unknown Object (File)
Dec 16 2023, 9:55 AM
Unknown Object (File)
Dec 16 2023, 9:55 AM
Unknown Object (File)
Dec 4 2023, 6:29 PM
Unknown Object (File)
Nov 22 2023, 5:12 PM
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).