[libvirt] [PATCH 02/18] vsh: Drop useless check for cmd != NULL

Michal Privoznik mprivozn at redhat.com
Tue Jan 2 17:11:55 UTC 2018


All our internal *Free() functions are capable of handling NULL.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 tools/vsh.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/tools/vsh.c b/tools/vsh.c
index e38dcec92..a21e1d1de 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -1392,10 +1392,8 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
     vshCmd *clast = NULL;
     vshCmdOpt *first = NULL;
 
-    if (ctl->cmd) {
-        vshCommandFree(ctl->cmd);
-        ctl->cmd = NULL;
-    }
+    vshCommandFree(ctl->cmd);
+    ctl->cmd = NULL;
 
     while (1) {
         vshCmdOpt *last = NULL;
@@ -1576,10 +1574,8 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser)
     return true;
 
  syntaxError:
-    if (ctl->cmd) {
-        vshCommandFree(ctl->cmd);
-        ctl->cmd = NULL;
-    }
+    vshCommandFree(ctl->cmd);
+    ctl->cmd = NULL;
     vshCommandOptFree(first);
     VIR_FREE(tkdata);
     return false;
-- 
2.13.6




More information about the libvir-list mailing list