Skip to content

Commit f52e7f5

Browse files
mmhalkuba-moo
authored andcommitted
vsock/test: Adapt send_byte()/recv_byte() to handle MSG_ZEROCOPY
For a zerocopy send(), buffer (always byte 'A') needs to be preserved (thus it can not be on the stack) or the data recv()ed check in recv_byte() might fail. While there, change the printf format to 0x%02x so the '\0' bytes can be seen. Reviewed-by: Stefano Garzarella <[email protected]> Signed-off-by: Michal Luczaj <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 50f9434 commit f52e7f5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/testing/vsock/util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ void recv_buf(int fd, void *buf, size_t len, int flags, ssize_t expected_ret)
401401
*/
402402
void send_byte(int fd, int expected_ret, int flags)
403403
{
404-
const uint8_t byte = 'A';
404+
static const uint8_t byte = 'A';
405405

406406
send_buf(fd, &byte, sizeof(byte), flags, expected_ret);
407407
}
@@ -420,7 +420,7 @@ void recv_byte(int fd, int expected_ret, int flags)
420420
recv_buf(fd, &byte, sizeof(byte), flags, expected_ret);
421421

422422
if (byte != 'A') {
423-
fprintf(stderr, "unexpected byte read %c\n", byte);
423+
fprintf(stderr, "unexpected byte read 0x%02x\n", byte);
424424
exit(EXIT_FAILURE);
425425
}
426426
}

0 commit comments

Comments
 (0)