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 2017/11/15 02:56:18 UTC
[trafficserver] 01/04: Use std::min and std::max globally
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit affaddfdcbcb0157920596edc840023fd21e8541
Author: Phil Sorber <so...@apache.org>
AuthorDate: Wed Sep 20 10:23:17 2017 -0600
Use std::min and std::max globally
(cherry picked from commit e638e7ddb6e1fd9a1e9faa16be3b87feb2be69a4)
---
example/thread-pool/psi.c | 1 +
iocore/cache/Cache.cc | 2 +-
iocore/cache/Store.cc | 2 +-
iocore/eventsystem/P_UnixSocketManager.h | 2 +-
iocore/net/NetVCTest.cc | 2 +-
iocore/net/P_InkBulkIO.h | 2 +-
iocore/net/UnixUDPNet.cc | 4 ++--
lib/records/RecHttp.cc | 2 +-
lib/ts/ink_defs.h | 27 ---------------------------
proxy/InkAPITestTool.cc | 4 ++--
proxy/PluginVC.cc | 12 ++++++------
proxy/hdrs/HTTP.cc | 2 ++
proxy/hdrs/HTTP.h | 2 +-
proxy/hdrs/HttpCompat.cc | 2 +-
proxy/hdrs/MIME.cc | 2 +-
proxy/http/HttpConfig.cc | 2 +-
proxy/http/HttpTransact.cc | 26 +++++++++++++-------------
proxy/http/HttpTransactHeaders.cc | 6 +++---
proxy/http/HttpTunnel.cc | 6 +++---
proxy/http2/HTTP2.cc | 2 +-
proxy/http2/Http2ConnectionState.cc | 18 +++++++++---------
tools/jtest/jtest.cc | 4 ++--
22 files changed, 54 insertions(+), 78 deletions(-)
diff --git a/example/thread-pool/psi.c b/example/thread-pool/psi.c
index 9702597..a690c03 100644
--- a/example/thread-pool/psi.c
+++ b/example/thread-pool/psi.c
@@ -49,6 +49,7 @@
#include <stdlib.h>
#include <limits.h>
#include <string.h>
+#include <sys/param.h>
#include "ts/ts.h"
#include "thread.h"
diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
index 9e4263e..e0b6339 100644
--- a/iocore/cache/Cache.cc
+++ b/iocore/cache/Cache.cc
@@ -3407,7 +3407,7 @@ HTTPInfo_v21::copy_and_upgrade_unmarshalled_to_v23(char *&dst, char *&src, size_
// Extra data is fragment table - set that if we have it.
if (n_frags) {
static size_t const IFT_SIZE = HTTPCacheAlt_v23::N_INTEGRAL_FRAG_OFFSETS * sizeof(FragOffset);
- size_t ift_actual = min(n_frags, HTTPCacheAlt_v23::N_INTEGRAL_FRAG_OFFSETS) * sizeof(FragOffset);
+ size_t ift_actual = std::min(n_frags, HTTPCacheAlt_v23::N_INTEGRAL_FRAG_OFFSETS) * sizeof(FragOffset);
if (length < (HTTP_ALT_MARSHAL_SIZE + n_frags * sizeof(FragOffset) - IFT_SIZE))
return false; // can't place fragment table.
diff --git a/iocore/cache/Store.cc b/iocore/cache/Store.cc
index e922d3b..06068ad 100644
--- a/iocore/cache/Store.cc
+++ b/iocore/cache/Store.cc
@@ -561,7 +561,7 @@ Span::init(const char *path, int64_t size)
// The actual size of a span always trumps the configured size.
if (size > 0 && this->size() != size) {
- int64_t newsz = MIN(size, this->size());
+ int64_t newsz = std::min(size, this->size());
Note("cache %s '%s' is %" PRId64 " bytes, but the configured size is %" PRId64 " bytes, using the minimum",
span_file_typename(sbuf.st_mode), path, this->size(), size);
diff --git a/iocore/eventsystem/P_UnixSocketManager.h b/iocore/eventsystem/P_UnixSocketManager.h
index b023a8d..b45f745 100644
--- a/iocore/eventsystem/P_UnixSocketManager.h
+++ b/iocore/eventsystem/P_UnixSocketManager.h
@@ -118,7 +118,7 @@ SocketManager::vector_io(int fd, struct iovec *vector, size_t count, int read_re
int64_t current_request_bytes;
for (n_vec = 0; n_vec < (int)count; n_vec += max_iovecs_per_request) {
- current_count = min(max_iovecs_per_request, ((int)(count - n_vec)));
+ current_count = std::min(max_iovecs_per_request, ((int)(count - n_vec)));
do {
// coverity[tainted_data_argument]
r = read_request ? ::readv(fd, &vector[n_vec], current_count) : ::writev(fd, &vector[n_vec], current_count);
diff --git a/iocore/net/NetVCTest.cc b/iocore/net/NetVCTest.cc
index 17401d5..07d7c6b 100644
--- a/iocore/net/NetVCTest.cc
+++ b/iocore/net/NetVCTest.cc
@@ -308,7 +308,7 @@ NetVCTest::write_handler(int event)
if (write_vio->ndone < bytes_to_send) {
int left_to_send = bytes_to_send - actual_bytes_sent;
ink_assert(left_to_send >= 0);
- int to_fill = MIN(left_to_send, write_bytes_to_add_per);
+ int to_fill = std::min(left_to_send, write_bytes_to_add_per);
actual_bytes_sent += fill_buffer(write_buffer, &write_seed, to_fill);
write_vio->reenable();
}
diff --git a/iocore/net/P_InkBulkIO.h b/iocore/net/P_InkBulkIO.h
index 46df82b..f24b95a 100644
--- a/iocore/net/P_InkBulkIO.h
+++ b/iocore/net/P_InkBulkIO.h
@@ -141,7 +141,7 @@ struct InkBulkIORequest {
*/
#define INKBIO_MAX_PKTS_PER_REQ_BLOCK \
((INKBIO_PKT_SIZE_WO_UDPHDR - (sizeof(struct InkBulkIORequest) + sizeof(struct InkBulkIOPkt))) / \
- MAX((sizeof(struct InkBulkIORequest)), (sizeof(struct InkBulkIOPkt))))
+ std::max((sizeof(struct InkBulkIORequest)), (sizeof(struct InkBulkIOPkt))))
/*
* Requests are just block-ids---the block id points to the inkbio-block
diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc
index da5a878..e9fadb1 100644
--- a/iocore/net/UnixUDPNet.cc
+++ b/iocore/net/UnixUDPNet.cc
@@ -668,10 +668,10 @@ UDPQueue::service(UDPNetHandler *nh)
// insert into our queue.
Debug("udp-send", "Adding %p", p);
if (p->conn->lastPktStartTime == 0) {
- pktSendStartTime = MAX(now, p->delivery_time);
+ pktSendStartTime = std::max(now, p->delivery_time);
} else {
pktSendTime = p->delivery_time;
- pktSendStartTime = MAX(MAX(now, pktSendTime), p->delivery_time);
+ pktSendStartTime = std::max(std::max(now, pktSendTime), p->delivery_time);
}
p->conn->lastPktStartTime = pktSendStartTime;
p->delivery_time = pktSendStartTime;
diff --git a/lib/records/RecHttp.cc b/lib/records/RecHttp.cc
index 29ea1fa..99f56b7 100644
--- a/lib/records/RecHttp.cc
+++ b/lib/records/RecHttp.cc
@@ -600,7 +600,7 @@ HttpProxyPort::print(char *out, size_t n)
}
}
- return min(zret, n);
+ return std::min(zret, n);
}
void
diff --git a/lib/ts/ink_defs.h b/lib/ts/ink_defs.h
index 0f80a81..f85589d 100644
--- a/lib/ts/ink_defs.h
+++ b/lib/ts/ink_defs.h
@@ -88,33 +88,6 @@ countof(const T (&)[N])
#define ABS(x) (((x) < 0) ? (-(x)) : (x))
#endif
-#ifndef MAX
-#define MAX(x, y) (((x) >= (y)) ? (x) : (y))
-#endif
-
-#ifndef MIN
-#define MIN(x, y) (((x) <= (y)) ? (x) : (y))
-#endif
-
-#ifdef __cplusplus
-// We can't use #define for min and max because it will conflict with
-// other declarations of min and max functions. This conflict
-// occurs with STL
-template <class T>
-T
-min(const T a, const T b)
-{
- return a < b ? a : b;
-}
-
-template <class T>
-T
-max(const T a, const T b)
-{
- return a > b ? a : b;
-}
-#endif
-
#define ATS_UNUSED __attribute__((unused))
#define ATS_WARN_IF_UNUSED __attribute__((warn_unused_result))
#define ATS_UNUSED_RETURN(x) \
diff --git a/proxy/InkAPITestTool.cc b/proxy/InkAPITestTool.cc
index dd814b1..fc3392a 100644
--- a/proxy/InkAPITestTool.cc
+++ b/proxy/InkAPITestTool.cc
@@ -667,7 +667,7 @@ synclient_txn_write_request(TSCont contp)
while (ntodo > 0) {
block = TSIOBufferStart(txn->req_buffer);
ptr_block = TSIOBufferBlockWriteStart(block, &avail);
- towrite = MIN(ntodo, avail);
+ towrite = std::min(ntodo, avail);
memcpy(ptr_block, txn->request + ndone, towrite);
TSIOBufferProduce(txn->req_buffer, towrite);
ntodo -= towrite;
@@ -962,7 +962,7 @@ synserver_txn_write_response(TSCont contp)
while (ntodo > 0) {
block = TSIOBufferStart(txn->resp_buffer);
ptr_block = TSIOBufferBlockWriteStart(block, &avail);
- towrite = MIN(ntodo, avail);
+ towrite = std::min(ntodo, avail);
memcpy(ptr_block, response + ndone, towrite);
TSIOBufferProduce(txn->resp_buffer, towrite);
ntodo -= towrite;
diff --git a/proxy/PluginVC.cc b/proxy/PluginVC.cc
index 7a377e7..e2e2217 100644
--- a/proxy/PluginVC.cc
+++ b/proxy/PluginVC.cc
@@ -432,7 +432,7 @@ PluginVC::transfer_bytes(MIOBuffer *transfer_to, IOBufferReader *transfer_from,
while (act_on > 0) {
int64_t block_read_avail = transfer_from->block_read_avail();
- int64_t to_move = MIN(act_on, block_read_avail);
+ int64_t to_move = std::min(act_on, block_read_avail);
int64_t moved = 0;
if (to_move <= 0) {
@@ -507,7 +507,7 @@ PluginVC::process_write_side(bool other_side_call)
IOBufferReader *reader = write_state.vio.get_reader();
int64_t bytes_avail = reader->read_avail();
- int64_t act_on = MIN(bytes_avail, ntodo);
+ int64_t act_on = std::min(bytes_avail, ntodo);
Debug("pvc", "[%u] %s: process_write_side; act_on %" PRId64 "", core_obj->id, PVC_TYPE, act_on);
@@ -532,7 +532,7 @@ PluginVC::process_write_side(bool other_side_call)
Debug("pvc", "[%u] %s: process_write_side no buffer space", core_obj->id, PVC_TYPE);
return;
}
- act_on = MIN(act_on, buf_space);
+ act_on = std::min(act_on, buf_space);
int64_t added = transfer_bytes(core_buffer, reader, act_on);
if (added < 0) {
@@ -625,7 +625,7 @@ PluginVC::process_read_side(bool other_side_call)
}
int64_t bytes_avail = core_reader->read_avail();
- int64_t act_on = MIN(bytes_avail, ntodo);
+ int64_t act_on = std::min(bytes_avail, ntodo);
Debug("pvc", "[%u] %s: process_read_side; act_on %" PRId64 "", core_obj->id, PVC_TYPE, act_on);
@@ -641,13 +641,13 @@ PluginVC::process_read_side(bool other_side_call)
MIOBuffer *output_buffer = read_state.vio.get_writer();
int64_t water_mark = output_buffer->water_mark;
- water_mark = MAX(water_mark, PVC_DEFAULT_MAX_BYTES);
+ water_mark = std::max(water_mark, static_cast<int64_t>(PVC_DEFAULT_MAX_BYTES));
int64_t buf_space = water_mark - output_buffer->max_read_avail();
if (buf_space <= 0) {
Debug("pvc", "[%u] %s: process_read_side no buffer space", core_obj->id, PVC_TYPE);
return;
}
- act_on = MIN(act_on, buf_space);
+ act_on = std::min(act_on, buf_space);
int64_t added = transfer_bytes(output_buffer, core_reader, act_on);
if (added <= 0) {
diff --git a/proxy/hdrs/HTTP.cc b/proxy/hdrs/HTTP.cc
index bf8aea3..c265e12 100644
--- a/proxy/hdrs/HTTP.cc
+++ b/proxy/hdrs/HTTP.cc
@@ -1816,6 +1816,8 @@ ClassAllocator<HTTPCacheAlt> httpCacheAltAllocator("httpCacheAltAllocator");
/*-------------------------------------------------------------------------
-------------------------------------------------------------------------*/
+int constexpr HTTPCacheAlt::N_INTEGRAL_FRAG_OFFSETS;
+
HTTPCacheAlt::HTTPCacheAlt()
: m_magic(CACHE_ALT_MAGIC_ALIVE),
m_writeable(1),
diff --git a/proxy/hdrs/HTTP.h b/proxy/hdrs/HTTP.h
index 251e3b9..3cd61a3 100644
--- a/proxy/hdrs/HTTP.h
+++ b/proxy/hdrs/HTTP.h
@@ -1353,7 +1353,7 @@ struct HTTPCacheAlt {
/// for the last fragment.
FragOffset *m_frag_offsets;
/// # of fragment offsets built in to object.
- static int const N_INTEGRAL_FRAG_OFFSETS = 4;
+ static int constexpr N_INTEGRAL_FRAG_OFFSETS = 4;
/// Integral fragment offset table.
FragOffset m_integral_frag_offsets[N_INTEGRAL_FRAG_OFFSETS];
diff --git a/proxy/hdrs/HttpCompat.cc b/proxy/hdrs/HttpCompat.cc
index 6f69758..89eaa63 100644
--- a/proxy/hdrs/HttpCompat.cc
+++ b/proxy/hdrs/HttpCompat.cc
@@ -851,7 +851,7 @@ HttpCompat::determine_set_by_language(RawHashTable *table_of_sets, StrList *acpt
// index, preferring values earlier in Accept-Language list. //
/////////////////////////////////////////////////////////////////
- Q = min(Ql, Qc);
+ Q = std::min(Ql, Qc);
//////////////////////////////////////////////////////////
// normally the Q for default pages should be slightly //
diff --git a/proxy/hdrs/MIME.cc b/proxy/hdrs/MIME.cc
index 418c34a..e2b0c1b 100644
--- a/proxy/hdrs/MIME.cc
+++ b/proxy/hdrs/MIME.cc
@@ -2802,7 +2802,7 @@ mime_mem_print(const char *src_d, int src_l, char *buf_start, int buf_length, in
}
}
- copy_l = min(buf_length - *buf_index_inout, src_l);
+ copy_l = std::min(buf_length - *buf_index_inout, src_l);
if (copy_l > 0) {
memcpy(buf_start + *buf_index_inout, src_d, copy_l);
*buf_index_inout += copy_l;
diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc
index 258d1d8..a7d3371 100644
--- a/proxy/http/HttpConfig.cc
+++ b/proxy/http/HttpConfig.cc
@@ -1304,7 +1304,7 @@ HttpConfig::reconfigure()
params->oride.cache_heuristic_min_lifetime = m_master.oride.cache_heuristic_min_lifetime;
params->oride.cache_heuristic_max_lifetime = m_master.oride.cache_heuristic_max_lifetime;
- params->oride.cache_heuristic_lm_factor = min(max(m_master.oride.cache_heuristic_lm_factor, 0.0f), 1.0f);
+ params->oride.cache_heuristic_lm_factor = std::min(std::max(m_master.oride.cache_heuristic_lm_factor, 0.0f), 1.0f);
params->oride.cache_guaranteed_min_lifetime = m_master.oride.cache_guaranteed_min_lifetime;
params->oride.cache_guaranteed_max_lifetime = m_master.oride.cache_guaranteed_max_lifetime;
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index c898fce..6109379 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -2411,8 +2411,8 @@ HttpTransact::HandleCacheOpenReadHitFreshness(State *s)
// for it. this is just to deal with the effects
// of the skew by setting minimum and maximum times
// so that ages are not negative, etc.
- s->request_sent_time = min(s->client_request_time, s->request_sent_time);
- s->response_received_time = min(s->client_request_time, s->response_received_time);
+ s->request_sent_time = std::min(s->client_request_time, s->request_sent_time);
+ s->response_received_time = std::min(s->client_request_time, s->response_received_time);
ink_assert(s->request_sent_time <= s->response_received_time);
@@ -4841,7 +4841,7 @@ HttpTransact::merge_and_update_headers_for_cache_update(State *s)
// If the cached response has an Age: we should update it
// We could use calculate_document_age but my guess is it's overkill
// Just use 'now' - 304's Date: + Age: (response's Age: if there)
- date_value = max(s->current.now - date_value, (ink_time_t)0);
+ date_value = std::max(s->current.now - date_value, (ink_time_t)0);
if (s->hdr_info.server_response.presence(MIME_PRESENCE_AGE)) {
time_t new_age = s->hdr_info.server_response.get_age();
@@ -7268,7 +7268,7 @@ HttpTransact::calculate_document_freshness_limit(State *s, HTTPHdr *response, ti
freshness_limit = (int)response->get_cooked_cc_max_age();
DebugTxn("http_match", "calculate_document_freshness_limit --- max_age set, freshness_limit = %d", freshness_limit);
}
- freshness_limit = min(max(0, freshness_limit), (int)s->txn_conf->cache_guaranteed_max_lifetime);
+ freshness_limit = std::min(std::max(0, freshness_limit), (int)s->txn_conf->cache_guaranteed_max_lifetime);
} else {
date_set = last_modified_set = false;
@@ -7305,7 +7305,7 @@ HttpTransact::calculate_document_freshness_limit(State *s, HTTPHdr *response, ti
DebugTxn("http_match", "calculate_document_freshness_limit --- Expires: %" PRId64 ", Date: %" PRId64 ", freshness_limit = %d",
(int64_t)expires_value, (int64_t)date_value, freshness_limit);
- freshness_limit = min(max(0, freshness_limit), (int)s->txn_conf->cache_guaranteed_max_lifetime);
+ freshness_limit = std::min(std::max(0, freshness_limit), (int)s->txn_conf->cache_guaranteed_max_lifetime);
} else {
last_modified_value = 0;
if (response->presence(MIME_PRESENCE_LAST_MODIFIED)) {
@@ -7329,7 +7329,7 @@ HttpTransact::calculate_document_freshness_limit(State *s, HTTPHdr *response, ti
ink_assert((f >= 0.0) && (f <= 1.0));
ink_time_t time_since_last_modify = date_value - last_modified_value;
int h_freshness = (int)(time_since_last_modify * f);
- freshness_limit = max(h_freshness, 0);
+ freshness_limit = std::max(h_freshness, 0);
DebugTxn("http_match", "calculate_document_freshness_limit --- heuristic: date=%" PRId64 ", lm=%" PRId64
", time_since_last_modify=%" PRId64 ", f=%g, freshness_limit = %d",
(int64_t)date_value, (int64_t)last_modified_value, (int64_t)time_since_last_modify, f, freshness_limit);
@@ -7341,13 +7341,13 @@ HttpTransact::calculate_document_freshness_limit(State *s, HTTPHdr *response, ti
}
// The freshness limit must always fall within the min and max guaranteed bounds.
- min_freshness_bounds = max((MgmtInt)0, s->txn_conf->cache_guaranteed_min_lifetime);
+ min_freshness_bounds = std::max((MgmtInt)0, s->txn_conf->cache_guaranteed_min_lifetime);
max_freshness_bounds = s->txn_conf->cache_guaranteed_max_lifetime;
// Heuristic freshness can be more strict.
if (*heuristic) {
- min_freshness_bounds = max(min_freshness_bounds, s->txn_conf->cache_heuristic_min_lifetime);
- max_freshness_bounds = min(max_freshness_bounds, s->txn_conf->cache_heuristic_max_lifetime);
+ min_freshness_bounds = std::max(min_freshness_bounds, s->txn_conf->cache_heuristic_min_lifetime);
+ max_freshness_bounds = std::min(max_freshness_bounds, s->txn_conf->cache_heuristic_max_lifetime);
}
// Now clip the freshness limit.
if (freshness_limit > max_freshness_bounds) {
@@ -7484,7 +7484,7 @@ HttpTransact::what_is_document_freshness(State *s, HTTPHdr *client_request, HTTP
if (current_age < 0) {
current_age = s->txn_conf->cache_guaranteed_max_lifetime;
} else {
- current_age = min((time_t)s->txn_conf->cache_guaranteed_max_lifetime, current_age);
+ current_age = std::min((time_t)s->txn_conf->cache_guaranteed_max_lifetime, current_age);
}
DebugTxn("http_match", "[what_is_document_freshness] fresh_limit: %d current_age: %" PRId64, fresh_limit, (int64_t)current_age);
@@ -7561,7 +7561,7 @@ HttpTransact::what_is_document_freshness(State *s, HTTPHdr *client_request, HTTP
// if min-fresh set, constrain the freshness limit //
/////////////////////////////////////////////////////
if (cooked_cc_mask & MIME_COOKED_MASK_CC_MIN_FRESH) {
- age_limit = min(age_limit, fresh_limit - client_request->get_cooked_cc_min_fresh());
+ age_limit = std::min(age_limit, fresh_limit - client_request->get_cooked_cc_min_fresh());
DebugTxn("http_match", "[..._document_freshness] min_fresh set, age limit: %d", age_limit);
}
///////////////////////////////////////////////////
@@ -7572,7 +7572,7 @@ HttpTransact::what_is_document_freshness(State *s, HTTPHdr *client_request, HTTP
if (age_val == 0) {
do_revalidate = true;
}
- age_limit = min(age_limit, age_val);
+ age_limit = std::min(age_limit, age_val);
DebugTxn("http_match", "[..._document_freshness] min_fresh set, age limit: %d", age_limit);
}
}
@@ -8871,7 +8871,7 @@ HttpTransact::update_size_and_time_stats(State *s, ink_hrtime total_time, ink_hr
switch (s->state_machine->background_fill) {
case BACKGROUND_FILL_COMPLETED: {
int64_t bg_size = origin_server_response_body_size - user_agent_response_body_size;
- bg_size = max((int64_t)0, bg_size);
+ bg_size = std::max((int64_t)0, bg_size);
HTTP_SUM_DYN_STAT(http_background_fill_bytes_completed_stat, bg_size);
break;
}
diff --git a/proxy/http/HttpTransactHeaders.cc b/proxy/http/HttpTransactHeaders.cc
index d3844c7..eba47c2 100644
--- a/proxy/http/HttpTransactHeaders.cc
+++ b/proxy/http/HttpTransactHeaders.cc
@@ -409,7 +409,7 @@ HttpTransactHeaders::calculate_document_age(ink_time_t request_time, ink_time_t
// Deal with clock skew. Sigh.
//
// TODO solve this global clock problem
- now_value = max(now, response_time);
+ now_value = std::max(now, response_time);
ink_assert(response_time >= 0);
ink_assert(request_time >= 0);
@@ -417,12 +417,12 @@ HttpTransactHeaders::calculate_document_age(ink_time_t request_time, ink_time_t
ink_assert(now_value >= response_time);
if (date_value > 0) {
- apparent_age = max((time_t)0, (response_time - date_value));
+ apparent_age = std::max((time_t)0, (response_time - date_value));
}
if (age_value < 0) {
current_age = -1; // Overflow from Age: header
} else {
- corrected_received_age = max(apparent_age, age_value);
+ corrected_received_age = std::max(apparent_age, age_value);
response_delay = response_time - request_time;
corrected_initial_age = corrected_received_age + response_delay;
resident_time = now_value - response_time;
diff --git a/proxy/http/HttpTunnel.cc b/proxy/http/HttpTunnel.cc
index d9fc59d..d21e79d 100644
--- a/proxy/http/HttpTunnel.cc
+++ b/proxy/http/HttpTunnel.cc
@@ -233,7 +233,7 @@ ChunkedHandler::transfer_bytes()
// Handle the case where we are doing chunked passthrough.
if (!dechunked_buffer) {
- moved = MIN(bytes_left, chunked_reader->read_avail());
+ moved = std::min(bytes_left, chunked_reader->read_avail());
chunked_reader->consume(moved);
bytes_left = bytes_left - moved;
return moved;
@@ -242,7 +242,7 @@ ChunkedHandler::transfer_bytes()
while (bytes_left > 0) {
block_read_avail = chunked_reader->block_read_avail();
- to_move = MIN(bytes_left, block_read_avail);
+ to_move = std::min(bytes_left, block_read_avail);
if (to_move <= 0) {
break;
}
@@ -374,7 +374,7 @@ ChunkedHandler::generate_chunked_content()
}
while ((r_avail = dechunked_reader->read_avail()) > 0 && state != CHUNK_WRITE_DONE) {
- int64_t write_val = MIN(max_chunk_size, r_avail);
+ int64_t write_val = std::min(max_chunk_size, r_avail);
state = CHUNK_WRITE_CHUNK;
Debug("http_chunk", "creating a chunk of size %" PRId64 " bytes", write_val);
diff --git a/proxy/http2/HTTP2.cc b/proxy/http2/HTTP2.cc
index e8f7bd4..85c10b5 100644
--- a/proxy/http2/HTTP2.cc
+++ b/proxy/http2/HTTP2.cc
@@ -586,7 +586,7 @@ http2_encode_header_blocks(HTTPHdr *in, uint8_t *out, uint32_t out_len, uint32_t
int32_t maximum_table_size)
{
// Limit the maximum table size to 64kB, which is the size advertised by major clients
- maximum_table_size = min(maximum_table_size, HTTP2_MAX_TABLE_SIZE_LIMIT);
+ maximum_table_size = std::min(maximum_table_size, HTTP2_MAX_TABLE_SIZE_LIMIT);
// Set maximum table size only if it is different from current maximum size
if (maximum_table_size == hpack_get_maximum_table_size(handle)) {
maximum_table_size = -1;
diff --git a/proxy/http2/Http2ConnectionState.cc b/proxy/http2/Http2ConnectionState.cc
index 10e20c6..40b6472 100644
--- a/proxy/http2/Http2ConnectionState.cc
+++ b/proxy/http2/Http2ConnectionState.cc
@@ -167,7 +167,7 @@ rcv_data_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
myreader->writer()->dealloc_reader(myreader);
uint32_t initial_rwnd = cstate.server_settings.get(HTTP2_SETTINGS_INITIAL_WINDOW_SIZE);
- uint32_t min_rwnd = min(initial_rwnd, cstate.server_settings.get(HTTP2_SETTINGS_MAX_FRAME_SIZE));
+ uint32_t min_rwnd = std::min(initial_rwnd, cstate.server_settings.get(HTTP2_SETTINGS_MAX_FRAME_SIZE));
// Connection level WINDOW UPDATE
if (cstate.server_rwnd <= min_rwnd) {
Http2WindowSize diff_size = initial_rwnd - cstate.server_rwnd;
@@ -713,7 +713,7 @@ rcv_window_update_frame(Http2ConnectionState &cstate, const Http2Frame &frame)
}
stream->client_rwnd += size;
- ssize_t wnd = min(cstate.client_rwnd, stream->client_rwnd);
+ ssize_t wnd = std::min(cstate.client_rwnd, stream->client_rwnd);
if (!stream->is_closed() && stream->get_state() == Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_REMOTE && wnd > 0) {
stream->send_response_body();
@@ -1067,7 +1067,7 @@ Http2ConnectionState::restart_streams()
s = next;
}
if (!s->is_closed() && s->get_state() == Http2StreamState::HTTP2_STREAM_STATE_HALF_CLOSED_REMOTE &&
- min(this->client_rwnd, s->client_rwnd) > 0) {
+ std::min(this->client_rwnd, s->client_rwnd) > 0) {
s->send_response_body();
}
@@ -1240,9 +1240,9 @@ Http2ConnectionState::send_data_frames_depends_on_priority()
Http2SendADataFrameResult
Http2ConnectionState::send_a_data_frame(Http2Stream *stream, size_t &payload_length)
{
- const ssize_t window_size = min(this->client_rwnd, stream->client_rwnd);
+ const ssize_t window_size = std::min(this->client_rwnd, stream->client_rwnd);
const size_t buf_len = BUFFER_SIZE_FOR_INDEX(buffer_size_index[HTTP2_FRAME_TYPE_DATA]);
- const size_t write_available_size = min(buf_len, static_cast<size_t>(window_size));
+ const size_t write_available_size = std::min(buf_len, static_cast<size_t>(window_size));
size_t read_available_size = 0;
uint8_t flags = 0x00;
@@ -1408,8 +1408,8 @@ Http2ConnectionState::send_headers_frame(Http2Stream *stream)
flags = 0;
while (sent < header_blocks_size) {
DebugHttp2Stream(ua_session, stream->get_id(), "Send CONTINUATION frame");
- payload_length = MIN(static_cast<uint32_t>(BUFFER_SIZE_FOR_INDEX(buffer_size_index[HTTP2_FRAME_TYPE_CONTINUATION])),
- header_blocks_size - sent);
+ payload_length = std::min(static_cast<uint32_t>(BUFFER_SIZE_FOR_INDEX(buffer_size_index[HTTP2_FRAME_TYPE_CONTINUATION])),
+ static_cast<uint32_t>(header_blocks_size - sent));
if (sent + payload_length == header_blocks_size) {
flags |= HTTP2_FLAGS_CONTINUATION_END_HEADERS;
}
@@ -1490,8 +1490,8 @@ Http2ConnectionState::send_push_promise_frame(Http2Stream *stream, URL &url)
flags = 0;
while (sent < header_blocks_size) {
DebugHttp2Stream(ua_session, stream->get_id(), "Send CONTINUATION frame");
- payload_length = MIN(static_cast<uint32_t>(BUFFER_SIZE_FOR_INDEX(buffer_size_index[HTTP2_FRAME_TYPE_CONTINUATION])),
- header_blocks_size - sent);
+ payload_length = std::min(static_cast<uint32_t>(BUFFER_SIZE_FOR_INDEX(buffer_size_index[HTTP2_FRAME_TYPE_CONTINUATION])),
+ static_cast<uint32_t>(header_blocks_size - sent));
if (sent + payload_length == header_blocks_size) {
flags |= HTTP2_FLAGS_CONTINUATION_END_HEADERS;
}
diff --git a/tools/jtest/jtest.cc b/tools/jtest/jtest.cc
index 774a6dd..730a881 100644
--- a/tools/jtest/jtest.cc
+++ b/tools/jtest/jtest.cc
@@ -516,7 +516,7 @@ max_limit_fd()
if (getrlimit(RLIMIT_NOFILE, &rl) >= 0) {
#ifdef OPEN_MAX
// Darwin
- rl.rlim_cur = MIN(OPEN_MAX, rl.rlim_max);
+ rl.rlim_cur = std::min(static_cast<rlim_t>(OPEN_MAX), rl.rlim_max);
#else
rl.rlim_cur = rl.rlim_max;
#endif
@@ -1962,7 +1962,7 @@ compose_all_urls(const char *tag, char *buf, char *start, char *end, int buflen,
char old;
while ((start = find_href_start(tag, end, buflen - (end - buf)))) {
char newurl[512];
- end = (char *)find_href_end(start, MIN(buflen - (start - buf), 512 - 10));
+ end = (char *)find_href_end(start, std::min(static_cast<int>(buflen - (start - buf)), 512 - 10));
if (!end) {
end = start + strlen(tag);
continue;
--
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>.