qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3] tests/microbit-test: Check nRF51 UART functi


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v3] tests/microbit-test: Check nRF51 UART functionality
Date: Thu, 8 Nov 2018 10:45:20 +0000
User-agent: Mutt/1.10.1 (2018-07-13)

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.)

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]