From 47f7783276438e5c073004cba6351c0e880ed6c5 Mon Sep 17 00:00:00 2001 Message-Id: <47f7783276438e5c073004cba6351c0e880ed6c5@dist-git> From: Erik Skultety Date: Tue, 2 Aug 2016 09:55:52 +0200 Subject: [PATCH] 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: Erik Skultety (cherry picked from commit 0ef07e19c7c29f1c03e95bf574fb98eee2243203) https://bugzilla.redhat.com/show_bug.cgi?id=1357363 Signed-off-by: Erik Skultety --- tools/vsh.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index 2b78919..2f564e6 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2742,7 +2742,7 @@ vshReadline(vshControl *ctl, const char *prompt) /* * Initialize debug settings. */ -static void +static int vshInitDebug(vshControl *ctl) { const char *debugEnv; @@ -2770,6 +2770,8 @@ vshInitDebug(vshControl *ctl) vshOpenLogFile(ctl); } } + + return 0; } @@ -2792,9 +2794,9 @@ vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set) cmdGroups = groups; cmdSet = set; - vshInitDebug(ctl); - if (ctl->imode && vshReadlineInit(ctl) < 0) + if (vshInitDebug(ctl) < 0 || + (ctl->imode && vshReadlineInit(ctl) < 0)) return false; return true; @@ -2809,7 +2811,8 @@ vshInitReload(vshControl *ctl) return false; } - vshInitDebug(ctl); + if (vshInitDebug(ctl) < 0) + return false; if (ctl->imode) vshReadlineDeinit(ctl); -- 2.9.2