Repository: trafficserver Updated Branches: refs/heads/master 80eb1a8aa -> 60e8d9764
[TS-3085] - fixed the unsafe type casting and made other code style changes per James Peach's suggestions Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/2280dc3e Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/2280dc3e Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/2280dc3e Branch: refs/heads/master Commit: 2280dc3e35acab0e7f9beda9c38ce0982eee66a4 Parents: 6a02191 Author: Sudheer Vinukonda <sudhe...@yahoo-inc.com> Authored: Wed Sep 24 17:01:29 2014 +0000 Committer: Sudheer Vinukonda <sudhe...@yahoo-inc.com> Committed: Wed Sep 24 17:01:29 2014 +0000 ---------------------------------------------------------------------- iocore/net/P_SSLUtils.h | 12 +++++++----- iocore/net/SSLNetVConnection.cc | 6 +++--- iocore/net/SSLUtils.cc | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2280dc3e/iocore/net/P_SSLUtils.h ---------------------------------------------------------------------- diff --git a/iocore/net/P_SSLUtils.h b/iocore/net/P_SSLUtils.h index 269f009..3cf0c20 100644 --- a/iocore/net/P_SSLUtils.h +++ b/iocore/net/P_SSLUtils.h @@ -98,7 +98,7 @@ extern RecRawStatBlock *ssl_rsb; do { \ RecSetRawStatSum(ssl_rsb, (x), 0); \ RecSetRawStatCount(ssl_rsb, (x), 0); \ - } while (0); + } while (0) // Create a default SSL server context. SSL_CTX * SSLDefaultServerContext(); @@ -116,8 +116,8 @@ void SSLInitializeStatistics(); void SSLReleaseContext(SSL_CTX* ctx); // Wrapper functions to SSL I/O routines -ssl_error_t SSLWriteBuffer(SSL * ssl, const void * buf, size_t nbytes, size_t& nwritten); -ssl_error_t SSLReadBuffer(SSL * ssl, void * buf, size_t nbytes, size_t& nread); +ssl_error_t SSLWriteBuffer(SSL * ssl, const void * buf, int64_t nbytes, int64_t& nwritten); +ssl_error_t SSLReadBuffer(SSL * ssl, void * buf, int64_t nbytes, int64_t& nread); ssl_error_t SSLAccept(SSL *ssl); ssl_error_t SSLConnect(SSL * ssl); @@ -129,8 +129,10 @@ ssl_error_t SSLConnect(SSL * ssl); #define SSLDebugVC(vc,fmt, ...) SSLDiagnostic(DiagsMakeLocation(), true, vc, fmt, ##__VA_ARGS__) #define SSL_CLR_ERR_INCR_DYN_STAT(x, fmt, ...) \ - SSLDiagnostic(DiagsMakeLocation(), true, NULL, fmt, ##__VA_ARGS__); \ - RecIncrRawStat(ssl_rsb, NULL, (int) x, 1); + do { \ + SSLDiagnostic(DiagsMakeLocation(), true, NULL, fmt, ##__VA_ARGS__); \ + RecIncrRawStat(ssl_rsb, NULL, (int) x, 1); \ + } while (0) void SSLDiagnostic(const SrcLoc& loc, bool debug, SSLNetVConnection * vc, const char * fmt, ...) TS_PRINTFLIKE(4, 5); http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2280dc3e/iocore/net/SSLNetVConnection.cc ---------------------------------------------------------------------- diff --git a/iocore/net/SSLNetVConnection.cc b/iocore/net/SSLNetVConnection.cc index 0f26679..71b0bfc 100644 --- a/iocore/net/SSLNetVConnection.cc +++ b/iocore/net/SSLNetVConnection.cc @@ -182,7 +182,7 @@ ssl_read_from_net(SSLNetVConnection * sslvc, EThread * lthread, int64_t &ret) int64_t bytes_read; int64_t block_write_avail; ssl_error_t sslErr = SSL_ERROR_NONE; - int nread = 0; + int64_t nread = 0; for (bytes_read = 0; (b != 0) && (sslErr == SSL_ERROR_NONE); b = b->next) { block_write_avail = b->write_avail(); @@ -192,7 +192,7 @@ ssl_read_from_net(SSLNetVConnection * sslvc, EThread * lthread, int64_t &ret) int64_t offset = 0; // while can be replaced with if - need to test what works faster with openssl while (block_write_avail > 0) { - sslErr = SSLReadBuffer (sslvc->ssl, b->end() + offset, (size_t)block_write_avail, (size_t&)nread); + sslErr = SSLReadBuffer (sslvc->ssl, b->end() + offset, block_write_avail, nread); Debug("ssl", "[SSL_NetVConnection::ssl_read_from_net] nread=%d", (int)nread); @@ -659,7 +659,7 @@ SSLNetVConnection::load_buffer_and_write(int64_t towrite, int64_t &wattempted, i total_wrote += l; Debug("ssl", "SSLNetVConnection::loadBufferAndCallWrite, before SSLWriteBuffer, l=%" PRId64", towrite=%" PRId64", b=%p", l, towrite, b); - err = SSLWriteBuffer(ssl, b->start() + offset, (size_t)l, (size_t&)r); + err = SSLWriteBuffer(ssl, b->start() + offset, l, r); if (r == l) { wattempted = total_wrote; } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/2280dc3e/iocore/net/SSLUtils.cc ---------------------------------------------------------------------- diff --git a/iocore/net/SSLUtils.cc b/iocore/net/SSLUtils.cc index 59e0b63..c8142a7 100644 --- a/iocore/net/SSLUtils.cc +++ b/iocore/net/SSLUtils.cc @@ -1663,7 +1663,7 @@ SSLReleaseContext(SSL_CTX * ctx) ssl_error_t -SSLWriteBuffer(SSL * ssl, const void * buf, size_t nbytes, size_t& nwritten) +SSLWriteBuffer(SSL * ssl, const void * buf, int64_t nbytes, int64_t& nwritten) { nwritten = 0; @@ -1681,7 +1681,7 @@ SSLWriteBuffer(SSL * ssl, const void * buf, size_t nbytes, size_t& nwritten) } ssl_error_t -SSLReadBuffer(SSL * ssl, void * buf, size_t nbytes, size_t& nread) +SSLReadBuffer(SSL * ssl, void * buf, int64_t nbytes, int64_t& nread) { nread = 0;