From 3ea4b30700d691ab8d4d944e5a5606b0af7f41f5 Mon Sep 17 00:00:00 2001 From: Demi Marie Obenour Date: Sun, 11 Aug 2024 19:23:21 -0400 Subject: [PATCH] connection: check for NULL string only once This removes a redundant check and combines two others. Signed-off-by: Demi Marie Obenour --- src/connection.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/connection.c b/src/connection.c index c322084c..4ba93092 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1063,14 +1063,14 @@ wl_connection_demarshal(struct wl_connection *connection, case WL_ARG_STRING: length = *p++; - if (length == 0 && !arg.nullable) { - wl_log("NULL string received on non-nullable " - "type, message %s(%s)\n", message->name, - message->signature); - errno = EINVAL; - goto err; - } if (length == 0) { + if (!arg.nullable) { + wl_log("NULL string received on non-nullable " + "type, message %s(%s)\n", message->name, + message->signature); + errno = EINVAL; + goto err; + } closure->args[i].s = NULL; break; } @@ -1088,7 +1088,7 @@ wl_connection_demarshal(struct wl_connection *connection, s = (char *) p; - if (length > 0 && s[length - 1] != '\0') { + if (s[length - 1] != '\0') { wl_log("string not nul-terminated, " "message %s(%s)\n", message->name, message->signature);