trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject [1/2] trafficserver git commit: TS-3297: make config_parse_error usage safer
Date Tue, 10 Feb 2015 00:28:42 GMT
Repository: trafficserver
Updated Branches:
  refs/heads/master ce74235e3 -> 04fb2fdeb


TS-3297: make config_parse_error usage safer


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

Branch: refs/heads/master
Commit: 04fb2fdeb17c3af162ac9c3e4684224c03f9064f
Parents: f18e47a
Author: James Peach <jpeach@apache.org>
Authored: Mon Feb 9 15:56:20 2015 -0800
Committer: James Peach <jpeach@apache.org>
Committed: Mon Feb 9 16:28:34 2015 -0800

----------------------------------------------------------------------
 iocore/dns/SplitDNS.cc      |  2 +-
 lib/ts/MatcherUtils.h       |  9 +++++++--
 proxy/CacheControl.cc       |  2 +-
 proxy/ControlMatcher.cc     | 10 +++++-----
 proxy/ParentSelection.cc    |  2 +-
 proxy/congest/Congestion.cc |  2 +-
 6 files changed, 16 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/04fb2fde/iocore/dns/SplitDNS.cc
----------------------------------------------------------------------
diff --git a/iocore/dns/SplitDNS.cc b/iocore/dns/SplitDNS.cc
index 3e87a83..c0c9f79 100644
--- a/iocore/dns/SplitDNS.cc
+++ b/iocore/dns/SplitDNS.cc
@@ -536,7 +536,7 @@ SplitDNSRecord::Init(matcher_line * line_info)
     }
   }
 
-  return config_parse_error();
+  return config_parse_error::ok();
 }
 
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/04fb2fde/lib/ts/MatcherUtils.h
----------------------------------------------------------------------
diff --git a/lib/ts/MatcherUtils.h b/lib/ts/MatcherUtils.h
index 10c8cc1..7dc5d97 100644
--- a/lib/ts/MatcherUtils.h
+++ b/lib/ts/MatcherUtils.h
@@ -117,7 +117,9 @@ const char *parseConfigLine(char *line, matcher_line * p_line, const matcher_tag
 
 struct config_parse_error
 {
-  config_parse_error() {
+  // Wrapper to make a syntactically nice success value.
+  static config_parse_error ok() {
+    return config_parse_error();
   }
 
   config_parse_error(const config_parse_error& rhs) {
@@ -126,7 +128,7 @@ struct config_parse_error
     }
   }
 
-  config_parse_error(const char * fmt, ...) TS_PRINTFLIKE(2, 3);
+  explicit config_parse_error(const char * fmt, ...) TS_NONNULL(2) TS_PRINTFLIKE(2, 3);
 
   config_parse_error& operator=(const config_parse_error& rhs) {
     if (rhs.msg.get()) {
@@ -148,6 +150,9 @@ struct config_parse_error
   }
 
 private:
+  config_parse_error() {
+  }
+
   ats_scoped_str msg;
 };
 

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/04fb2fde/proxy/CacheControl.cc
----------------------------------------------------------------------
diff --git a/proxy/CacheControl.cc b/proxy/CacheControl.cc
index b655bd3..bc25b8d 100644
--- a/proxy/CacheControl.cc
+++ b/proxy/CacheControl.cc
@@ -376,7 +376,7 @@ CacheControlRecord::Init(matcher_line * line_info)
     }
   }
 
-  return NULL;
+  return config_parse_error::ok();
 }
 
 // void CacheControlRecord::UpdateMatch(CacheControlResult* result, RequestData* rdata)

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/04fb2fde/proxy/ControlMatcher.cc
----------------------------------------------------------------------
diff --git a/proxy/ControlMatcher.cc b/proxy/ControlMatcher.cc
index be01d05..591cee2 100644
--- a/proxy/ControlMatcher.cc
+++ b/proxy/ControlMatcher.cc
@@ -185,7 +185,7 @@ template<class Data, class Result> config_parse_error
 HostMatcher<Data, Result>::NewEntry(matcher_line * line_info)
 {
   Data *cur_d;
-  config_parse_error error;
+  config_parse_error error = config_parse_error::ok();
   char *match_data;
 
   // Make sure space has been allocated
@@ -293,7 +293,7 @@ UrlMatcher<Data, Result>::NewEntry(matcher_line * line_info)
   Data *cur_d;
   char *pattern;
   int *value;
-  config_parse_error error;
+  config_parse_error error = config_parse_error::ok();
 
   // Make sure space has been allocated
   ink_assert(num_el >= 0);
@@ -433,7 +433,7 @@ RegexMatcher<Data, Result>::NewEntry(matcher_line * line_info)
   char *pattern;
   const char *errptr;
   int erroffset;
-  config_parse_error error;
+  config_parse_error error = config_parse_error::ok();
 
   // Make sure space has been allocated
   ink_assert(num_el >= 0);
@@ -617,7 +617,7 @@ IpMatcher<Data, Result>::NewEntry(matcher_line * line_info)
   const char *errptr;
   char *match_data;
   IpEndpoint addr1, addr2;
-  config_parse_error error;
+  config_parse_error error = config_parse_error::ok();
 
   // Make sure space has been allocated
   ink_assert(num_el >= 0);
@@ -901,7 +901,7 @@ ControlMatcher<Data, Result>::BuildTableFromString(char *file_buf)
   // Traverse the list and build the records table
   current = first;
   while (current != NULL) {
-    config_parse_error error;
+    config_parse_error error = config_parse_error::ok();
 
     second_pass++;
     if ((flags & ALLOW_HOST_TABLE) && current->type == MATCH_DOMAIN) {

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/04fb2fde/proxy/ParentSelection.cc
----------------------------------------------------------------------
diff --git a/proxy/ParentSelection.cc b/proxy/ParentSelection.cc
index c1dc646..86098d7 100644
--- a/proxy/ParentSelection.cc
+++ b/proxy/ParentSelection.cc
@@ -913,7 +913,7 @@ ParentRecord::Init(matcher_line * line_info)
     }
   }
 
-  return config_parse_error();
+  return config_parse_error::ok();
 }
 
 // void ParentRecord::UpdateMatch(ParentResult* result, RequestData* rdata);

http://git-wip-us.apache.org/repos/asf/trafficserver/blob/04fb2fde/proxy/congest/Congestion.cc
----------------------------------------------------------------------
diff --git a/proxy/congest/Congestion.cc b/proxy/congest/Congestion.cc
index 2b067a3..60baee6 100644
--- a/proxy/congest/Congestion.cc
+++ b/proxy/congest/Congestion.cc
@@ -171,7 +171,7 @@ CongestionControlRecord::validate()
   // max_connection == 0, no connection allow to the origin server for the rule
 #undef IsGt0
 
-  return config_parse_error();
+  return config_parse_error::ok();
 }
 
 config_parse_error


Mime
View raw message