qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 6/7] hw/isa: Assert isa_register_portio_list() gets non-NULL


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH 6/7] hw/isa: Assert isa_register_portio_list() gets non-NULL ISA device
Date: Tue, 14 Feb 2023 11:18:06 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.7.2

On 8/2/23 20:47, Richard Henderson wrote:
On 2/7/23 14:07, Philippe Mathieu-Daudé wrote:
The previous commit removed the single call to
isa_register_portio_list() with dev=NULL. To be
sure we won't reintroduce such weird (ab)use,
add an assertion.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

I wonder how much use of __attribute__((nonnull)) we should be making.

__attribute__((nonnull)) is compile-time, but seems weaker than the
good old runtime assert():

 void a0(void *ptr)
 {
   assert(ptr);
 }

 __attribute__((nonnull)) void a1(void *ptr)
 {
   // can no use assert(ptr) because compiler warning
 }

 void b0(void *x)
 {
   a(NULL); // runtime assertion
 }

 void b(void *x)
 {
   a1(NULL); // compile error
 }

 void c0(void *x)
 {
   a0(x);
 }

 void c1(void *x)
 {
   a1(x);
 }

 void d0(void *x)
 {
   c0(NULL); // runtime assertion
 }

 void d1(void *x)
 {
   c1(NULL); // no compile error, no assertion!
 }

I realize we'd probably want to add -fno-delete-null-pointer-checks if we make too much use of that.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]