qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Hao Wu <wuhaotsh@google.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Thomas Huth" <thuth@redhat.com>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	qemu-arm <qemu-arm@nongnu.org>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"Patrick Venture" <venture@google.com>,
	"IS20 Avi Fishman" <Avi.Fishman@nuvoton.com>,
	"CS20 KFTing" <kfting@nuvoton.com>,
	"Havard Skinnemoen" <hskinnemoen@google.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	bin.meng@windriver.com, qemu-block@nongnu.org,
	"Shengtan Mao" <maoshengtan2011@gmail.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Shengtan Mao" <stmao@google.com>,
	"Chris Rauer" <crauer@google.com>
Subject: Re: [PATCH v4] tests/qtest: add qtests for npcm7xx sdhci
Date: Fri, 25 Feb 2022 09:45:33 -0800	[thread overview]
Message-ID: <CAGcCb10AbftohExf2-2u6gAs+MeOj8gYceDoJ59t4pcX3rz_Pg@mail.gmail.com> (raw)
In-Reply-To: <CAFEAcA_hzOkgLaYv=Zy338zfv3WsvSyKVEgzS6bn03o0=ed1VA@mail.gmail.com>

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

I have sent an updated version that uses memcmp()

On Fri, Feb 25, 2022 at 3:44 AM Peter Maydell <peter.maydell@linaro.org>
wrote:

> On Thu, 24 Feb 2022 at 19:03, Hao Wu <wuhaotsh@google.com> wrote:
> >
> > From: Shengtan Mao <stmao@google.com>
> >
> > Reviewed-by: Hao Wu <wuhaotsh@google.com>
> > Reviewed-by: Chris Rauer <crauer@google.com>
> > Signed-off-by: Shengtan Mao <stmao@google.com>
> > Signed-off-by: Patrick Venture <venture@google.com>
> > Signed-off-by: Hao Wu <wuhaotsh@google.com>
> > ---
> > v4:
> >  * use strncmp to compare fixed length strings
> > v3:
> >  * fixup compilation from missing macro value
> > v2:
> >  * update copyright year
> >  * check result of open
> >  * use g_free instead of free
> >  * move declarations to the top
> >  * use g_file_open_tmp
> > ---
>
> > +static void write_sdread(QTestState *qts, const char *msg)
> > +{
> > +    int fd, ret;
> > +    size_t len = strlen(msg);
> > +    char *rmsg = g_malloc(len);
> > +
> > +    /* write message to sd */
> > +    fd = open(sd_path, O_WRONLY);
> > +    g_assert(fd >= 0);
> > +    ret = write(fd, msg, len);
> > +    close(fd);
> > +    g_assert(ret == len);
> > +
> > +    /* read message using sdhci */
> > +    ret = sdhci_read_cmd(qts, NPCM7XX_MMC_BA, rmsg, len);
> > +    g_assert(ret == len);
> > +    g_assert(!strncmp(rmsg, msg, len));
>
> We always know we want to compare exactly 'len' bytes here, and we know
> the buffers in each case are at least that large. The right function
> for that is memcmp(), I think.
>
> thanks
> -- PMM
>

[-- Attachment #2: Type: text/html, Size: 2554 bytes --]

  reply	other threads:[~2022-02-25 17:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-24 19:03 [PATCH v4] tests/qtest: add qtests for npcm7xx sdhci Hao Wu
2022-02-25 11:44 ` Peter Maydell
2022-02-25 17:45   ` Hao Wu [this message]
2022-02-25 18:34     ` Patrick Venture

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=CAGcCb10AbftohExf2-2u6gAs+MeOj8gYceDoJ59t4pcX3rz_Pg@mail.gmail.com \
    --to=wuhaotsh@google.com \
    --cc=Avi.Fishman@nuvoton.com \
    --cc=bin.meng@windriver.com \
    --cc=crauer@google.com \
    --cc=f4bug@amsat.org \
    --cc=hskinnemoen@google.com \
    --cc=kfting@nuvoton.com \
    --cc=lvivier@redhat.com \
    --cc=maoshengtan2011@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=stmao@google.com \
    --cc=thuth@redhat.com \
    --cc=venture@google.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).