From: Paul Brook <paul@codesourcery.com>
To: qemu-devel@nongnu.org
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
Markus Armbruster <armbru@redhat.com>
Subject: Re: [Qemu-devel] [6609] Parse full PCI device addresses (Markus Armbruster)
Date: Thu, 12 Feb 2009 16:18:16 +0000 [thread overview]
Message-ID: <200902121618.17411.paul@codesourcery.com> (raw)
In-Reply-To: <20090212155605.GA18654@amt.cnet>
> > If we're rejecting nonzero domains then having the parse routine return a
> > domain value seems wrong. It's just going to make it harder to verify
> > correct operation when domains are implemented.
>
> + /* Note: QEMU doesn't implement domains other than 0 */
> + if (dom != 0 || pci_find_bus(bus) == NULL) {
> + fprintf(stderr, "PCI device address %s not supported", addr);
> + return -1;
> + }
>
> + if (!strcmp(devaddr, "auto")) {
> + *domp = *busp = 0;
> + *slotp = -1;
> + /* want to support dom/bus auto-assign at some point */
> + return 0;
> + }
>
> We return domain 0. I considered domain 0 as implicit at the moment, is
> that wrong?
>
> I can't see where you're getting at.
You're returning a value that's always known to be zero. IMHO That's worse
than not returning a value at all.
This implies users of this function will either ignore the value or have
redundant, untested (i.e. probably bitrotten) code to handle nonzero domains.
Either way, it's liable the break horribly at runtime as soon as we start
trying to support multiple domains.
If pci_parse_devaddr is defined to only handle zero domains, then it should
not be returning a domain value. If/when we implement multiple PCI domains we
can change the interface, and get nice compiler errors in all the other code
we forgot to update.
Alternatively, have the parse routine return the full tuple, and enforce
domain == 0 elsewhere.
Paul
next prev parent reply other threads:[~2009-02-12 16:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-11 15:21 [Qemu-devel] [6609] Parse full PCI device addresses (Markus Armbruster) Anthony Liguori
2009-02-12 15:39 ` Paul Brook
2009-02-12 15:56 ` Marcelo Tosatti
2009-02-12 16:18 ` Paul Brook [this message]
2009-02-12 18:27 ` Marcelo Tosatti
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=200902121618.17411.paul@codesourcery.com \
--to=paul@codesourcery.com \
--cc=armbru@redhat.com \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
/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).