Skip to content

Commit bb78e69

Browse files
committed
Refactoring to change as many functions as static and to improve
source format.
1 parent 8c7c4d9 commit bb78e69

File tree

16 files changed

+692
-360
lines changed

16 files changed

+692
-360
lines changed

contrib/pgxc_ctl/bash_handler.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ extern char *pgxc_ctl_conf_prototype[];
2424
/*
2525
* Install bash script.
2626
*/
27-
void install_pgxc_ctl_bash(char *path)
27+
void
28+
install_pgxc_ctl_bash(char *path)
2829
{
2930
char cmd[1024];
3031
FILE *pgxc_ctl_bash = fopen(path, "w");
@@ -61,7 +62,8 @@ void uninstall_pgxc_ctl_bash(char *path)
6162
* typically $HOME/pgxc_ctl, which can be changed with pgxc_ctl options.
6263
* See pgxc_ctl.c or pgxc_ctl document for details.
6364
*/
64-
void read_config_file(char *path, char *conf)
65+
void
66+
read_config_file(char *path, char *conf)
6567
{
6668
FILE *vars;
6769
char cmd[1024];

contrib/pgxc_ctl/config.c

Lines changed: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ enum Quote { UNQUOTED, SINGLEQUOTED, DOUBLEQUOTED };
6161
/*
6262
* Get a token from the line
6363
*/
64-
char *get_word(char *line, char **token)
64+
char *
65+
get_word(char *line, char **token)
6566
{
6667
enum Quote quoted = UNQUOTED;
6768

@@ -129,7 +130,8 @@ char *get_word(char *line, char **token)
129130
/*
130131
* Parse line and create/update a variable.
131132
*/
132-
static void parse_line(char *line)
133+
static void
134+
parse_line(char *line)
133135
{
134136
char *varname;
135137
char *val;
@@ -155,7 +157,8 @@ static void parse_line(char *line)
155157
*
156158
* This blocks any unknow variables to be build within pgxc_ctl structure.
157159
*/
158-
static void parse_line_select(char *line, char *selectThis[])
160+
static void
161+
parse_line_select(char *line, char *selectThis[])
159162
{
160163
char *varname;
161164
char *val;
@@ -183,7 +186,8 @@ static void parse_line_select(char *line, char *selectThis[])
183186
/*
184187
* Configuration file I/F
185188
*/
186-
void read_vars(FILE *conf)
189+
void
190+
read_vars(FILE *conf)
187191
{
188192
char line[MAXLINE+1];
189193

@@ -194,7 +198,8 @@ void read_vars(FILE *conf)
194198
/*
195199
* Configuration file I/F
196200
*/
197-
void read_selected_vars(FILE *conf, char *selectThis[])
201+
void
202+
read_selected_vars(FILE *conf, char *selectThis[])
198203
{
199204
char line[MAXLINE+1];
200205

@@ -205,7 +210,8 @@ void read_selected_vars(FILE *conf, char *selectThis[])
205210
/*
206211
* Build the configuraiton file prototype.
207212
*/
208-
void install_conf_prototype(char *path)
213+
void
214+
install_conf_prototype(char *path)
209215
{
210216
char cmd[MAXPATH+1];
211217
FILE *pgxc_config_proto = fopen(path, "w");
@@ -226,7 +232,8 @@ void install_conf_prototype(char *path)
226232
/*
227233
* Get all the servers --> VAR_allServers
228234
*/
229-
static void addServer(char **name)
235+
static void
236+
addServer(char **name)
230237
{
231238
int ii, jj;
232239
int flag;
@@ -254,7 +261,8 @@ static void addServer(char **name)
254261
/*
255262
* Test each node and build target server list
256263
*/
257-
void makeServerList(void)
264+
void
265+
makeServerList(void)
258266
{
259267
/* Initialize */
260268
reset_var(VAR_allServers);
@@ -290,7 +298,8 @@ void makeServerList(void)
290298
*
291299
* Log archive backup will be implemented in the future.
292300
*/
293-
int is_none(char *s)
301+
int
302+
is_none(char *s)
294303
{
295304
if (strcmp(s, "none") == 0)
296305
return TRUE;
@@ -302,7 +311,8 @@ int is_none(char *s)
302311
/*
303312
* Remove gtm slave. Used at failover.
304313
*/
305-
static void emptyGtmSlave()
314+
static void
315+
emptyGtmSlave()
306316
{
307317
reset_var_val(VAR_gtmSlaveServer, "none");
308318
reset_var_val(VAR_gtmSlavePort, "0");
@@ -316,7 +326,8 @@ static void emptyGtmSlave()
316326
* We can just initialize gtm_proy using gtminit, configure and
317327
* run it.
318328
*/
319-
static void emptyGtmProxies()
329+
static void
330+
emptyGtmProxies()
320331
{
321332
int ii;
322333

@@ -342,7 +353,8 @@ static void emptyGtmProxies()
342353
* This is needed when a slave promotes and becomes a new
343354
* master.
344355
*/
345-
static void emptyCoordSlaves()
356+
static void
357+
emptyCoordSlaves()
346358
{
347359
int ii;
348360

@@ -361,7 +373,8 @@ static void emptyCoordSlaves()
361373
/*
362374
* Removes datanode slave from pgxc_ctl configuration.
363375
*/
364-
static void emptyDatanodeSlaves()
376+
static void
377+
emptyDatanodeSlaves()
365378
{
366379
int ii;
367380

@@ -389,7 +402,8 @@ static void emptyDatanodeSlaves()
389402
* Similar handling will be done for gtm slave, coordinator slaves
390403
* and datanode slaves.
391404
*/
392-
void handle_no_slaves()
405+
void
406+
handle_no_slaves()
393407
{
394408
int is_empty;
395409
int ii;
@@ -504,14 +518,16 @@ void handle_no_slaves()
504518
/*
505519
* Check if there's no overlap in the resource --> Port, host and directory.
506520
*/
507-
static void reportMissingVar(char *name)
521+
static void
522+
reportMissingVar(char *name)
508523
{
509524
elog(ERROR, "ERROR: %s is not configured.\n", name);
510525
}
511526

512527
static int anyConfigErrors = FALSE;
513528

514-
static void checkIfVarIsConfigured(char *name)
529+
static void
530+
checkIfVarIsConfigured(char *name)
515531
{
516532
if (!find_var(name) || !sval(name))
517533
{
@@ -520,14 +536,16 @@ static void checkIfVarIsConfigured(char *name)
520536
}
521537
}
522538

523-
static void checkIfConfigured(char *names[])
539+
static void
540+
checkIfConfigured(char *names[])
524541
{
525542
int ii;
526543
for(ii = 0; names[ii]; ii++)
527544
checkIfVarIsConfigured(names[ii]);
528545
}
529546

530-
static void checkConfiguredAndSize(char *names[], char *msg)
547+
static void
548+
checkConfiguredAndSize(char *names[], char *msg)
531549
{
532550
int ii;
533551
int sz0;
@@ -548,7 +566,8 @@ static void checkConfiguredAndSize(char *names[], char *msg)
548566
}
549567
}
550568

551-
int checkSpecificResourceConflict(char *name, char *host, int port, char *dir, int is_gtm)
569+
int
570+
checkSpecificResourceConflict(char *name, char *host, int port, char *dir, int is_gtm)
552571
{
553572
if (checkNameConflict(name, is_gtm))
554573
return 1;
@@ -561,7 +580,8 @@ int checkSpecificResourceConflict(char *name, char *host, int port, char *dir, i
561580
/*
562581
* Note that 1 will be returned when a conflict is found
563582
*/
564-
int checkNameConflict(char *name, int is_gtm)
583+
int
584+
checkNameConflict(char *name, int is_gtm)
565585
{
566586
int ii;
567587

@@ -595,7 +615,8 @@ int checkNameConflict(char *name, int is_gtm)
595615
/*
596616
* Note that 1 will be returned when a conflict is found.
597617
*/
598-
int checkPortConflict(char *host, int port)
618+
int
619+
checkPortConflict(char *host, int port)
599620
{
600621
int ii;
601622

@@ -634,7 +655,8 @@ int checkPortConflict(char *host, int port)
634655
return 0;
635656
}
636657

637-
int checkDirConflict(char *host, char *dir)
658+
int
659+
checkDirConflict(char *host, char *dir)
638660
{
639661
int ii;
640662

@@ -681,9 +703,10 @@ int checkDirConflict(char *host, char *dir)
681703
*
682704
* 3) A directory, in a given host, must be owned (used) only by single node.
683705
*/
684-
static void checkResourceConflict(char *srcNames, char *srcServers, char *srcPorts, char *srcPoolers, char *srcDirs,
685-
char *destNames, char *destServers, char *destPorts, char *destPoolers, char *destDirs,
686-
int destOnly, int checkName)
706+
static void
707+
checkResourceConflict(char *srcNames, char *srcServers, char *srcPorts, char *srcPoolers, char *srcDirs,
708+
char *destNames, char *destServers, char *destPorts, char *destPoolers, char *destDirs,
709+
int destOnly, int checkName)
687710
{
688711
int ii, jj;
689712

@@ -809,7 +832,8 @@ static void checkResourceConflict(char *srcNames, char *srcServers, char *srcPor
809832
* Check if each node resource is configured properly
810833
* Again, finding an error will not make the program stop.
811834
*/
812-
static void verifyResource(void)
835+
static void
836+
verifyResource(void)
813837
{
814838
char *GtmVars[] = {VAR_gtmName,
815839
VAR_gtmMasterServer,
@@ -1036,7 +1060,8 @@ static void verifyResource(void)
10361060
/*
10371061
* Check if the minimum components are configured --- gtm master, coordinator master and datanode master.
10381062
*/
1039-
void check_configuration(void)
1063+
void
1064+
check_configuration(void)
10401065
{
10411066
/*
10421067
* See if mandatory configuration is defined. Will continue if error is detected
@@ -1061,7 +1086,8 @@ void check_configuration(void)
10611086
/*
10621087
* Backup configuration files to a remote site as specified.
10631088
*/
1064-
int backup_configuration(void)
1089+
int
1090+
backup_configuration(void)
10651091
{
10661092
if ((strcasecmp(sval(VAR_configBackup), "y") != 0) || is_none(sval(VAR_configBackupHost)) ||
10671093
is_none(sval(VAR_configBackupDir)) || is_none(sval(VAR_configBackupFile)))
@@ -1072,7 +1098,8 @@ int backup_configuration(void)
10721098
sval(VAR_configBackupDir), sval(VAR_configBackupFile)));
10731099
}
10741100

1075-
NodeType getNodeType(char *nodeName)
1101+
NodeType
1102+
getNodeType(char *nodeName)
10761103
{
10771104
int ii;
10781105

@@ -1099,7 +1126,8 @@ NodeType getNodeType(char *nodeName)
10991126

11001127
}
11011128

1102-
int getDefaultWalSender(int isCoord)
1129+
int
1130+
getDefaultWalSender(int isCoord)
11031131
{
11041132
int ii;
11051133

0 commit comments

Comments
 (0)