test: fix -Wstringop-overread warning

Check the length before doing the compare like we do a few lines below,
not the other way around. It's a false positive because the length is
capped well below the maximum object size but it's an easy fix.

Fixes the following warning:

    test/test-poll-oob.c:94:19: warning: ‘strncmp’ specified bound
    [18446744071562067968, 18446744073709551615] exceeds maximum
    object size 9223372036854775807 [-Wstringop-overread]
This commit is contained in:
Ben Noordhuis 2026-01-13 10:18:06 +01:00
parent f420c2bd57
commit 9522a11db3

View File

@ -91,8 +91,8 @@ static void poll_cb(uv_poll_t* handle, int status, int events) {
while (n == -1 && errno == EINTR);
ASSERT(n >= 0 || errno != EINVAL);
if (cli_rd_check == 1) {
ASSERT_OK(strncmp(buffer, "world", n));
ASSERT_EQ(5, n);
ASSERT_OK(strncmp(buffer, "world", n));
cli_rd_check = 2;
}
if (cli_rd_check == 0) {