You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by so...@apache.org on 2015/01/15 00:56:29 UTC
trafficserver git commit: TS-898: remove pointless NULL check on array
Repository: trafficserver
Updated Branches:
refs/heads/4.2.x 9e2a47291 -> 7cf27625b
TS-898: remove pointless NULL check on array
cl.origin_list is an array do the NULL check is pointless. Also
simplify the code around origiin set initialization so that the
origin set is always allocated. Coverity #1200013.
(cherry picked from commit b90a731d4e2d31fbb1e958bde76250a3994fb690)
Conflicts:
CHANGES
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/7cf27625
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/7cf27625
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/7cf27625
Branch: refs/heads/4.2.x
Commit: 7cf27625b2e04ff5422dd6b99452eaa58e628fad
Parents: 9e2a472
Author: James Peach <jp...@apache.org>
Authored: Sun Apr 13 17:00:18 2014 -0700
Committer: Phil Sorber <so...@apache.org>
Committed: Wed Jan 14 16:54:54 2015 -0700
----------------------------------------------------------------------
CHANGES | 2 ++
proxy/logstats.cc | 22 ++++++++--------------
2 files changed, 10 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7cf27625/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 2077ab0..6aefa99 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
-*- coding: utf-8 -*-
Changes with Apache Traffic Server 4.2.3
+ *) [TS-898] Remove pointless NULL check on address of array.
+
*) [TS-2959] Fix compiler issue for MultiCache.
Changes with Apache Traffic Server 4.2.2
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/7cf27625/proxy/logstats.cc
----------------------------------------------------------------------
diff --git a/proxy/logstats.cc b/proxy/logstats.cc
index 3d50ec7..e594551 100644
--- a/proxy/logstats.cc
+++ b/proxy/logstats.cc
@@ -1372,7 +1372,7 @@ parse_log_buff(LogBufferHeader * buf_header, bool summary = false)
// TODO: If we save state (struct) for a run, we probably need to always
// update the origin data, no matter what the origin_set is.
- if (origin_set ? (origin_set->find(tok) != origin_set->end()) : 1) {
+ if (origin_set->empty() || (origin_set->find(tok) != origin_set->end())) {
o_iter = origins.find(tok);
if (origins.end() == o_iter) {
o_stats = (OriginStats *)ats_malloc(sizeof(OriginStats));
@@ -2208,7 +2208,7 @@ my_exit(const ExitStatus& status)
}
// Next the totals for all Origins, unless we specified a list of origins to filter.
- if (!origin_set) {
+ if (origin_set->empty()) {
first = false;
if (cl.json) {
std::cout << "{ \"total\": {" << std::endl;
@@ -2303,7 +2303,7 @@ main(int /* argc ATS_UNUSED */, char *argv[])
memset(&totals, 0, sizeof(totals));
init_elapsed(&totals);
- origin_set = NULL;
+ origin_set = NEW(new OriginSet);
parse_errors = 0;
// Command line parsing
@@ -2328,13 +2328,9 @@ main(int /* argc ATS_UNUSED */, char *argv[])
char *tok;
char *sep_ptr;
- if (NULL == origin_set)
- origin_set = NEW(new OriginSet);
- if (cl.origin_list) {
- for (tok = strtok_r(cl.origin_list, ",", &sep_ptr); tok != NULL;) {
- origin_set->insert(tok);
- tok = strtok_r(NULL, ",", &sep_ptr);
- }
+ for (tok = strtok_r(cl.origin_list, ",", &sep_ptr); tok != NULL;) {
+ origin_set->insert(tok);
+ tok = strtok_r(NULL, ",", &sep_ptr);
}
}
// Load origins from an "external" file (\n separated)
@@ -2348,9 +2344,6 @@ main(int /* argc ATS_UNUSED */, char *argv[])
_exit(0);
}
- if (NULL == origin_set)
- origin_set = NEW(new OriginSet);
-
while (!fs.eof()) {
std::string line;
std::string::size_type start, end;
@@ -2366,8 +2359,9 @@ main(int /* argc ATS_UNUSED */, char *argv[])
char *buf;
buf = ats_strdup(line.substr(start, end).c_str());
- if (buf)
+ if (buf) {
origin_set->insert(buf);
+ }
}
}
}