Re: warning: cast removes address space '__percpu' of expression

From: Charlemagne Lasse
Date: Tue Apr 02 2024 - 03:56:44 EST


Am Mo., 1. Apr. 2024 um 21:16 Uhr schrieb Uros Bizjak <ubizjak@xxxxxxxxx>:
> > I would even go as far as saying that 1ca3683cc6d2 ("x86/percpu:
> > Enable named address spaces with known compiler version") together
> > with 3a1d3829e193 ("x86/percpu: Avoid sparse warning with cast to
> > named address space") triggered this problem

I think 1ca3683cc6d2 was wrong and is the last working one.


Just switch to 1ca3683cc6d2c2ce4204df519c4e4730d037905a and you won't
see the messages.

```
git reset --hard 1ca3683cc6d2c2ce4204df519c4e4730d037905a
git clean -dfx
make allnoconfig -j$(nproc)
make kvm_guest.config
make prepare -j$(nproc)
touch include/linux/netdevice.h
make C=1 net/core/dev.o CHECK="sparse -Wcast-from-as"
```

Go to 9a462b9eafa6dda16ea8429b151edb1fb535d744 and cherry-pick
3a1d3829e193c091475ceab481c5f8deab385023 and you would see the error.
On amd64 with 12.2.0, this would look like this:

```
git reset --hard 9a462b9eafa6dda16ea8429b151edb1fb535d744
git cherry-pick 3a1d3829e193c091475ceab481c5f8deab385023
git clean -dfx
make allnoconfig -j$(nproc)
make kvm_guest.config
make prepare -j$(nproc)
touch include/linux/netdevice.h
make C=1 net/core/dev.o CHECK="sparse -Wcast-from-as"
```

I would recommend to use `-Wsparse-all` for testing but for this
demonstration, it is easier to use `-Wcast-from-as` to reduce the
amount of noise in the demonstrator.