On Tue, 15 Mar 2022 at 18:35, Philippe Mathieu-Daudé <philippe.mathieu.da...@gmail.com> wrote: > On 8/3/22 12:18, Peter Maydell wrote: > > Using 'unsigned long' in a cast (or anything else) is often > > the wrong thing in QEMU... > > $ git grep -F '(unsigned long)' | wc -l > 273 > > Ouch :/
Only "often", not "always" :-) We have some APIs that work on 'long', usually because they're generic APIs borrowed from the Linux kernel like the clear_bit/set_bit functions. And sometimes you're interfacing to a host OS API whose types are 'long'. So it's only one of those things that I tend to have in the back of my head during code review, rather than something I think we could enforce automatically. The stuff in sev.c you list does look a bit suspicious, but it's not actually buggy because that's all KVM code so we know 'unsigned long' and pointers are the same size. 'uintptr_t' would be better, though. thanks -- PMM