[sheepdog] [PATCH] dog/cluster: code optimize for confirmation of cluster_force_recover
Ruoyu
liangry at ucweb.com
Mon Apr 21 08:52:29 CEST 2014
reuse confirm() is better, no need to handle it from scratch.
Signed-off-by: Ruoyu <liangry at ucweb.com>
---
dog/cluster.c | 15 ++-------------
1 file changed, 2 insertions(+), 13 deletions(-)
diff --git a/dog/cluster.c b/dog/cluster.c
index 482a0a7..4af1e7c 100644
--- a/dog/cluster.c
+++ b/dog/cluster.c
@@ -427,21 +427,10 @@ static int cluster_force_recover(int argc, char **argv)
int ret;
struct sd_req hdr;
struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
- char str[123] = {'\0'};
struct sd_node nodes[SD_MAX_NODES];
- if (!cluster_cmd_data.force) {
- int i, l;
- printf(RECOVER_PRINT);
- ret = scanf("%s", str);
- if (ret < 0)
- return EXIT_SYSFAIL;
- l = strlen(str);
- for (i = 0; i < l; i++)
- str[i] = tolower(str[i]);
- if (strncmp(str, "yes", 3) != 0)
- return EXIT_SUCCESS;
- }
+ if (!cluster_cmd_data.force)
+ confirm(RECOVER_PRINT);
sd_init_req(&hdr, SD_OP_FORCE_RECOVER);
hdr.data_length = sizeof(nodes);
--
1.8.3.2
More information about the sheepdog
mailing list