connection: check for NULL string only once

This removes a redundant check and combines two others.

Signed-off-by: Demi Marie Obenour <demi@invisiblethingslab.com>
This commit is contained in:
Demi Marie Obenour 2024-08-11 19:23:21 -04:00
parent bd0aa37eb9
commit 3ea4b30700

View file

@ -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);