From: Greg Kurz <groug@kaod.org>
To: Eric Blake <eblake@redhat.com>
Cc: nee <nia.alarie@gmail.com>,
qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@gmail.com>,
Jim Mussared <jim@groklearning.com>,
Joel Stanley <joel@jms.id.au>
Subject: Re: [Qemu-devel] [PATCH v2] 9p: Convert use of atoi to qemu_strtoi to allow error checking
Date: Mon, 12 Mar 2018 18:07:46 +0100 [thread overview]
Message-ID: <20180312180746.43303703@bahia.lan> (raw)
In-Reply-To: <9e1dbfe9-e26b-66b6-7009-1c2015160c97@redhat.com>
On Mon, 12 Mar 2018 11:00:39 -0500
Eric Blake <eblake@redhat.com> wrote:
> On 03/12/2018 10:50 AM, nee wrote:
>
> >>> } else if (perm & P9_STAT_MODE_LINK) {
> >>> - int32_t ofid = atoi(extension.data);
> >>> - V9fsFidState *ofidp = get_fid(pdu, ofid);
> >>> + int ofid;
> >>
> >>
> >> 'unsigned int' and...
> >>
> >>> + V9fsFidState *ofidp;
> >>> +
> >>> + if (qemu_strtoi(extension.data, NULL, 10, &ofid)) {
> >>
> >>
> >> qemu_strtoui() might be smarter, per Greg's comments on v1.
> >>
> >>> + err = -EINVAL;
> >>> + goto out;
> >>> + }
> >>> + ofidp = get_fid(pdu, (int32_t)ofid);
> >>
> >>
> >> This cast is spurious.
> >>
> >> --
> >> Eric Blake, Principal Software Engineer
> >> Red Hat, Inc. +1-919-301-3266
> >> Virtualization: qemu.org | libvirt.org
> >
> > I did this because get_fid() takes an int32_t, not an unsigned int.
> > The struct V9fsFidState also uses an int32_t for its `fid` member. Do
> > you want me to change all these types, or just the function being used
> > here?
>
> I'll let Greg answer; he's more familiar with the 9p code (I was just
> commenting based on his initial answer to v1).
>
Yeah... as I was saying, fids are 32-bit unsigned per spec but the code is
using int32_t indeed. This is incorrect and it should be fixed.
prev parent reply other threads:[~2018-03-12 17:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-12 15:33 [Qemu-devel] [PATCH v2] 9p: Convert use of atoi to qemu_strtoi to allow error checking Nia Alarie
2018-03-12 15:43 ` Eric Blake
2018-03-12 15:50 ` nee
2018-03-12 16:00 ` Eric Blake
2018-03-12 17:07 ` Greg Kurz [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=20180312180746.43303703@bahia.lan \
--to=groug@kaod.org \
--cc=eblake@redhat.com \
--cc=jim@groklearning.com \
--cc=joel@jms.id.au \
--cc=nia.alarie@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@gmail.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).