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
F114599055: D1727.diff
Mon, Apr 14, 7:24 AM
F114596157: D1727.id.diff
Mon, Apr 14, 6:50 AM
F114590808: D1727.id3524.diff
Mon, Apr 14, 5:47 AM
F114590216: D1727.id3567.diff
Mon, Apr 14, 5:41 AM
Unknown Object (File)
Sat, Apr 5, 1:47 PM
Unknown Object (File)
Tue, Apr 1, 1:15 PM
Unknown Object (File)
Feb 23 2025, 1:05 AM
Unknown Object (File)
Jan 23 2025, 5:33 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).