You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2015/01/05 02:39:15 UTC

trafficserver git commit: Fix a bogus free, and change some prototypes to use reference arguments to make it clearer what the intent is.

Repository: trafficserver
Updated Branches:
  refs/heads/master aab46af56 -> 9b5fbe5dd


Fix a bogus free, and change some prototypes to use reference
arguments to make it clearer what the intent is.

Coverity CID #1022064


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/9b5fbe5d
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/9b5fbe5d
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/9b5fbe5d

Branch: refs/heads/master
Commit: 9b5fbe5dd75a721c505222958276f028ae51daf2
Parents: aab46af
Author: Leif Hedstrom <zw...@apache.org>
Authored: Sun Jan 4 18:38:22 2015 -0700
Committer: Leif Hedstrom <zw...@apache.org>
Committed: Sun Jan 4 18:38:22 2015 -0700

----------------------------------------------------------------------
 mgmt/api/INKMgmtAPI.cc     | 60 +++++++++++++++++++----------------------
 mgmt/api/include/mgmtapi.h |  2 +-
 2 files changed, 29 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9b5fbe5d/mgmt/api/INKMgmtAPI.cc
----------------------------------------------------------------------
diff --git a/mgmt/api/INKMgmtAPI.cc b/mgmt/api/INKMgmtAPI.cc
index ed40eba..4abeba1 100644
--- a/mgmt/api/INKMgmtAPI.cc
+++ b/mgmt/api/INKMgmtAPI.cc
@@ -43,7 +43,7 @@
 #include "TextBuffer.h"
 
 // forward declarations
-void init_pdss_format(TSPdSsFormat * info);
+void init_pdss_format(TSPdSsFormat& info);
 
 
 /***************************************************************************
@@ -667,21 +667,21 @@ TSIntListIsValid(TSIntList intl, int min, int max)
 
 // helper fn that sets default values for the info passed in
 void
-init_pdss_format(TSPdSsFormat * info)
-{
-  info->pd_type = TS_PD_UNDEFINED;
-  info->pd_val = NULL;
-  info->sec_spec.active = 0;
-  info->sec_spec.time.hour_a = 0;
-  info->sec_spec.time.min_a = 0;
-  info->sec_spec.time.hour_b = 0;
-  info->sec_spec.time.min_b = 0;
-  info->sec_spec.src_ip = TS_INVALID_IP_ADDR;
-  info->sec_spec.prefix = NULL;
-  info->sec_spec.suffix = NULL;
-  info->sec_spec.port = TS_INVALID_PORT;
-  info->sec_spec.method = TS_METHOD_UNDEFINED;
-  info->sec_spec.scheme = TS_SCHEME_UNDEFINED;
+init_pdss_format(TSPdSsFormat& info)
+{
+  info.pd_type = TS_PD_UNDEFINED;
+  info.pd_val = NULL;
+  info.sec_spec.active = 0;
+  info.sec_spec.time.hour_a = 0;
+  info.sec_spec.time.min_a = 0;
+  info.sec_spec.time.hour_b = 0;
+  info.sec_spec.time.min_b = 0;
+  info.sec_spec.src_ip = TS_INVALID_IP_ADDR;
+  info.sec_spec.prefix = NULL;
+  info.sec_spec.suffix = NULL;
+  info.sec_spec.port = TS_INVALID_PORT;
+  info.sec_spec.method = TS_METHOD_UNDEFINED;
+  info.sec_spec.scheme = TS_SCHEME_UNDEFINED;
 }
 
 /*--- allocate/deallocate operations --------------------------------------*/
@@ -856,18 +856,14 @@ TSPdSsFormatCreate(void)
 }
 
 tsapi void
-TSPdSsFormatDestroy(TSPdSsFormat * ele)
+TSPdSsFormatDestroy(TSPdSsFormat& ele)
 {
-  if (ele) {
-    ats_free(ele->pd_val);
-    ats_free(ele->sec_spec.src_ip);
-    ats_free(ele->sec_spec.prefix);
-    ats_free(ele->sec_spec.suffix);
-    if (ele->sec_spec.port)
-      TSPortEleDestroy(ele->sec_spec.port);
-    ats_free(ele);
-  }
-  return;
+  ats_free(ele.pd_val);
+  ats_free(ele.sec_spec.src_ip);
+  ats_free(ele.sec_spec.prefix);
+  ats_free(ele.sec_spec.suffix);
+  if (ele.sec_spec.port)
+    TSPortEleDestroy(ele.sec_spec.port);
 }
 
 /*-------------------------------------------------------------
@@ -893,7 +889,7 @@ TSCacheEleCreate(TSRuleTypeT type)
   /* set defaults */
   ele->cfg_ele.type = type;
   ele->cfg_ele.error = TS_ERR_OKAY;
-  init_pdss_format(&(ele->cache_info));
+  init_pdss_format(ele->cache_info);
   ele->time_period.d = 0;
   ele->time_period.h = 0;
   ele->time_period.m = 0;
@@ -906,7 +902,7 @@ tsapi void
 TSCacheEleDestroy(TSCacheEle * ele)
 {
   if (ele) {
-    TSPdSsFormatDestroy(&(ele->cache_info));
+    TSPdSsFormatDestroy(ele->cache_info);
     ats_free(ele);
   }
   return;
@@ -926,7 +922,7 @@ TSCongestionEleCreate()
   /* set defaults */
   ele->cfg_ele.type = TS_CONGESTION;
   ele->cfg_ele.error = TS_ERR_OKAY;
-  //init_pdss_format(&(ele->congestion_info));
+  //init_pdss_format(ele->congestion_info);
   ele->pd_type = TS_PD_UNDEFINED;
   ele->pd_val = NULL;
   ele->prefix = NULL;
@@ -1169,7 +1165,7 @@ TSParentProxyEleCreate(TSRuleTypeT type)
 
   ele->cfg_ele.type = type;
   ele->cfg_ele.error = TS_ERR_OKAY;
-  init_pdss_format(&(ele->parent_info));
+  init_pdss_format(ele->parent_info);
   ele->rr = TS_RR_NONE;
   ele->proxy_list = TS_INVALID_LIST;
   ele->direct = false;
@@ -1181,7 +1177,7 @@ tsapi void
 TSParentProxyEleDestroy(TSParentProxyEle * ele)
 {
   if (ele) {
-    TSPdSsFormatDestroy(&(ele->parent_info));
+    TSPdSsFormatDestroy(ele->parent_info);
     if (ele->proxy_list)
       TSDomainListDestroy(ele->proxy_list);
     ats_free(ele);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/9b5fbe5d/mgmt/api/include/mgmtapi.h
----------------------------------------------------------------------
diff --git a/mgmt/api/include/mgmtapi.h b/mgmt/api/include/mgmtapi.h
index d7790a5..b71a166 100644
--- a/mgmt/api/include/mgmtapi.h
+++ b/mgmt/api/include/mgmtapi.h
@@ -861,7 +861,7 @@ extern "C"
   tsapi TSSspec *TSSspecCreate();
   tsapi void TSSspecDestroy(TSSspec * ele);
   tsapi TSPdSsFormat *TSPdSsFormatCreate();
-  tsapi void TSPdSsFormatDestroy(TSPdSsFormat * ele);
+  tsapi void TSPdSsFormatDestroy(TSPdSsFormat& ele);
   tsapi TSCacheEle *TSCacheEleCreate(TSRuleTypeT type);
   tsapi void TSCacheEleDestroy(TSCacheEle * ele);
   tsapi TSCongestionEle *TSCongestionEleCreate();