Re: [PATCHv2 ath-next] wifi: ath9k: mark static arrays as const
From: Rosen Penev
Date: Tue Jun 23 2026 - 17:32:08 EST
On Tue, Jun 23, 2026 at 5:58 AM Toke Høiland-Jørgensen <toke@xxxxxxx> wrote:
>
> Rosen Penev <rosenp@xxxxxxxxx> writes:
>
> > On Mon, Jun 22, 2026 at 4:49 AM Toke Høiland-Jørgensen <toke@xxxxxxx> wrote:
> >>
> >> Rosen Penev <rosenp@xxxxxxxxx> writes:
> >>
> >> > PN9Data is a read-only lookup table and is never modified. Adding const
> >> > lets the compiler place it in .rodata and prevents accidental writes.
> >> >
> >> > Use the same treatment for bits_per_symbol. It's not modified either.
> >> >
> >> > Assisted-by: opencode:big-pickle
> >> > Signed-off-by: Rosen Penev <rosenp@xxxxxxxxx>
> >>
> >> Again, which actual bug are you fixing here?
> > Patches are required to be bugfixes?
>
> Well, or at least have some concrete benefit? You're changing working
> code here, we've had to revert patches of this kind before because it
> broke things.
>
> For this patch specifically, there's one of two cases:
>
> - The array is never written to, in which case the patch has no
> practical effect
>
> or
>
> - The array *is* actually written to somewhere, in which case the kernel
> will now crash as soon as someone tries to run the code.
I believe the description addresses this.
>
> Either way, I don't see how the risk/benefit tradeoff comes off positive
> for this patch?
const makes the array easier to optimize for a compiler in general.
And because it's static, it goes in rodata.
>
> -Toke