1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

virsh: check if specified debug level is in range

This commit is contained in:
Ján Tomko 2012-07-26 16:05:51 +02:00 committed by Eric Blake
parent f12e139621
commit 4fedf388f6
2 changed files with 8 additions and 2 deletions

View File

@ -36,3 +36,4 @@
Alex Jia <ajia@redhat.com> Alex Jia <ajia@redhat.com>
Royce Lv <lvroyce@linux.vnet.ibm.com> Royce Lv <lvroyce@linux.vnet.ibm.com>
Daniel J Walsh <dwalsh@redhat.com> Daniel J Walsh <dwalsh@redhat.com>
Ján Tomko <jtomko@redhat.com>

View File

@ -3073,7 +3073,7 @@ vshAllowedEscapeChar(char c)
static bool static bool
vshParseArgv(vshControl *ctl, int argc, char **argv) vshParseArgv(vshControl *ctl, int argc, char **argv)
{ {
int arg, len; int arg, len, debug;
struct option opt[] = { struct option opt[] = {
{"debug", required_argument, NULL, 'd'}, {"debug", required_argument, NULL, 'd'},
{"help", no_argument, NULL, 'h'}, {"help", no_argument, NULL, 'h'},
@ -3093,10 +3093,15 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
while ((arg = getopt_long(argc, argv, "+d:hqtc:vVrl:e:", opt, NULL)) != -1) { while ((arg = getopt_long(argc, argv, "+d:hqtc:vVrl:e:", opt, NULL)) != -1) {
switch (arg) { switch (arg) {
case 'd': case 'd':
if (virStrToLong_i(optarg, NULL, 10, &ctl->debug) < 0) { if (virStrToLong_i(optarg, NULL, 10, &debug) < 0) {
vshError(ctl, "%s", _("option -d takes a numeric argument")); vshError(ctl, "%s", _("option -d takes a numeric argument"));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (debug < VSH_ERR_DEBUG || debug > VSH_ERR_ERROR)
vshError(ctl, _("ignoring debug level %d out of range [%d-%d]"),
debug, VSH_ERR_DEBUG, VSH_ERR_ERROR);
else
ctl->debug = debug;
break; break;
case 'h': case 'h':
vshUsage(); vshUsage();