From a4f861a49a8e67bd82f9b8c32b0299ce8d6adc42 Mon Sep 17 00:00:00 2001 From: Jie Liu Date: Thu, 2 Apr 2026 10:31:22 +0800 Subject: [PATCH] connection: allow NULL implementation and listener in wl_closure_invoke In practice, not all callbacks defined by a wl_interface are needed by every client or server. For instance, a client may only care about a subset of events on an object and leave the rest unhandled. Previously, a NULL implementation or a NULL listener function for a specific opcode would cause a fatal wl_abort(), forcing users to provide stub callbacks for every opcode even when they had nothing to do. This made code unnecessarily verbose. Downgrade the abort to a wl_log() warning and return early after cleaning up file descriptors. This allows partial interface implementations, simplifying user code while still logging a diagnostic message for debugging. Signed-off-by: Jie Liu --- src/connection.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/connection.c b/src/connection.c index 2d1e8d1d..bb8993b5 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1232,13 +1232,16 @@ wl_closure_invoke(struct wl_closure *closure, uint32_t flags, implementation = target->implementation; if (!implementation) { - wl_abort("Implementation of resource %d of %s is NULL\n", + wl_log("Implementation of resource %d of %s is NULL\n", target->id, target->interface->name); + + return wl_closure_clear_fds(closure); } if (!implementation[opcode]) { - wl_abort("listener function for opcode %u of %s is NULL\n", + wl_log("listener function for opcode %u of %s is NULL\n", opcode, target->interface->name); + return wl_closure_clear_fds(closure); } ffi_call(&cif, implementation[opcode], NULL, ffi_args);