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 2013/10/27 22:36:48 UTC
[23/50] [abbrv] git commit: Fix g++ compiler warnings
Fix g++ compiler warnings
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/1f829e26
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/1f829e26
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/1f829e26
Branch: refs/heads/5.0.x
Commit: 1f829e268620ae0181c7542d6e7b253b71a40ddc
Parents: 64b5a6f
Author: Brian Geffon <br...@apache.org>
Authored: Mon Oct 21 11:54:36 2013 -0700
Committer: Brian Geffon <br...@apache.org>
Committed: Mon Oct 21 11:54:36 2013 -0700
----------------------------------------------------------------------
lib/atscppapi/src/AsyncHttpFetch.cc | 2 +-
lib/atscppapi/src/GlobalPlugin.cc | 3 ++-
lib/atscppapi/src/GzipDeflateTransformation.cc | 14 +++++++-------
lib/atscppapi/src/GzipInflateTransformation.cc | 4 ++--
lib/atscppapi/src/Headers.cc | 6 +++---
lib/atscppapi/src/Logger.cc | 6 ++++--
lib/atscppapi/src/TransformationPlugin.cc | 16 ++++++++--------
lib/atscppapi/src/utils_internal.cc | 4 +---
8 files changed, 28 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1f829e26/lib/atscppapi/src/AsyncHttpFetch.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/AsyncHttpFetch.cc b/lib/atscppapi/src/AsyncHttpFetch.cc
index 51ca95d..3fd798d 100644
--- a/lib/atscppapi/src/AsyncHttpFetch.cc
+++ b/lib/atscppapi/src/AsyncHttpFetch.cc
@@ -82,7 +82,7 @@ static int handleFetchEvents(TSCont cont, TSEvent event, void *edata) {
state->body_ = data_start; // data_start will now be pointing to body
state->body_size_ = data_end - data_start;
utils::internal::initResponse(state->response_, state->hdr_buf_, state->hdr_loc_);
- LOG_DEBUG("Fetch result had a status code of %d with a body length of %d", status, state->body_size_);
+ LOG_DEBUG("Fetch result had a status code of %d with a body length of %ld", status, state->body_size_);
} else {
LOG_ERROR("Unable to parse response; Request URL [%s]; transaction %p",
state->request_.getUrl().getUrlString().c_str(), txn);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1f829e26/lib/atscppapi/src/GlobalPlugin.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/GlobalPlugin.cc b/lib/atscppapi/src/GlobalPlugin.cc
index 40cd9e8..b2d8581 100644
--- a/lib/atscppapi/src/GlobalPlugin.cc
+++ b/lib/atscppapi/src/GlobalPlugin.cc
@@ -34,8 +34,9 @@ using namespace atscppapi;
*/
struct atscppapi::GlobalPluginState : noncopyable {
TSCont cont_;
- bool ignore_internal_transactions_;
GlobalPlugin *global_plugin_;
+ bool ignore_internal_transactions_;
+
GlobalPluginState(GlobalPlugin *global_plugin, bool ignore_internal_transactions)
: global_plugin_(global_plugin), ignore_internal_transactions_(ignore_internal_transactions) { }
};
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1f829e26/lib/atscppapi/src/GzipDeflateTransformation.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/GzipDeflateTransformation.cc b/lib/atscppapi/src/GzipDeflateTransformation.cc
index 5d701c8..40d0d94 100644
--- a/lib/atscppapi/src/GzipDeflateTransformation.cc
+++ b/lib/atscppapi/src/GzipDeflateTransformation.cc
@@ -43,8 +43,8 @@ const int ONE_KB = 1024;
struct atscppapi::transformations::GzipDeflateTransformationState: noncopyable {
z_stream z_stream_;
bool z_stream_initialized_;
- int64_t bytes_produced_;
TransformationPlugin::Type transformation_type_;
+ int64_t bytes_produced_;
GzipDeflateTransformationState(TransformationPlugin::Type type) :
z_stream_initialized_(false), transformation_type_(type), bytes_produced_(0) {
@@ -93,29 +93,29 @@ void GzipDeflateTransformation::consume(const string &data) {
// For small payloads the size can actually be greater than the original input
// so we'll use twice the original size to avoid needless repeated calls to deflate.
- unsigned long buffer_size = data.length() < ONE_KB ? 2 * ONE_KB : data.length();
+ unsigned long buffer_size = data.length() < static_cast<string::size_type>(ONE_KB ? 2 * ONE_KB : data.length());
vector<unsigned char> buffer(buffer_size);
do {
- LOG_DEBUG("Iteration %d: Deflate will compress %d bytes", ++iteration, data.size());
+ LOG_DEBUG("Iteration %d: Deflate will compress %ld bytes", ++iteration, data.size());
state_->z_stream_.avail_out = buffer_size;
state_->z_stream_.next_out = &buffer[0];
int err = deflate(&state_->z_stream_, Z_SYNC_FLUSH);
if (Z_OK != err) {
- LOG_ERROR("Iteration %d: Deflate failed to compress %d bytes with error code '%d'", iteration, data.size(), err);
+ LOG_ERROR("Iteration %d: Deflate failed to compress %ld bytes with error code '%d'", iteration, data.size(), err);
return;
}
int bytes_to_write = buffer_size - state_->z_stream_.avail_out;
state_->bytes_produced_ += bytes_to_write;
- LOG_DEBUG("Iteration %d: Deflate compressed %d bytes to %d bytes, producing output...", iteration, data.size(), bytes_to_write);
+ LOG_DEBUG("Iteration %d: Deflate compressed %ld bytes to %d bytes, producing output...", iteration, data.size(), bytes_to_write);
produce(string(reinterpret_cast<char *>(&buffer[0]), static_cast<size_t>(bytes_to_write)));
} while (state_->z_stream_.avail_out == 0);
if (state_->z_stream_.avail_in != 0) {
- LOG_ERROR("Inflate finished with data still remaining in the buffer of size '%d'", state_->z_stream_.avail_in);
+ LOG_ERROR("Inflate finished with data still remaining in the buffer of size '%u'", state_->z_stream_.avail_in);
}
}
@@ -148,7 +148,7 @@ void GzipDeflateTransformation::handleInputComplete() {
int64_t bytes_written = setOutputComplete();
if (state_->bytes_produced_ != bytes_written) {
- LOG_ERROR("Gzip bytes produced sanity check failed, deflated bytes = %d != written bytes = %d", state_->bytes_produced_, bytes_written);
+ LOG_ERROR("Gzip bytes produced sanity check failed, deflated bytes = %ld != written bytes = %ld", state_->bytes_produced_, bytes_written);
}
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1f829e26/lib/atscppapi/src/GzipInflateTransformation.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/GzipInflateTransformation.cc b/lib/atscppapi/src/GzipInflateTransformation.cc
index 931e6e8..1962e97 100644
--- a/lib/atscppapi/src/GzipInflateTransformation.cc
+++ b/lib/atscppapi/src/GzipInflateTransformation.cc
@@ -47,7 +47,7 @@ struct atscppapi::transformations::GzipInflateTransformationState: noncopyable {
TransformationPlugin::Type transformation_type_;
GzipInflateTransformationState(TransformationPlugin::Type type) :
- z_stream_initialized_(false), transformation_type_(type), bytes_produced_(0) {
+ z_stream_initialized_(false), bytes_produced_(0), transformation_type_(type) {
memset(&z_stream_, 0, sizeof(z_stream_));
@@ -122,7 +122,7 @@ void GzipInflateTransformation::consume(const string &data) {
void GzipInflateTransformation::handleInputComplete() {
int64_t bytes_written = setOutputComplete();
if (state_->bytes_produced_ != bytes_written) {
- LOG_ERROR("Gzip bytes produced sanity check failed, inflated bytes = %d != written bytes = %d", state_->bytes_produced_, bytes_written);
+ LOG_ERROR("Gzip bytes produced sanity check failed, inflated bytes = %ld != written bytes = %ld", state_->bytes_produced_, bytes_written);
}
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1f829e26/lib/atscppapi/src/Headers.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/Headers.cc b/lib/atscppapi/src/Headers.cc
index c4da326..0c07923 100644
--- a/lib/atscppapi/src/Headers.cc
+++ b/lib/atscppapi/src/Headers.cc
@@ -122,8 +122,8 @@ bool Headers::checkAndInitHeaders() const {
}
state_->name_values_map_.getValueRef().clear();
string key;
- const char *name, *value;
- int name_len, num_values, value_len;
+ const char *name;
+ int name_len;
pair<NameValuesMap::iterator, bool> insert_result;
TSMLoc field_loc = TSMimeHdrFieldGet(state_->hdr_buf_, state_->hdr_loc_, FIRST_INDEX);
while (field_loc) {
@@ -455,7 +455,7 @@ bool Headers::addCookie(const ResponseCookie &response_cookie) {
return false;
}
if (!checkAndInitHeaders()) {
- false;
+ return false;
}
// @TODO Do logic here
return true;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1f829e26/lib/atscppapi/src/Logger.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/Logger.cc b/lib/atscppapi/src/Logger.cc
index a7c18d5..c08202a 100644
--- a/lib/atscppapi/src/Logger.cc
+++ b/lib/atscppapi/src/Logger.cc
@@ -175,6 +175,8 @@ void Logger::flush() {
namespace {
const int DEFAULT_BUFFER_SIZE_FOR_VARARGS = 8*1024;
+// We use a macro here because varargs would be a pain to forward via a helper
+// function
#define TS_TEXT_LOG_OBJECT_WRITE(level) \
char buffer[DEFAULT_BUFFER_SIZE_FOR_VARARGS]; \
int n; \
@@ -183,11 +185,11 @@ const int DEFAULT_BUFFER_SIZE_FOR_VARARGS = 8*1024;
va_start(ap, fmt); \
n = vsnprintf (&buffer[0], sizeof(buffer), fmt, ap); \
va_end(ap); \
- if (n > -1 && n < sizeof(buffer)) { \
+ if (n > -1 && n < static_cast<int>(sizeof(buffer))) { \
LOG_DEBUG("logging a " level " to '%s' with length %d", state_->filename_.c_str(), n); \
TSTextLogObjectWrite(state_->text_log_obj_, const_cast<char*>("[" level "] %s"), buffer); \
} else { \
- LOG_ERROR("Unable to log " level " message to '%s' due to size exceeding %d bytes.", state_->filename_.c_str(), sizeof(buffer)); \
+ LOG_ERROR("Unable to log " level " message to '%s' due to size exceeding %lud bytes.", state_->filename_.c_str(), sizeof(buffer)); \
} \
return; \
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1f829e26/lib/atscppapi/src/TransformationPlugin.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/TransformationPlugin.cc b/lib/atscppapi/src/TransformationPlugin.cc
index 2fcb899..75a6706 100644
--- a/lib/atscppapi/src/TransformationPlugin.cc
+++ b/lib/atscppapi/src/TransformationPlugin.cc
@@ -91,7 +91,7 @@ int handleTransformationPluginRead(TSCont contp, TransformationPluginState *stat
TSVIO write_vio = TSVConnWriteVIOGet(contp);
if (write_vio) {
int64_t to_read = TSVIONTodoGet(write_vio);
- LOG_DEBUG("Transformation contp=%p write_vio=%p, to_read=%d", contp, write_vio, to_read);
+ LOG_DEBUG("Transformation contp=%p write_vio=%p, to_read=%ld", contp, write_vio, to_read);
if (to_read > 0) {
/*
@@ -99,11 +99,11 @@ int handleTransformationPluginRead(TSCont contp, TransformationPluginState *stat
* the amount of data actually in the read buffer.
**/
int64_t avail = TSIOBufferReaderAvail(TSVIOReaderGet(write_vio));
- LOG_DEBUG("Transformation contp=%p write_vio=%p, to_read=%d, buffer reader avail=%d", contp, write_vio, to_read, avail);
+ LOG_DEBUG("Transformation contp=%p write_vio=%p, to_read=%ld, buffer reader avail=%ld", contp, write_vio, to_read, avail);
if (to_read > avail) {
to_read = avail;
- LOG_DEBUG("Transformation contp=%p write_vio=%p, to read > avail, fixing to_read to be equal to avail. to_read=%d, buffer reader avail=%d", contp, write_vio, to_read, avail);
+ LOG_DEBUG("Transformation contp=%p write_vio=%p, to read > avail, fixing to_read to be equal to avail. to_read=%ld, buffer reader avail=%ld", contp, write_vio, to_read, avail);
}
if (to_read > 0) {
@@ -122,7 +122,7 @@ int handleTransformationPluginRead(TSCont contp, TransformationPluginState *stat
TSVIONDoneSet(write_vio, TSVIONDoneGet(write_vio) + to_read);
std::string in_data = utils::internal::consumeFromTSIOBufferReader(input_reader);
- LOG_DEBUG("Transformation contp=%p write_vio=%p consumed %d bytes from bufferreader", contp, write_vio, in_data.length());
+ LOG_DEBUG("Transformation contp=%p write_vio=%p consumed %ld bytes from bufferreader", contp, write_vio, in_data.length());
/* Clean up the buffer and reader */
TSIOBufferReaderFree(input_reader);
@@ -232,7 +232,7 @@ TransformationPlugin::~TransformationPlugin() {
}
size_t TransformationPlugin::produce(const std::string &data) {
- LOG_DEBUG("TransformationPlugin=%p tshttptxn=%p producing output with length=%d", this, state_->txn_, data.length());
+ LOG_DEBUG("TransformationPlugin=%p tshttptxn=%p producing output with length=%ld", this, state_->txn_, data.length());
int64_t write_length = static_cast<int64_t>(data.length());
if (!write_length) {
return 0;
@@ -261,11 +261,11 @@ size_t TransformationPlugin::produce(const std::string &data) {
// Finally we can copy this data into the output_buffer
int64_t bytes_written = TSIOBufferWrite(state_->output_buffer_, data.c_str(), write_length);
state_->bytes_written_ += bytes_written; // So we can set BytesDone on outputComplete().
- LOG_DEBUG("TransformationPlugin=%p tshttptxn=%p write to TSIOBuffer %d bytes total bytes written %d", this, state_->txn_, bytes_written, state_->bytes_written_);
+ LOG_DEBUG("TransformationPlugin=%p tshttptxn=%p write to TSIOBuffer %ld bytes total bytes written %ld", this, state_->txn_, bytes_written, state_->bytes_written_);
// Sanity Checks
if (bytes_written != write_length) {
- LOG_ERROR("TransformationPlugin=%p tshttptxn=%p bytes written < expected. bytes_written=%d write_length=%d", this, state_->txn_, bytes_written, write_length);
+ LOG_ERROR("TransformationPlugin=%p tshttptxn=%p bytes written < expected. bytes_written=%ld write_length=%ld", this, state_->txn_, bytes_written, write_length);
}
int connection_closed = TSVConnClosedGet(state_->vconn_);
@@ -282,7 +282,7 @@ size_t TransformationPlugin::produce(const std::string &data) {
size_t TransformationPlugin::setOutputComplete() {
int connection_closed = TSVConnClosedGet(state_->vconn_);
- LOG_DEBUG("OutputComplete TransformationPlugin=%p tshttptxn=%p vconn=%p connection_closed=%d, total bytes written=%d", this, state_->txn_, state_->vconn_, connection_closed,state_->bytes_written_);
+ LOG_DEBUG("OutputComplete TransformationPlugin=%p tshttptxn=%p vconn=%p connection_closed=%d, total bytes written=%ld", this, state_->txn_, state_->vconn_, connection_closed,state_->bytes_written_);
if (!connection_closed && !state_->output_vio_) {
LOG_DEBUG("TransformationPlugin=%p tshttptxn=%p output complete without writing any data, initiating write of 0 bytes.", this, state_->txn_);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/1f829e26/lib/atscppapi/src/utils_internal.cc
----------------------------------------------------------------------
diff --git a/lib/atscppapi/src/utils_internal.cc b/lib/atscppapi/src/utils_internal.cc
index b153a49..01920d2 100644
--- a/lib/atscppapi/src/utils_internal.cc
+++ b/lib/atscppapi/src/utils_internal.cc
@@ -50,8 +50,7 @@ int handleTransactionEvents(TSCont cont, TSEvent event, void *edata) {
Transaction &transaction = utils::internal::getTransaction(ats_txn_handle);
LOG_DEBUG("Got event %d on continuation %p for transaction (ats pointer %p, object %p)", event, cont,
ats_txn_handle, &transaction);
- TSMBuffer hdr_buf;
- TSMLoc hdr_loc;
+
switch (event) {
case TS_EVENT_HTTP_POST_REMAP:
transaction.getClientRequest().getUrl().reset();
@@ -170,7 +169,6 @@ TSHttpHookID utils::internal::convertInternalHookToTsHook(Plugin::HookType hookt
}
TSHttpHookID utils::internal::convertInternalTransformationTypeToTsHook(TransformationPlugin::Type type) {
- TSHttpHookID hook_id;
switch (type) {
case TransformationPlugin::RESPONSE_TRANSFORMATION:
return TS_HTTP_RESPONSE_TRANSFORM_HOOK;