Skip to content

Commit

Permalink
perftests/recv-zeros: more specific error-handling
Browse files Browse the repository at this point in the history
clang19-tidy warned that the previous code could result in an undefined
value in errno.  That's because in general, recv() can return -1, 0, or
any positive number up to buflen.  However, because we used the
MSG_WAITALL flag, the possible output is restricted to -1, 0, or buflen.
Due to that flag, the previous code was not wrong.

However, there's no harm in changing the "do we have an error?" check,
and that makes clang-tidy happier.
  • Loading branch information
gperciva authored and cperciva committed Jan 13, 2025
1 parent 4f631d3 commit 5adee54
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion perftests/recv-zeros/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ main(int argc, char ** argv)
do {
r = recv(socket_recv, buffer, buflen, MSG_WAITALL);
} while (r == (ssize_t)buflen);
if (r != 0) {
if (r == -1) {
warnp("recv");
goto err4;
}
Expand Down

0 comments on commit 5adee54

Please sign in to comment.