qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: Julia Suvorova <jusual@mail.ru>
Cc: qemu-devel@nongnu.org, "Peter Maydell" <peter.maydell@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Joel Stanley" <joel@jms.id.au>,
	"Jim Mussared" <jim@groklearning.com>,
	"Steffen Görtz" <mail@steffen-goertz.de>,
	"Thomas Huth" <thuth@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3] tests/microbit-test: Check nRF51 UART functionality
Date: Thu, 8 Nov 2018 10:45:20 +0000	[thread overview]
Message-ID: <20181108104520.GF17083@stefanha-x1.localdomain> (raw)
In-Reply-To: <20181105104524.933-1-jusual@mail.ru>

[-- Attachment #1: Type: text/plain, Size: 614 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

      parent reply	other threads:[~2018-11-08 10:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-05 10:45 [Qemu-devel] [PATCH v3] tests/microbit-test: Check nRF51 UART functionality Julia Suvorova
2018-11-05 12:24 ` Alex Bennée
2018-11-05 13:26   ` Julia Suvorova
2018-11-05 15:29 ` no-reply
2018-11-05 15:32 ` no-reply
2018-11-05 16:16 ` Philippe Mathieu-Daudé
2018-11-05 16:36   ` Julia Suvorova
2018-11-05 17:54 ` Peter Maydell
2018-11-08 10:50   ` Stefan Hajnoczi
2018-11-08 10:45 ` Stefan Hajnoczi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181108104520.GF17083@stefanha-x1.localdomain \
    --to=stefanha@redhat.com \
    --cc=jim@groklearning.com \
    --cc=joel@jms.id.au \
    --cc=jusual@mail.ru \
    --cc=mail@steffen-goertz.de \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).