HAWQ-473. fix coverity errors introduced by new codes

Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/c72d0662
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/c72d0662
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/c72d0662

Branch: refs/heads/HAWQ-459
Commit: c72d06629f28b00b430db0bfcc79422cfd25f814
Parents: 99a307b
Author: Wen Lin <[email protected]>
Authored: Tue Mar 15 14:55:37 2016 +0800
Committer: Wen Lin <[email protected]>
Committed: Tue Mar 15 14:55:37 2016 +0800

----------------------------------------------------------------------
 .../communication/rmcomm_RM2RMSEG.c             | 16 +++++---------
 src/backend/resourcemanager/requesthandler.c    |  8 +++----
 .../resourcebroker/resourcebroker_LIBYARN.c     |  8 +++----
 src/backend/resourcemanager/resourcemanager.c   | 12 +++++-----
 src/backend/resourcemanager/resourcepool.c      | 23 +++++++-------------
 5 files changed, 25 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/c72d0662/src/backend/resourcemanager/communication/rmcomm_RM2RMSEG.c
----------------------------------------------------------------------
diff --git a/src/backend/resourcemanager/communication/rmcomm_RM2RMSEG.c 
b/src/backend/resourcemanager/communication/rmcomm_RM2RMSEG.c
index ca332c9..7baab7d 100644
--- a/src/backend/resourcemanager/communication/rmcomm_RM2RMSEG.c
+++ b/src/backend/resourcemanager/communication/rmcomm_RM2RMSEG.c
@@ -243,11 +243,9 @@ void 
receivedRUAliveResponse(AsyncCommMessageHandlerContext  context,
                                add_segment_history_row(segres->Stat->ID + 
REGISTRATION_ORDER_OFFSET,
                                                                                
GET_SEGRESOURCE_HOSTNAME(segres),
                                                                                
description->Str);
-                               if (description != NULL)
-                               {
-                                       freeSimpleStringContent(description);
-                                       rm_pfree(PCONTEXT, description);
-                               }
+
+                               freeSimpleStringContent(description);
+                               rm_pfree(PCONTEXT, description);
                        }
                        /* Set the host down. */
                        elog(WARNING, "Resource manager sets host %s from up to 
down "
@@ -304,11 +302,9 @@ void sentRUAliveError(AsyncCommMessageHandlerContext 
context)
                        add_segment_history_row(segres->Stat->ID + 
REGISTRATION_ORDER_OFFSET,
                                                                        
GET_SEGRESOURCE_HOSTNAME(segres),
                                                                        
description->Str);
-                       if (description != NULL)
-                       {
-                               freeSimpleStringContent(description);
-                               rm_pfree(PCONTEXT, description);
-                       }
+
+                       freeSimpleStringContent(description);
+                       rm_pfree(PCONTEXT, description);
                }
                /* Set the host down. */
                elog(LOG, "Resource manager sets host %s from up to down "

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/c72d0662/src/backend/resourcemanager/requesthandler.c
----------------------------------------------------------------------
diff --git a/src/backend/resourcemanager/requesthandler.c 
b/src/backend/resourcemanager/requesthandler.c
index a06d169..694c9cd 100644
--- a/src/backend/resourcemanager/requesthandler.c
+++ b/src/backend/resourcemanager/requesthandler.c
@@ -1014,11 +1014,9 @@ bool handleRMRequestSegmentIsDown(void **arg)
                                                
add_segment_history_row(segres->Stat->ID + REGISTRATION_ORDER_OFFSET,
                                                                                
                hostname,
                                                                                
                description->Str);
-                                               if (description != NULL)
-                                               {
-                                                       
freeSimpleStringContent(description);
-                                                       rm_pfree(PCONTEXT, 
description);
-                                               }
+
+                                               
freeSimpleStringContent(description);
+                                               rm_pfree(PCONTEXT, description);
                                        }
 
                                        /* Set the host down. */

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/c72d0662/src/backend/resourcemanager/resourcebroker/resourcebroker_LIBYARN.c
----------------------------------------------------------------------
diff --git 
a/src/backend/resourcemanager/resourcebroker/resourcebroker_LIBYARN.c 
b/src/backend/resourcemanager/resourcebroker/resourcebroker_LIBYARN.c
index d446a6d..cdbe0d5 100644
--- a/src/backend/resourcemanager/resourcebroker/resourcebroker_LIBYARN.c
+++ b/src/backend/resourcemanager/resourcebroker/resourcebroker_LIBYARN.c
@@ -732,11 +732,9 @@ int handleRB2RM_ClusterReport(void)
                                                
GET_SEGRESOURCE_HOSTNAME(segres),
                                                SEGMENT_STATUS_DOWN,
                                                (description->Len > 
0)?description->Str:"");
-                       if (description != NULL)
-                       {
-                               freeSimpleStringContent(description);
-                               rm_pfree(PCONTEXT, description);
-                       }
+
+                       freeSimpleStringContent(description);
+                       rm_pfree(PCONTEXT, description);
                }
        }
        freePAIRRefList(&(PRESPOOL->Segments), &allsegres);

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/c72d0662/src/backend/resourcemanager/resourcemanager.c
----------------------------------------------------------------------
diff --git a/src/backend/resourcemanager/resourcemanager.c 
b/src/backend/resourcemanager/resourcemanager.c
index 138c5a0..cb1eecc 100644
--- a/src/backend/resourcemanager/resourcemanager.c
+++ b/src/backend/resourcemanager/resourcemanager.c
@@ -2557,9 +2557,9 @@ void updateStatusOfAllNodes()
        for(uint32_t idx = 0; idx < PRESPOOL->SegmentIDCounter; idx++)
        {
                node = getSegResource(idx);
+               Assert(node != NULL);
                uint8_t oldStatus = node->Stat->FTSAvailable;
-               if (node != NULL &&
-                        (curtime - node->LastUpdateTime >
+               if ( (curtime - node->LastUpdateTime >
                         1000000LL * rm_segment_heartbeat_timeout) &&
                         (node->Stat->StatusDesc & 
SEG_STATUS_HEARTBEAT_TIMEOUT) == 0)
                {
@@ -2591,11 +2591,9 @@ void updateStatusOfAllNodes()
                                add_segment_history_row(idx + 
REGISTRATION_ORDER_OFFSET,
                                                                                
GET_SEGRESOURCE_HOSTNAME(node),
                                                                                
(description->Len > 0)?description->Str:"");
-                               if (description != NULL)
-                               {
-                                       freeSimpleStringContent(description);
-                                       rm_pfree(PCONTEXT, description);
-                               }
+
+                               freeSimpleStringContent(description);
+                               rm_pfree(PCONTEXT, description);
                        }
 
                        elog(WARNING, "Resource manager sets host %s heartbeat 
timeout.",

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/c72d0662/src/backend/resourcemanager/resourcepool.c
----------------------------------------------------------------------
diff --git a/src/backend/resourcemanager/resourcepool.c 
b/src/backend/resourcemanager/resourcepool.c
index d3a01a4..ff5f34f 100644
--- a/src/backend/resourcemanager/resourcepool.c
+++ b/src/backend/resourcemanager/resourcepool.c
@@ -992,11 +992,8 @@ int addHAWQSegWithSegStat(SegStat segstat, bool 
*capstatchanged)
                                                                        
IS_SEGSTAT_FTSAVAILABLE(segresource->Stat) ?
                                                                                
SEG_STATUS_DESCRIPTION_UP:description->Str);
 
-                       if (description != NULL)
-                       {
-                               freeSimpleStringContent(description);
-                               rm_pfree(PCONTEXT, description);
-                       }
+                       freeSimpleStringContent(description);
+                       rm_pfree(PCONTEXT, description);
                }
 
                if (segresource->Stat->FTSAvailable == 
RESOURCE_SEG_STATUS_AVAILABLE)
@@ -1243,11 +1240,9 @@ int addHAWQSegWithSegStat(SegStat segstat, bool 
*capstatchanged)
                                                                                
GET_SEGRESOURCE_HOSTNAME(segresource),
                                                                                
IS_SEGSTAT_FTSAVAILABLE(segresource->Stat) ?
                                                                                
        SEG_STATUS_DESCRIPTION_UP:description->Str);
-                               if (description != NULL)
-                               {
-                                       freeSimpleStringContent(description);
-                                       rm_pfree(PCONTEXT, description);
-                               }
+
+                               freeSimpleStringContent(description);
+                               rm_pfree(PCONTEXT, description);
                        }
                }
 
@@ -1538,11 +1533,9 @@ int updateHAWQSegWithGRMSegStat( SegStat segstat)
                                        IS_SEGSTAT_FTSAVAILABLE(segres->Stat) ?
                                                
SEGMENT_STATUS_UP:SEGMENT_STATUS_DOWN,
                                        (description->Len > 
0)?description->Str:"");
-               if (description != NULL)
-               {
-                       freeSimpleStringContent(description);
-                       rm_pfree(PCONTEXT, description);
-               }
+
+               freeSimpleStringContent(description);
+               rm_pfree(PCONTEXT, description);
        }
 
        int32_t curratio = 0;

Reply via email to