提交 0ef07e19 编写于 作者: E Erik Skultety

vsh: Make vshInitDebug return int instead of void

Well, the reason behind this change is that if the function is extended in some
way that e.g. would involve allocation we do not have a way of telling it to
the caller. More specifically, vshInitDebug only relies on some hardcoded
environment variables (by a mistake) that aren't documented anywhere so neither
virsh's nor virt-admin's documented environment variables take effect. One
possible solution would be duplicate the code for each CLI client or leave the
method be generic and provide means that it could figure out, which client
called it, thus initializing the proper environment variables but that could
involve operations that might as well fail in certain circumstances and the
caller should know that an error occurred.
Signed-off-by: NErik Skultety <eskultet@redhat.com>
上级 1db6908a
...@@ -2963,7 +2963,7 @@ vshReadline(vshControl *ctl, const char *prompt) ...@@ -2963,7 +2963,7 @@ vshReadline(vshControl *ctl, const char *prompt)
/* /*
* Initialize debug settings. * Initialize debug settings.
*/ */
static void static int
vshInitDebug(vshControl *ctl) vshInitDebug(vshControl *ctl)
{ {
const char *debugEnv; const char *debugEnv;
...@@ -2991,6 +2991,8 @@ vshInitDebug(vshControl *ctl) ...@@ -2991,6 +2991,8 @@ vshInitDebug(vshControl *ctl)
vshOpenLogFile(ctl); vshOpenLogFile(ctl);
} }
} }
return 0;
} }
...@@ -3013,9 +3015,9 @@ vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set) ...@@ -3013,9 +3015,9 @@ vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set)
cmdGroups = groups; cmdGroups = groups;
cmdSet = set; cmdSet = set;
vshInitDebug(ctl);
if (ctl->imode && vshReadlineInit(ctl) < 0) if (vshInitDebug(ctl) < 0 ||
(ctl->imode && vshReadlineInit(ctl) < 0))
return false; return false;
return true; return true;
...@@ -3030,7 +3032,8 @@ vshInitReload(vshControl *ctl) ...@@ -3030,7 +3032,8 @@ vshInitReload(vshControl *ctl)
return false; return false;
} }
vshInitDebug(ctl); if (vshInitDebug(ctl) < 0)
return false;
if (ctl->imode) if (ctl->imode)
vshReadlineDeinit(ctl); vshReadlineDeinit(ctl);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册