On Mon, Nov 05, 2018 at 01:45:24PM +0300, Julia Suvorova wrote: > + writel(NRF51_UART_BASE + A_UART_SUSPEND, 0x01); > + writel(NRF51_UART_BASE + A_UART_TXD, 'h'); > + writel(NRF51_UART_BASE + A_UART_STARTTX, 0x01); > + w_to_txd("world"); > + g_assert(read(sock_fd, s, 10) == 5); > + g_assert(strcmp(s, "world") == 0);
Please use memcmp(3) instead. A broken QEMU could send non-NUL terminated data and strcmp(3) would go beyond the end of s[]. (I haven't looked back to see if s[6..9] was previously initialized to '\0' but it's cleaner if the code makes it obvious that there is no bug here.)
signature.asc
Description: PGP signature