On 06/15/2012 02:46 PM, Li Zhang wrote:
On Fri, Jun 15, 2012 at 7:09 PM, Andreas Färber<afaer...@suse.de>  wrote:

You don't seem to be getting what I'm saying: As discussed in great
lengths for how to access a passed-in device tree for ARM, the code
checking this option (i.e., in spapr.c) is expected to call
qemu_opt_get() itself, instead of saving its value globally in vl.c. For
example:

machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0);
usb_opt = qemu_opt_get(machine_opts, "usb");
if (strcmp(usb_opt, "off") != 0) {
    // set up OHCI
}

I see.
I  just thought if every machine has the same code, it can be done in vl.c.
Isn't  the global variable good ?

No, global variables are always bad :). If you see code duplication, just throw the interesting bit into a static inline function in a header and have the users call that.


Alex


Reply via email to