[libvirt] [PATCH] virsh: check if specified debug level is in range
Eric Blake
eblake at redhat.com
Thu Jul 26 13:42:36 UTC 2012
On 07/26/2012 07:35 AM, Ján Tomko wrote:
> ---
> tools/virsh.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/tools/virsh.c b/tools/virsh.c
> index 5658796..34ae171 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -3097,6 +3097,10 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
> vshError(ctl, "%s", _("option -d takes a numeric argument"));
> exit(EXIT_FAILURE);
> }
> + if (ctl->debug < VSH_ERR_DEBUG || ctl->debug > VSH_ERR_ERROR) {
> + vshError(ctl, _("ignoring debug level %d out of range [0-4]"),
> + ctl->debug);
> + }
That warns, but still uses the fishy ctl->debug value for the rest of
the life of the program. Would it be better to first parse the option
into a temporary variable, then range check, and only after the range
check then assign it to ctl->debug?
--
Eric Blake eblake at redhat.com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120726/d2749356/attachment-0001.sig>
More information about the libvir-list
mailing list