tests: Remove some compiler warnings

Remove warnings like:

In file included from /usr/include/glib-2.0/glib.h:86,
                 from ../server/tests/test-glib-compat.h:21,
                 from ../server/tests/test-channel.cpp:25:
In function 'void send_ack_sync(int, uint32_t)',
    inlined from 'void channel_loop()' at ../server/tests/test-channel.cpp:250:18:
../server/sys-socket.h:28:43: error: 'ssize_t write(int, const void*, size_t)' reading 10 bytes from a region of size 2 [-Werror=stringop-overread]
   28 | #define socket_write(sock, buf, len) write(sock, buf, len)
/usr/include/glib-2.0/glib/gtestutils.h:50:61: note: in definition of macro 'g_assert_cmpint'
   50 |                                              gint64 __n1 = (n1), __n2 = (n2); \
      |                                                             ^~
../server/tests/test-channel.cpp:132:21: note: in expansion of macro 'socket_write'
  132 |     g_assert_cmpint(socket_write(socket, &msg.type, 10), ==, 10);
      |                     ^~~~~~~~~~~~
../server/tests/test-channel.cpp: In function 'void channel_loop()':
../server/tests/test-channel.cpp:123:18: note: source object 'send_ack_sync(int, uint32_t)::<unnamed struct>::type' of size 2
  123 |         uint16_t type;
      |                  ^~~~
In file included from ../server/tests/test-channel.cpp:22:
/usr/include/unistd.h:367:16: note: in a call to function 'ssize_t write(int, const void*, size_t)' declared with attribute 'access (read_only, 2, 3)'
  367 | extern ssize_t write (int __fd, const void *__buf, size_t __n) __wur
      |                ^~~~~
cc1plus: all warnings being treated as errors

Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Acked-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
Frediano Ziglio 2021-05-04 18:11:40 +01:00
parent e39412644c
commit 62dd7e47e9
2 changed files with 4 additions and 3 deletions

View File

@ -129,7 +129,7 @@ static void send_ack_sync(int socket, uint32_t generation)
msg.len = GUINT32_TO_LE(sizeof(generation));
msg.generation = GUINT32_TO_LE(generation);
g_assert_cmpint(socket_write(socket, &msg.type, 10), ==, 10);
g_assert_cmpint(socket_write(socket, reinterpret_cast<uint8_t *>(&msg) + 2, 10), ==, 10);
}
static SpiceTimer *waked_up_timer;

View File

@ -108,7 +108,7 @@ static void send_ack_sync(int socket, uint32_t generation)
msg.len = GUINT32_TO_LE(sizeof(generation));
msg.generation = GUINT32_TO_LE(generation);
g_assert_cmpint(socket_write(socket, &msg.type, 10), ==, 10);
g_assert_cmpint(socket_write(socket, reinterpret_cast<uint8_t *>(&msg) + 2, 10), ==, 10);
}
static void send_data(int socket, uint32_t type, uint32_t reader_id)
@ -128,7 +128,8 @@ static void send_data(int socket, uint32_t type, uint32_t reader_id)
msg.vheader.length = GUINT32_TO_LE(6);
strcpy(msg.data, "hello");
g_assert_cmpint(socket_write(socket, &msg.type, sizeof(msg)-4), ==, sizeof(msg)-4);
g_assert_cmpint(socket_write(socket, reinterpret_cast<uint8_t *>(&msg) + 2,
sizeof(msg) - 4), ==, sizeof(msg) - 4);
}
static void check_data(VmcEmu *vmc_emu)