Fix some more compiler warnings
authorPavan Deolasee <[email protected]>
Fri, 14 Sep 2018 05:29:48 +0000 (10:59 +0530)
committerPavan Deolasee <[email protected]>
Fri, 14 Sep 2018 05:29:48 +0000 (10:59 +0530)
src/backend/pgxc/locator/redistrib.c
src/backend/pgxc/pool/pgxcnode.c
src/backend/pgxc/squeue/squeue.c
src/backend/postmaster/clustermon.c
src/backend/tcop/pquery.c
src/bin/pgxc_ctl/bash_handler.c
src/bin/pgxc_ctl/do_command.c
src/bin/pgxc_ctl/do_shell.c
src/bin/pgxc_ctl/monitor.c
src/bin/pgxc_ctl/pgxc_ctl.c
src/bin/pgxc_ctl/utils.c

index 1a081b473013e6e78b2f785edf696362bfba35f0..8ba684af51c77a125edccc50c52c3c50add4a098 100644 (file)
@@ -377,6 +377,7 @@ distrib_execute_command(RedistribState *distribState, RedistribCommand *command)
                        break;
                case DISTRIB_NONE:
                default:
+                       command_str = "";       /* keep compiler quiet */
                        Assert(0); /* Should not happen */
        }
 
index 01d678dd2f0c6e67db224265e2de1fb883d8a468..d59e9cd7f790adc0ef6d5a260271b41a1cebdbe1 100644 (file)
@@ -2567,9 +2567,7 @@ Datum
 pgxc_node_str(PG_FUNCTION_ARGS)
 {
        Name            result;
-       int                     len;
 
-       len = strlen(PGXCNodeName);
        /* We use palloc0 here to ensure result is zero-padded */
        result = (Name) palloc0(NAMEDATALEN);
        memcpy(NameStr(*result), PGXCNodeName, NAMEDATALEN - 1);
index 2f782b92e893a81dd2d1139997739845635400ab..83fe258f9551171f618876269a21d8ac22042d62 100644 (file)
@@ -901,7 +901,7 @@ SharedQueueWrite(SharedQueue squeue, int consumerIdx,
                /* Create tuplestore if does not exist */
                if (*tuplestore == NULL)
                {
-                       int                     ptrno;
+                       int                     ptrno PG_USED_FOR_ASSERTS_ONLY;
                        char            storename[64];
 
 #ifdef SQUEUE_STAT
index 34f571c03bf3929c2dc948d660415f3b1014562e..fbe5a1b044c599c7cddfde057db1a8485fb5b8ca 100644 (file)
@@ -403,7 +403,6 @@ GlobalTransactionId
 ClusterMonitorGetGlobalXmin(bool invalid_ok)
 {
        GlobalTransactionId xmin = InvalidGlobalTransactionId;
-       int                                     retries = 0;
 
        SpinLockAcquire(&ClusterMonitorCtl->mutex);
        xmin = ClusterMonitorCtl->gtm_recent_global_xmin;
index b4fb4c992edc11d1412f8fd8087f79e42f80934f..4cae2a0bc742138ae820e262dcbaec9a0ddabab0 100644 (file)
@@ -2300,7 +2300,7 @@ AdvanceProducingPortal(Portal portal, bool can_wait)
                 */
                if (portal->holdStore == NULL && portal->status != PORTAL_FAILED)
                {
-                       int idx;
+                       int idx PG_USED_FOR_ASSERTS_ONLY;
                        char storename[64];
 
                        PortalCreateProducerStore(portal);
index c4aa1e27f18ebf884e5bf0746b13340811939867..b667436883322ea6dbca9ff31f48d54a9eb424b8 100644 (file)
@@ -29,6 +29,7 @@ void install_pgxc_ctl_bash(char *path, int read_prototype)
        char cmd[1024];
        FILE *pgxc_ctl_bash = fopen(path, "w");
        int i;
+       int rc;
 
        elog(NOTICE, "Installing pgxc_ctl_bash script as %s.\n", path);
        if (!pgxc_ctl_bash)
@@ -44,7 +45,9 @@ void install_pgxc_ctl_bash(char *path, int read_prototype)
                fprintf(pgxc_ctl_bash, "%s\n", pgxc_ctl_bash_script[i]);
        fclose(pgxc_ctl_bash);
        sprintf(cmd, "chmod +x %s", path);
-       system(cmd);
+       rc = system(cmd);
+       if (WEXITSTATUS(rc) != 0)
+               elog(ERROR, "failed to execute system command \"%s\"", cmd);
 }
 
 /*
index 6fed22c0cf35a2001f71736ec55a76d1850594da..16cda17d59e36bb1ba31e238fcbd70adf60163df 100644 (file)
@@ -2090,14 +2090,13 @@ static void do_clean_command(char *line)
                                        continue;
                        } 
                } while(GetToken());
+
                if (cmdList)
                {
-                       int rc;
-                       rc = doCmdList(cmdList);
+                       if (doCmdList(cmdList) != 0)
+                               elog(ERROR, "failed to execute command list");
                        cleanCmdList(cmdList);
-                       elog(INFO, "Done.\n");
                }
-       return;
        }
 }
 
index 5165ef3564ad241ecfdb34b000d83f123c7780e0..53951d4aa52b84e39878ff8a8f445733918a380e 100644 (file)
@@ -469,6 +469,7 @@ int doCmdList(cmdList_t *cmds)
                                {
                                        int pid;
                                        pid = waitpid(cmds->cmds[ii]->pid, &status, 0);
+                                       (void ) pid;    /* keep compiler quiet */
                                        rc = WEXITSTATUS(status);
                                }
                        }
@@ -522,9 +523,9 @@ int doCmdList(cmdList_t *cmds)
 
 void appendCmdEl(cmd_t *src, cmd_t *new)
 {
-       cmd_t *curr;
+       /* go to the end of the list */
+       for(; src->next; src = src->next);
 
-       for(curr = src; src->next; src = src->next);
        src->next = new;
 }
 
index f14c24bb4773ea59fffe69cf378dda46180d1f5a..02997c83224e5519c3e623187100643f12eba9e4 100644 (file)
@@ -279,7 +279,6 @@ static void monitor_something(char **nodeList)
 void do_monitor_command(char *line)
 {
        char *token;
-       int rc = 0;
 
        if (!GetToken())
        {
@@ -302,10 +301,10 @@ void do_monitor_command(char *line)
                        if (isVarYes(VAR_gtmSlave))
                                monitor_gtm_slave();
                        else
-                               elog(ERROR, "ERROR: gtm slave is not configured.\n"), rc=-1;
+                               elog(ERROR, "ERROR: gtm slave is not configured.\n");
                }
                else
-                       elog(ERROR, "Invalid monitor gtm command option.\n"), rc=-1;
+                       elog(ERROR, "Invalid monitor gtm command option.\n");
                return;
        }
        else if (TestToken("gtm_proxy"))
@@ -349,7 +348,7 @@ void do_monitor_command(char *line)
                else if (TestToken("slave"))
                {
                        if (!isVarYes(VAR_coordSlave))
-                               elog(ERROR, "ERROR: coordinator slave is not configured.\n"), rc = -1;
+                               elog(ERROR, "ERROR: coordinator slave is not configured.\n");
                        else
                                if (!GetToken() || TestToken("all"))
                                        monitor_coordinator_slave(aval(VAR_coordNames));
@@ -398,7 +397,7 @@ void do_monitor_command(char *line)
                else if (TestToken("slave"))
                {
                        if (!isVarYes(VAR_coordSlave))
-                               elog(ERROR, "ERROR: datanode slave is not configured.\n"), rc = -1;
+                               elog(ERROR, "ERROR: datanode slave is not configured.\n");
                        else
                                if (!GetToken() || TestToken("all"))
                                        monitor_datanode_slave(aval(VAR_coordNames));
index 81d732753d2b19cbd9be74d6e30c7a4f2165fa5f..d36fb4f2d92e1501fdd7630656fae18b1e44198d 100644 (file)
@@ -151,6 +151,7 @@ set_bash:
        {
                struct stat buf;
                char    cmd[MAXLINE+1];
+               int             rc;
                
                if (stat(pgxc_ctl_home, &buf) ==0)
                {
@@ -166,7 +167,14 @@ set_bash:
                        }
                }
                snprintf(cmd, MAXLINE, "mkdir -p %s", pgxc_ctl_home);
-               system(cmd);
+
+               rc = system(cmd);
+               if (WEXITSTATUS(rc) != 0)
+               {
+                       fprintf(stderr, "failed to execute system command \"%s\"", cmd);
+                       exit(1);
+               }
+
                if (stat(pgxc_ctl_home, &buf) ==0)
                {
                        if (S_ISDIR(buf.st_mode))
@@ -289,10 +297,16 @@ static void prepare_pgxc_ctl_bash(char *path)
 
 static void pgxcCtlMkdir(char *path)
 {
-       char cmd[MAXPATH+1];
+       char    cmd[MAXPATH+1];
+       int             rc;
 
        snprintf(cmd, MAXPATH, "mkdir -p %s", path);
-       system(cmd);
+       rc = system(cmd);
+       if (WEXITSTATUS(rc) != 0)
+       {
+               fprintf(stderr, "failed to execute system command \"%s\"", cmd);
+               exit(1);
+       }
 }
 
 static void startLog(char *path, char *logFileNam)
index 501e7f83ea91b90e427b207030753c50e3829249..4c8f7dd2b57d319a5a3c7129b518e535979b18d1 100644 (file)
@@ -397,8 +397,15 @@ char *getIpAddress(char *hostName)
                elog(ERROR, "ERROR: could not open the command, \"%s\", %s\n", command, strerror(errno));
                return NULL;
        }
+
        ipAddr = Malloc(MAXTOKEN+1);
-       fgets(ipAddr, MAXTOKEN, f);
+       if (fgets(ipAddr, MAXTOKEN, f) == NULL)
+       {
+               elog(ERROR, "could not get IP address from the command \"%s\"",
+                               command);
+               return NULL;
+       }
+
        pclose(f);
        trimNl(ipAddr);
        return ipAddr;