FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Cluster Development

 
 
LinkBack Thread Tools
 
Old 12-10-2010, 08:00 AM
Dmitry Mishin
 
Default Unify 'del' functions

No need to keep 2 copies with almost the same logic inside - better to add if..
else clause.

Signed-off-by: Dmitry Mishin <dim@parallels.com>
---
config/tools/ccs_tool/ccs_tool.c | 2 +-
config/tools/ccs_tool/editconf.c | 68 ++-----------------------------------
config/tools/ccs_tool/editconf.h | 1 -
3 files changed, 5 insertions(+), 66 deletions(-)

diff --git a/config/tools/ccs_tool/ccs_tool.c b/config/tools/ccs_tool/ccs_tool.c
index 824da6d..12d447c 100644
--- a/config/tools/ccs_tool/ccs_tool.c
+++ b/config/tools/ccs_tool/ccs_tool.c
@@ -232,7 +232,7 @@ static int tool_main(int argc, char *argv[])
exit(EXIT_SUCCESS);
}
else if(!strcmp(argv[optind], "delservice")){
- del_service(argc-1, argv+1);
+ del_node(argc-1, argv+1);
exit(EXIT_SUCCESS);
}
else if(!strcmp(argv[optind], "addfence")){
diff --git a/config/tools/ccs_tool/editconf.c b/config/tools/ccs_tool/editconf.c
index b33f288..a4ef407 100644
--- a/config/tools/ccs_tool/editconf.c
+++ b/config/tools/ccs_tool/editconf.c
@@ -130,15 +130,6 @@ static void delnode_usage(const char *name)
exit(0);
}

-static void delservice_usage(const char *name)
-{
- fprintf(stderr, "Usage: %s %s [options] <name>
", prog_name, name);
- config_usage(1);
- help_usage();
-
- exit(0);
-}
-
static void addnodeid_usage(const char *name)
{
fprintf(stderr, "Add node IDs to all nodes in the config file that don't have them.
");
@@ -1067,7 +1058,10 @@ void del_node(int argc, char **argv)

increment_version(root_element);

- del_clusternode(root_element, &ninfo);
+ if (!strcmp(argv[0], "delnode"))
+ del_clusternode(root_element, &ninfo);
+ else if (!strcmp(argv[0], "delservice"))
+ del_clusterservice(root_element, &ninfo);

/* Write it out */
save_file(doc, &ninfo);
@@ -1240,60 +1234,6 @@ void add_service(int argc, char **argv)

}

-void del_service(int argc, char **argv)
-{
- struct option_info ninfo;
- int opt;
- xmlDoc *doc;
- xmlNode *root_element;
-
- memset(&ninfo, 0, sizeof(ninfo));
- ninfo.tell_ccsd = 1;
-
- while ( (opt = getopt_long(argc, argv, "o:c:CFh?", delservice_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
-
- case 'o':
- ninfo.outputfile = strdup(optarg);
- break;
-
- case 'C':
- ninfo.tell_ccsd = 0;
- break;
-
- case 'F':
- ninfo.force_ccsd = 1;
- break;
-
- case '?':
- default:
- delservice_usage(argv[0]);
- }
- }
-
- /* Get service name parameter */
- if (optind < argc)
- ninfo.name = strdup(argv[optind]);
- else
- delservice_usage(argv[0]);
-
- doc = open_configfile(&ninfo);
-
- root_element = xmlDocGetRootElement(doc);
-
- increment_version(root_element);
-
- del_clusterservice(root_element, &ninfo);
-
- /* Write it out */
- save_file(doc, &ninfo);
-}
-
void list_services(int argc, char **argv)
{
xmlNode *cur_service;
diff --git a/config/tools/ccs_tool/editconf.h b/config/tools/ccs_tool/editconf.h
index be8945e..0090ab6 100644
--- a/config/tools/ccs_tool/editconf.h
+++ b/config/tools/ccs_tool/editconf.h
@@ -3,7 +3,6 @@ void add_nodeids(int argc, char **argv);
void add_service(int argc, char **argv);
void add_fence(int argc, char **argv);
void del_node(int argc, char **argv);
-void del_service(int argc, char **argv);
void del_fence(int argc, char **argv);
void list_nodes(int argc, char **argv);
void list_services(int argc, char **argv);
--
1.7.1
 
Old 12-10-2010, 12:42 PM
Dmitry Mishin
 
Default Unify 'del' functions

No need to keep 2 copies with almost the same logic inside - better to add if..
else clause.

Signed-off-by: Dmitry Mishin <dim@parallels.com>
---
config/tools/ccs_tool/ccs_tool.c | 2 +-
config/tools/ccs_tool/editconf.c | 59 ++-----------------------------------
config/tools/ccs_tool/editconf.h | 1 -
3 files changed, 5 insertions(+), 57 deletions(-)

diff --git a/config/tools/ccs_tool/ccs_tool.c b/config/tools/ccs_tool/ccs_tool.c
index 2fe6f78..8062549 100644
--- a/config/tools/ccs_tool/ccs_tool.c
+++ b/config/tools/ccs_tool/ccs_tool.c
@@ -230,7 +230,7 @@ static int tool_main(int argc, char *argv[])
exit(EXIT_SUCCESS);
}
else if(!strcmp(argv[optind], "delservice")){
- del_service(argc-1, argv+1);
+ del_node(argc-1, argv+1);
exit(EXIT_SUCCESS);
}
else if(!strcmp(argv[optind], "addfence")){
diff --git a/config/tools/ccs_tool/editconf.c b/config/tools/ccs_tool/editconf.c
index d63dc37..d68f395 100644
--- a/config/tools/ccs_tool/editconf.c
+++ b/config/tools/ccs_tool/editconf.c
@@ -128,15 +128,6 @@ static void delnode_usage(const char *name)
exit(0);
}

-static void delservice_usage(const char *name)
-{
- fprintf(stderr, "Usage: %s %s [options] <name>
", prog_name, name);
- config_usage(1);
- help_usage();
-
- exit(0);
-}
-
static void addnodeid_usage(const char *name)
{
fprintf(stderr, "Add node IDs to all nodes in the config file that don't have them.
");
@@ -1045,7 +1036,10 @@ void del_node(int argc, char **argv)

increment_version(root_element);

- del_clusternode(root_element, &ninfo);
+ if (!strcmp(argv[0], "delnode"))
+ del_clusternode(root_element, &ninfo);
+ else if (!strcmp(argv[0], "delservice"))
+ del_clusterservice(root_element, &ninfo);

/* Write it out */
save_file(doc, &ninfo);
@@ -1209,51 +1203,6 @@ void add_service(int argc, char **argv)

}

-void del_service(int argc, char **argv)
-{
- struct option_info ninfo;
- int opt;
- xmlDoc *doc;
- xmlNode *root_element;
-
- memset(&ninfo, 0, sizeof(ninfo));
-
- while ( (opt = getopt_long(argc, argv, "o:c:CFh?", delservice_options, NULL)) != EOF)
- {
- switch(opt)
- {
- case 'c':
- ninfo.configfile = strdup(optarg);
- break;
-
- case 'o':
- ninfo.outputfile = strdup(optarg);
- break;
-
- case '?':
- default:
- delservice_usage(argv[0]);
- }
- }
-
- /* Get service name parameter */
- if (optind < argc)
- ninfo.name = strdup(argv[optind]);
- else
- delservice_usage(argv[0]);
-
- doc = open_configfile(&ninfo);
-
- root_element = xmlDocGetRootElement(doc);
-
- increment_version(root_element);
-
- del_clusterservice(root_element, &ninfo);
-
- /* Write it out */
- save_file(doc, &ninfo);
-}
-
void list_services(int argc, char **argv)
{
xmlNode *cur_service;
diff --git a/config/tools/ccs_tool/editconf.h b/config/tools/ccs_tool/editconf.h
index be8945e..0090ab6 100644
--- a/config/tools/ccs_tool/editconf.h
+++ b/config/tools/ccs_tool/editconf.h
@@ -3,7 +3,6 @@ void add_nodeids(int argc, char **argv);
void add_service(int argc, char **argv);
void add_fence(int argc, char **argv);
void del_node(int argc, char **argv);
-void del_service(int argc, char **argv);
void del_fence(int argc, char **argv);
void list_nodes(int argc, char **argv);
void list_services(int argc, char **argv);
--
1.7.1
 

Thread Tools




All times are GMT. The time now is 03:28 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org