summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-cmd-peer.c10
-rw-r--r--cli/src/cli-cmd-volume.c72
-rw-r--r--cli/src/cli-cmd.h13
-rw-r--r--cli/src/cli.c4
4 files changed, 46 insertions, 53 deletions
diff --git a/cli/src/cli-cmd-peer.c b/cli/src/cli-cmd-peer.c
index 60756f310..4ac1630e5 100644
--- a/cli/src/cli-cmd-peer.c
+++ b/cli/src/cli-cmd-peer.c
@@ -96,8 +96,8 @@ out:
if ((sent == 0) && (parse_error == 0))
cli_out ("Peer probe failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -164,8 +164,7 @@ out:
cli_out ("Peer detach failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -203,8 +202,7 @@ out:
cli_out ("Peer status failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index c3222547d..3f76b6150 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -104,9 +104,8 @@ out:
if ((sent == 0) && (parse_error == 0))
cli_out ("Getting Volume information failed!");
}
- frame->local = NULL;
- if (frame)
- STACK_DESTROY (frame->root);
+
+ CLI_STACK_DESTROY (frame);
return ret;
@@ -175,8 +174,8 @@ out:
if (dict)
dict_unref (dict);
- if (frame)
- STACK_DESTROY (frame->root);
+
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -404,8 +403,7 @@ out:
cli_out ("Volume create failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -458,8 +456,7 @@ out:
cli_out ("Volume delete failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -538,8 +535,7 @@ out:
cli_out ("Volume start failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -661,8 +657,7 @@ out:
if (dict)
dict_unref (dict);
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -720,8 +715,7 @@ out:
cli_out ("Volume rename on '%s' failed", (char *)words[2]);
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -814,8 +808,7 @@ out:
cli_out ("Volume rebalance failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -860,8 +853,7 @@ out:
cli_out ("Volume reset failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
@@ -907,8 +899,7 @@ out:
cli_out ("Volume profile failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
@@ -954,8 +945,7 @@ out:
cli_out ("Volume set failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
@@ -1019,8 +1009,7 @@ out:
cli_out ("Volume add-brick failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -1074,8 +1063,7 @@ out:
if (ret && parse_err == 0)
cli_out ("Quota command failed");
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
@@ -1136,8 +1124,7 @@ out:
if (options)
dict_unref (options);
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
@@ -1188,8 +1175,7 @@ out:
cli_out ("Volume replace-brick failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -1244,8 +1230,7 @@ out:
cli_out ("Volume top failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
@@ -1293,8 +1278,7 @@ out:
cli_out ("Volume log rotate failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -1398,8 +1382,7 @@ out:
if (ret && parse_err == 0)
cli_out (GEOREP" command failed");
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -1447,8 +1430,7 @@ cli_cmd_volume_status_cbk (struct cli_state *state,
if (dict)
dict_unref (dict);
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -1677,8 +1659,7 @@ out:
if (options)
dict_unref (options);
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -1732,8 +1713,7 @@ out:
cli_out ("Volume statedump failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -1763,8 +1743,7 @@ out:
cli_out ("Volume list failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
@@ -1820,8 +1799,7 @@ out:
cli_out ("Volume clear-locks failed");
}
- if (frame)
- STACK_DESTROY (frame->root);
+ CLI_STACK_DESTROY (frame);
return ret;
}
diff --git a/cli/src/cli-cmd.h b/cli/src/cli-cmd.h
index 82e0ff113..ba877e2c4 100644
--- a/cli/src/cli-cmd.h
+++ b/cli/src/cli-cmd.h
@@ -30,6 +30,19 @@
#include "cli.h"
#include "list.h"
+#define CLI_STACK_DESTROY(_frame) \
+ do { \
+ if (_frame) { \
+ if (_frame->local) { \
+ gf_log ("cli", GF_LOG_DEBUG, "frame->local " \
+ "is not NULL (%p)", _frame->local); \
+ cli_local_wipe (_frame->local); \
+ _frame->local = NULL; \
+ } \
+ STACK_DESTROY (_frame->root); \
+ } \
+ } while (0);
+
typedef enum {
GF_ANSWER_YES = 1,
GF_ANSWER_NO = 2
diff --git a/cli/src/cli.c b/cli/src/cli.c
index c638dc827..7a490fed2 100644
--- a/cli/src/cli.c
+++ b/cli/src/cli.c
@@ -543,6 +543,10 @@ void
cli_local_wipe (cli_local_t *local)
{
if (local) {
+ if (local->get_vol.volname)
+ GF_FREE (local->get_vol.volname);
+ if (local->dict)
+ dict_unref (local->dict);
GF_FREE (local);
}