Skip to content

Commit 1c3e66e

Browse files
committed
This commit improve the warning message at pgxc_ctl make using gcc 4.8.
1 parent 01238ae commit 1c3e66e

File tree

8 files changed

+26
-16
lines changed

8 files changed

+26
-16
lines changed

contrib/pgxc_ctl/bash_handler.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ install_pgxc_ctl_bash(char *path)
3535
if (!pgxc_ctl_bash)
3636
{
3737
elog(ERROR, "ERROR: Could not open pgxc_ctl bash script, %s, %s\n", path, strerror(errno));
38+
return;
3839
}
3940
for (i=0; pgxc_ctl_conf_prototype[i]; i++)
4041
fprintf(pgxc_ctl_bash, "%s\n", pgxc_ctl_conf_prototype[i]);
4142
for (i=0; pgxc_ctl_bash_script[i]; i++)
4243
fprintf(pgxc_ctl_bash, "%s\n", pgxc_ctl_bash_script[i]);
4344
fclose(pgxc_ctl_bash);
4445
sprintf(cmd, "chmod +x %s", path);
45-
system(cmd);
46+
if (system(cmd) == -1)
47+
elog(ERROR, "ERROR: system() function returned error, %s\n", strerror(errno));
4648
}
4749

4850
/*

contrib/pgxc_ctl/config.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,8 @@ install_conf_prototype(char *path)
226226
fprintf(pgxc_config_proto, "%s\n", pgxc_ctl_conf_prototype[i]);
227227
fclose(pgxc_config_proto);
228228
snprintf(cmd, MAXPATH, "chmod +x %s", path);
229-
system(cmd);
229+
if (system(cmd) == -1)
230+
elog(ERROR, "ERROR: system() function error, %s\n", strerror(errno));
230231
}
231232

232233
/*

contrib/pgxc_ctl/datanode_cmd.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,9 @@ failover_oneDatanode(int datanodeIdx)
841841
#endif
842842
"select pgxc_pool_reload();\n"
843843
"\\q\n",
844+
#if 0
844845
aval(VAR_datanodeNames)[datanodeIdx],
846+
#endif
845847
aval(VAR_datanodeNames)[datanodeIdx], aval(VAR_datanodeMasterServers)[datanodeIdx], aval(VAR_datanodePorts)[datanodeIdx]);
846848
fclose(f);
847849
}

contrib/pgxc_ctl/do_command.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1979,8 +1979,7 @@ do_clean_command(char *line)
19791979
} while(GetToken());
19801980
if (cmdList)
19811981
{
1982-
int rc;
1983-
rc = doCmdList(cmdList);
1982+
doCmdList(cmdList);
19841983
cleanCmdList(cmdList);
19851984
elog(INFO, "Done.\n");
19861985
}

contrib/pgxc_ctl/do_shell.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,8 @@ appendCmdEl(cmd_t *src, cmd_t *new)
528528
{
529529
cmd_t *curr;
530530

531-
for(curr = src; src->next; src = src->next);
532-
src->next = new;
531+
for(curr = src; curr->next; curr = curr->next);
532+
curr->next = new;
533533
}
534534

535535
void

contrib/pgxc_ctl/monitor.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ void
286286
do_monitor_command(char *line)
287287
{
288288
char *token;
289-
int rc = 0;
290289

291290
if (!GetToken())
292291
{
@@ -309,10 +308,10 @@ do_monitor_command(char *line)
309308
if (isVarYes(VAR_gtmSlave))
310309
monitor_gtm_slave();
311310
else
312-
elog(ERROR, "ERROR: gtm slave is not configured.\n"), rc=-1;
311+
elog(ERROR, "ERROR: gtm slave is not configured.\n");
313312
}
314313
else
315-
elog(ERROR, "Invalid monitor gtm command option.\n"), rc=-1;
314+
elog(ERROR, "Invalid monitor gtm command option.\n");
316315
return;
317316
}
318317
else if (TestToken("gtm_proxy"))
@@ -356,7 +355,7 @@ do_monitor_command(char *line)
356355
else if (TestToken("slave"))
357356
{
358357
if (!isVarYes(VAR_coordSlave))
359-
elog(ERROR, "ERROR: coordinator slave is not configured.\n"), rc = -1;
358+
elog(ERROR, "ERROR: coordinator slave is not configured.\n");
360359
else
361360
if (!GetToken() || TestToken("all"))
362361
monitor_coordinator_slave(aval(VAR_coordNames));
@@ -405,7 +404,7 @@ do_monitor_command(char *line)
405404
else if (TestToken("slave"))
406405
{
407406
if (!isVarYes(VAR_coordSlave))
408-
elog(ERROR, "ERROR: datanode slave is not configured.\n"), rc = -1;
407+
elog(ERROR, "ERROR: datanode slave is not configured.\n");
409408
else
410409
if (!GetToken() || TestToken("all"))
411410
monitor_datanode_slave(aval(VAR_coordNames));

contrib/pgxc_ctl/pgxc_ctl.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@ build_pgxc_ctl_home(char *home)
168168
}
169169
}
170170
snprintf(cmd, MAXLINE, "mkdir -p %s", pgxc_ctl_home);
171-
system(cmd);
171+
if (system(cmd) == -1)
172+
{
173+
fprintf(stderr, "ERROR: system() function error, %s\n", strerror(errno));
174+
return;
175+
}
172176
if (stat(pgxc_ctl_home, &buf) ==0)
173177
{
174178
if (S_ISDIR(buf.st_mode))
@@ -285,7 +289,8 @@ pgxcCtlMkdir(char *path)
285289
char cmd[MAXPATH+1];
286290

287291
snprintf(cmd, MAXPATH, "mkdir -p %s", path);
288-
system(cmd);
292+
if (system(cmd) == -1)
293+
elog(ERROR, "ERROR: system() function error, %s\n", strerror(errno));
289294
}
290295

291296
static void
@@ -521,6 +526,8 @@ main(int argc, char *argv[])
521526
reset_var_val(VAR_logDir, logdir);
522527
if (logfile)
523528
reset_var_val(VAR_logFile, logfile);
529+
if (verbose)
530+
reset_var_val(VAR_verbose, verbose);
524531
startLog(sval(VAR_logDir), sval(VAR_logFile));
525532
prepare_pgxc_ctl_bash(pgxc_ctl_bash_path);
526533
build_configuration_path(configuration);

contrib/pgxc_ctl/utils.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,12 @@ get_prog_pid(char *host, char *progname, char *dir)
298298
"\"ps -f -C %s | grep %s\"",
299299
sval(VAR_pgxcUser), host, progname, dir);
300300
wkf = popen(cmd, "r");
301-
if (wkf == NULL)
301+
if ((wkf == NULL) || (fgets(pid_s, MAXLINE, wkf) != pid_s))
302302
{
303303
elog(ERROR, "ERROR: cannot obtain pid value of the remote postmaster, host \"%s\" dir \"%s\", %s\n",
304304
host, dir, strerror(errno));
305305
return(-1);
306306
}
307-
fgets(pid_s, MAXLINE, wkf);
308307
fclose(wkf);
309308
/* Get the second token */
310309
line = pid_s;
@@ -404,7 +403,8 @@ getIpAddress(char *hostName)
404403
return NULL;
405404
}
406405
ipAddr = Malloc(MAXTOKEN+1);
407-
fgets(ipAddr, MAXTOKEN, f);
406+
if (fgets(ipAddr, MAXTOKEN, f) != ipAddr)
407+
ipAddr[0] = '\0';
408408
fclose(f);
409409
trimNl(ipAddr);
410410
return ipAddr;

0 commit comments

Comments
 (0)