Page MenuHomeFreeBSD

Fix a bunch of cast-qual warnings in ath's ar9300_attach.c
ClosedPublic

Authored by dim on Jan 29 2015, 5:59 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 25 2024, 10:28 PM
Unknown Object (File)
Mar 2 2024, 4:38 PM
Unknown Object (File)
Feb 28 2024, 6:40 PM
Unknown Object (File)
Dec 20 2023, 5:45 AM
Unknown Object (File)
Dec 16 2023, 9:53 AM
Unknown Object (File)
Dec 16 2023, 9:53 AM
Unknown Object (File)
Nov 1 2023, 1:47 PM
Unknown Object (File)
Oct 13 2023, 4:14 PM
Subscribers
None

Details

Summary

When testing with clang 3.6.0, I got a number of the following -Wcast-qual warnings:

sys/contrib/dev/ath/ath_hal/ar9300/ar9300_attach.c:849:9: error: cast from 'unsigned int const (*)[2]' to 'unsigned int *'
      drops const qualifier [-Werror,-Wcast-qual]
        INIT_INI_ARRAY(&ahp->ah_ini_mac[ATH_INI_CORE],
        ^
sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h:325:41: note: expanded from macro 'INIT_INI_ARRAY'
    (iniarray)->ia_array = (u_int32_t *)(array);    \
                                        ^
sys/contrib/dev/ath/ath_hal/ar9300/ar9300_attach.c:852:9: error: cast from 'unsigned int const (*)[5]' to 'unsigned int *'
      drops const qualifier [-Werror,-Wcast-qual]
        INIT_INI_ARRAY(&ahp->ah_ini_mac[ATH_INI_POST],
        ^
sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h:325:41: note: expanded from macro 'INIT_INI_ARRAY'
    (iniarray)->ia_array = (u_int32_t *)(array);    \
                                        ^
sys/contrib/dev/ath/ath_hal/ar9300/ar9300_attach.c:858:9: error: cast from 'unsigned int const (*)[2]' to 'unsigned int *'
      drops const qualifier [-Werror,-Wcast-qual]
        INIT_INI_ARRAY(&ahp->ah_ini_bb[ATH_INI_CORE],
        ^
sys/contrib/dev/ath/ath_hal/ar9300/ar9300.h:325:41: note: expanded from macro 'INIT_INI_ARRAY'
    (iniarray)->ia_array = (u_int32_t *)(array);    \
                                        ^

As far as I can see, it should be no problem to constify both the ia_array field in struct ar9300_ini_array, and the cast in the INIT_INI_ARRAY() macro.

No functional change.

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 Fix a bunch of cast-qual warnings in ath's ar9300_attach.c.
dim updated this object.
dim edited the test plan for this revision. (Show Details)
dim added a reviewer: adrian.

Lemme go see if there's any code that treats the array as read/write buried somewhere deep in the HAL.

The AR5416 HAL has this "behaviour". :(

In D1725#3, @adrian wrote:

Lemme go see if there's any code that treats the array as read/write buried somewhere deep in the HAL.

As far as I can see, the items that induced warnings were all defined as const arrays in sys/contrib/dev/ath/ath_hal/ar9300/*.ini, so they should have ended up in the read-only data segment. But the code indeed looks tricky. :-)

Alternatively, we can just add a __DECONST to the cast in INIT_INI_ARRAY().

Adrian, if you don't have time to review, I can also disable the -Wcast-qual warning for this particular file instead. I would like to get some change in, so I can merge it to the clang360-import branch.

I just reviewed it; it looks fine. Please commit!

adrian edited edge metadata.
This revision is now accepted and ready to land.Feb 6 2015, 3:12 PM
dim updated this revision to Diff 3683.

Closed by commit rS278348 (authored by @dim).