Re: [PATCH 2/2] kvm tools: Check for unknown parameters in network option handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 13, 2012 at 3:27 PM, Pekka Enberg <penberg@xxxxxxxxxx> wrote:
> On Mon, Aug 13, 2012 at 6:31 AM, Michael Ellerman
> <michael@xxxxxxxxxxxxxx> wrote:
>>> > diff --git a/tools/kvm/builtin-run.c b/tools/kvm/builtin-run.c
>>> > index a36bd00..9e5c1d4 100644
>>> > --- a/tools/kvm/builtin-run.c
>>> > +++ b/tools/kvm/builtin-run.c
>>> > @@ -257,7 +257,8 @@ static int set_net_param(struct virtio_net_params *p, const char *param,
>>> >                 p->vhost = atoi(val);
>>> >         } else if (strcmp(param, "fd") == 0) {
>>> >                 p->fd = atoi(val);
>>> > -       }
>>> > +       } else
>>> > +               die("Unknown network parameter %s", param);
>>>
>>> we need braces here:
>>
>> We don't _need_ braces, but I assume you mean you'd prefer braces?
>
> This is Linux coding style so we don't prefer them either.

Documentation/CodingStyle says:
'''
Do not unnecessarily use braces where a single statement will do.

if (condition)
        action();

and

if (condition)
        do_this();
else
        do_that();

This does not apply if only one branch of a conditional statement is a single
statement; in the latter case use braces in both branches:

if (condition) {
        do_this();
        do_that();
} else {
        otherwise();
}
'''
we have a multiple line branch in set_net_param(), so I think it's
better to have the braces for the last die() branch.

-- 
Asias He
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux