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é <phi...@linaro.org>

Reviewed-by: Richard Henderson <richard.hender...@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