mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
tests/unit: Add a assert for test_io_channel_unix_listen_cleanup
Calling bind without checking return value. Add a assert for it. Signed-off-by: Kunwu <chentao@kylinos.cn> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
95cc223afb
commit
08e702043f
1 changed files with 4 additions and 2 deletions
|
@ -506,7 +506,7 @@ static void test_io_channel_unix_listen_cleanup(void)
|
||||||
{
|
{
|
||||||
QIOChannelSocket *ioc;
|
QIOChannelSocket *ioc;
|
||||||
struct sockaddr_un un;
|
struct sockaddr_un un;
|
||||||
int sock;
|
int sock, ret = 0;
|
||||||
|
|
||||||
#define TEST_SOCKET "test-io-channel-socket.sock"
|
#define TEST_SOCKET "test-io-channel-socket.sock"
|
||||||
|
|
||||||
|
@ -519,7 +519,9 @@ static void test_io_channel_unix_listen_cleanup(void)
|
||||||
un.sun_family = AF_UNIX;
|
un.sun_family = AF_UNIX;
|
||||||
snprintf(un.sun_path, sizeof(un.sun_path), "%s", TEST_SOCKET);
|
snprintf(un.sun_path, sizeof(un.sun_path), "%s", TEST_SOCKET);
|
||||||
unlink(TEST_SOCKET);
|
unlink(TEST_SOCKET);
|
||||||
bind(sock, (struct sockaddr *)&un, sizeof(un));
|
ret = bind(sock, (struct sockaddr *)&un, sizeof(un));
|
||||||
|
g_assert_cmpint(ret, ==, 0);
|
||||||
|
|
||||||
ioc->fd = sock;
|
ioc->fd = sock;
|
||||||
ioc->localAddrLen = sizeof(ioc->localAddr);
|
ioc->localAddrLen = sizeof(ioc->localAddr);
|
||||||
getsockname(sock, (struct sockaddr *)&ioc->localAddr,
|
getsockname(sock, (struct sockaddr *)&ioc->localAddr,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue