http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/RecFile.cc ---------------------------------------------------------------------- diff --git a/lib/records/RecFile.cc b/lib/records/RecFile.cc index 669ec59..ba254de 100644 --- a/lib/records/RecFile.cc +++ b/lib/records/RecFile.cc @@ -34,7 +34,7 @@ RecHandle RecFileOpenR(const char *file) { RecHandle h_file; - return ((h_file =::open(file, O_RDONLY)) < 0) ? REC_HANDLE_INVALID : h_file; + return ((h_file = ::open(file, O_RDONLY)) < 0) ? REC_HANDLE_INVALID : h_file; } //------------------------------------------------------------------------- @@ -46,7 +46,7 @@ RecFileOpenW(const char *file) { RecHandle h_file; - if ((h_file =::open(file, O_WRONLY | O_TRUNC | O_CREAT, 0600)) < 0) { + if ((h_file = ::open(file, O_WRONLY | O_TRUNC | O_CREAT, 0600)) < 0) { return REC_HANDLE_INVALID; } fcntl(h_file, F_SETFD, 1); @@ -57,7 +57,8 @@ RecFileOpenW(const char *file) // RecFileSync //------------------------------------------------------------------------- -int RecFileSync(RecHandle h_file) +int +RecFileSync(RecHandle h_file) { return (fsync(h_file) == 0) ? REC_ERR_OKAY : REC_ERR_FAIL; } @@ -79,7 +80,7 @@ RecFileClose(RecHandle h_file) int RecFileRead(RecHandle h_file, char *buf, int size, int *bytes_read) { - if ((*bytes_read =::read(h_file, buf, size)) <= 0) { + if ((*bytes_read = ::read(h_file, buf, size)) <= 0) { *bytes_read = 0; return REC_ERR_FAIL; } @@ -93,7 +94,7 @@ RecFileRead(RecHandle h_file, char *buf, int size, int *bytes_read) int RecFileWrite(RecHandle h_file, char *buf, int size, int *bytes_written) { - if ((*bytes_written =::write(h_file, buf, size)) < 0) { + if ((*bytes_written = ::write(h_file, buf, size)) < 0) { *bytes_written = 0; return REC_ERR_FAIL; } @@ -109,7 +110,7 @@ RecFileGetSize(RecHandle h_file) { struct stat fileStats; fstat(h_file, &fileStats); - return (int) fileStats.st_size; + return (int)fileStats.st_size; } //------------------------------------------------------------------------- @@ -125,7 +126,6 @@ RecFileExists(const char *file) } RecFileClose(h_file); return REC_ERR_OKAY; - } //------------------------------------------------------------------------- @@ -135,7 +135,6 @@ RecFileExists(const char *file) RecHandle RecPipeCreate(const char *base_path, const char *name) { - RecHandle listenfd; RecHandle acceptfd; struct sockaddr_un servaddr; @@ -177,14 +176,14 @@ RecPipeCreate(const char *base_path, const char *name) ink_strlcpy(servaddr.sun_path, path, sizeof(servaddr.sun_path)); int optval = 1; - if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (char *) &optval, sizeof(int)) < 0) { + if (setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (char *)&optval, sizeof(int)) < 0) { RecLog(DL_Warning, "[RecPipeCreate] setsockopt error\n"); close(listenfd); return REC_HANDLE_INVALID; } servaddr_len = sizeof(servaddr.sun_family) + strlen(servaddr.sun_path); - if ((bind(listenfd, (struct sockaddr *) &servaddr, servaddr_len)) < 0) { + if ((bind(listenfd, (struct sockaddr *)&servaddr, servaddr_len)) < 0) { RecLog(DL_Warning, "[RecPipeCreate] bind error\n"); close(listenfd); return REC_HANDLE_INVALID; @@ -197,8 +196,7 @@ RecPipeCreate(const char *base_path, const char *name) } // block until we get a connection from the other side cliaddr_len = sizeof(cliaddr); - if ((acceptfd = accept(listenfd, (struct sockaddr *) &cliaddr, - &cliaddr_len)) < 0) { + if ((acceptfd = accept(listenfd, (struct sockaddr *)&cliaddr, &cliaddr_len)) < 0) { close(listenfd); return REC_HANDLE_INVALID; } @@ -215,7 +213,6 @@ RecPipeCreate(const char *base_path, const char *name) RecHandle RecPipeConnect(const char *base_path, const char *name) { - RecHandle sockfd; struct sockaddr_un servaddr; int servaddr_len; @@ -228,7 +225,7 @@ RecPipeConnect(const char *base_path, const char *name) return REC_HANDLE_INVALID; } // Setup Connection to LocalManager */ - memset((char *) &servaddr, 0, sizeof(servaddr)); + memset((char *)&servaddr, 0, sizeof(servaddr)); servaddr.sun_family = AF_UNIX; ink_strlcpy(servaddr.sun_path, path, sizeof(servaddr.sun_path)); servaddr_len = sizeof(servaddr.sun_family) + strlen(servaddr.sun_path); @@ -244,7 +241,7 @@ RecPipeConnect(const char *base_path, const char *name) return REC_HANDLE_INVALID; } // blocking connect - if ((connect(sockfd, (struct sockaddr *) &servaddr, servaddr_len)) < 0) { + if ((connect(sockfd, (struct sockaddr *)&servaddr, servaddr_len)) < 0) { RecLog(DL_Warning, "[RecPipeConnect] connect error\n"); close(sockfd); return REC_HANDLE_INVALID;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/RecHttp.cc ---------------------------------------------------------------------- diff --git a/lib/records/RecHttp.cc b/lib/records/RecHttp.cc index af72e46..2854813 100644 --- a/lib/records/RecHttp.cc +++ b/lib/records/RecHttp.cc @@ -21,11 +21,11 @@ limitations under the License. */ -# include <records/I_RecCore.h> -# include <records/I_RecHttp.h> -# include <ts/ink_defs.h> -# include <ts/Tokenizer.h> -# include <strings.h> +#include <records/I_RecCore.h> +#include <records/I_RecHttp.h> +#include <ts/ink_defs.h> +#include <ts/Tokenizer.h> +#include <strings.h> SessionProtocolNameRegistry globalSessionProtocolNameRegistry; @@ -33,19 +33,19 @@ SessionProtocolNameRegistry globalSessionProtocolNameRegistry; These are also used for NPN setup. */ -const char * const TS_NPN_PROTOCOL_HTTP_0_9 = "http/0.9"; -const char * const TS_NPN_PROTOCOL_HTTP_1_0 = "http/1.0"; -const char * const TS_NPN_PROTOCOL_HTTP_1_1 = "http/1.1"; -const char * const TS_NPN_PROTOCOL_HTTP_2_0_14 = "h2-14"; // Last H2 interrop draft. TODO: Should be removed later -const char * const TS_NPN_PROTOCOL_HTTP_2_0 = "h2"; // HTTP/2 over TLS -const char * const TS_NPN_PROTOCOL_SPDY_1 = "spdy/1"; // obsolete -const char * const TS_NPN_PROTOCOL_SPDY_2 = "spdy/2"; -const char * const TS_NPN_PROTOCOL_SPDY_3 = "spdy/3"; -const char * const TS_NPN_PROTOCOL_SPDY_3_1 = "spdy/3.1"; +const char *const TS_NPN_PROTOCOL_HTTP_0_9 = "http/0.9"; +const char *const TS_NPN_PROTOCOL_HTTP_1_0 = "http/1.0"; +const char *const TS_NPN_PROTOCOL_HTTP_1_1 = "http/1.1"; +const char *const TS_NPN_PROTOCOL_HTTP_2_0_14 = "h2-14"; // Last H2 interrop draft. TODO: Should be removed later +const char *const TS_NPN_PROTOCOL_HTTP_2_0 = "h2"; // HTTP/2 over TLS +const char *const TS_NPN_PROTOCOL_SPDY_1 = "spdy/1"; // obsolete +const char *const TS_NPN_PROTOCOL_SPDY_2 = "spdy/2"; +const char *const TS_NPN_PROTOCOL_SPDY_3 = "spdy/3"; +const char *const TS_NPN_PROTOCOL_SPDY_3_1 = "spdy/3.1"; -const char * const TS_NPN_PROTOCOL_GROUP_HTTP = "http"; -const char * const TS_NPN_PROTOCOL_GROUP_HTTP2 = "http2"; -const char * const TS_NPN_PROTOCOL_GROUP_SPDY = "spdy"; +const char *const TS_NPN_PROTOCOL_GROUP_HTTP = "http"; +const char *const TS_NPN_PROTOCOL_GROUP_HTTP2 = "http2"; +const char *const TS_NPN_PROTOCOL_GROUP_SPDY = "spdy"; // Precomputed indices for ease of use. int TS_NPN_PROTOCOL_INDEX_HTTP_0_9 = SessionProtocolNameRegistry::INVALID; @@ -64,7 +64,8 @@ SessionProtocolSet HTTP2_PROTOCOL_SET; SessionProtocolSet DEFAULT_NON_TLS_SESSION_PROTOCOL_SET; SessionProtocolSet DEFAULT_TLS_SESSION_PROTOCOL_SET; -void RecHttpLoadIp(char const* value_name, IpAddr& ip4, IpAddr& ip6) +void +RecHttpLoadIp(char const *value_name, IpAddr &ip4, IpAddr &ip6) { char value[1024]; ip4.invalidate(); @@ -72,19 +73,23 @@ void RecHttpLoadIp(char const* value_name, IpAddr& ip4, IpAddr& ip6) if (REC_ERR_OKAY == RecGetRecordString(value_name, value, sizeof(value))) { Tokenizer tokens(", "); int n_addrs = tokens.Initialize(value); - for (int i = 0 ; i < n_addrs ; ++i ) { - char const* host = tokens[i]; + for (int i = 0; i < n_addrs; ++i) { + char const *host = tokens[i]; IpEndpoint tmp4, tmp6; // For backwards compatibility we need to support the use of host names // for the address to bind. if (0 == ats_ip_getbestaddrinfo(host, &tmp4, &tmp6)) { if (ats_is_ip4(&tmp4)) { - if (!ip4.isValid()) ip4 = tmp4; - else Warning("'%s' specifies more than one IPv4 address, ignoring %s.", value_name, host); + if (!ip4.isValid()) + ip4 = tmp4; + else + Warning("'%s' specifies more than one IPv4 address, ignoring %s.", value_name, host); } if (ats_is_ip6(&tmp6)) { - if (!ip6.isValid()) ip6 = tmp6; - else Warning("'%s' specifies more than one IPv6 address, ignoring %s.", value_name, host); + if (!ip6.isValid()) + ip6 = tmp6; + else + Warning("'%s' specifies more than one IPv6 address, ignoring %s.", value_name, host); } } else { Warning("'%s' has an value '%s' that is not recognized as an IP address, ignored.", value_name, host); @@ -94,110 +99,118 @@ void RecHttpLoadIp(char const* value_name, IpAddr& ip4, IpAddr& ip6) } -char const* const HttpProxyPort::DEFAULT_VALUE = "8080"; +char const *const HttpProxyPort::DEFAULT_VALUE = "8080"; -char const* const HttpProxyPort::PORTS_CONFIG_NAME = "proxy.config.http.server_ports"; +char const *const HttpProxyPort::PORTS_CONFIG_NAME = "proxy.config.http.server_ports"; // "_PREFIX" means the option contains additional data. // Each has a corresponding _LEN value that is the length of the option text. // Options without _PREFIX are just flags with no additional data. -char const* const HttpProxyPort::OPT_FD_PREFIX = "fd"; -char const* const HttpProxyPort::OPT_OUTBOUND_IP_PREFIX = "ip-out"; -char const* const HttpProxyPort::OPT_INBOUND_IP_PREFIX = "ip-in"; -char const* const HttpProxyPort::OPT_HOST_RES_PREFIX = "ip-resolve"; -char const* const HttpProxyPort::OPT_PROTO_PREFIX = "proto"; - -char const* const HttpProxyPort::OPT_IPV6 = "ipv6"; -char const* const HttpProxyPort::OPT_IPV4 = "ipv4"; -char const* const HttpProxyPort::OPT_TRANSPARENT_INBOUND = "tr-in"; -char const* const HttpProxyPort::OPT_TRANSPARENT_OUTBOUND = "tr-out"; -char const* const HttpProxyPort::OPT_TRANSPARENT_FULL = "tr-full"; -char const* const HttpProxyPort::OPT_TRANSPARENT_PASSTHROUGH = "tr-pass"; -char const* const HttpProxyPort::OPT_SSL = "ssl"; -char const* const HttpProxyPort::OPT_PLUGIN = "plugin"; -char const* const HttpProxyPort::OPT_BLIND_TUNNEL = "blind"; -char const* const HttpProxyPort::OPT_COMPRESSED = "compressed"; +char const *const HttpProxyPort::OPT_FD_PREFIX = "fd"; +char const *const HttpProxyPort::OPT_OUTBOUND_IP_PREFIX = "ip-out"; +char const *const HttpProxyPort::OPT_INBOUND_IP_PREFIX = "ip-in"; +char const *const HttpProxyPort::OPT_HOST_RES_PREFIX = "ip-resolve"; +char const *const HttpProxyPort::OPT_PROTO_PREFIX = "proto"; + +char const *const HttpProxyPort::OPT_IPV6 = "ipv6"; +char const *const HttpProxyPort::OPT_IPV4 = "ipv4"; +char const *const HttpProxyPort::OPT_TRANSPARENT_INBOUND = "tr-in"; +char const *const HttpProxyPort::OPT_TRANSPARENT_OUTBOUND = "tr-out"; +char const *const HttpProxyPort::OPT_TRANSPARENT_FULL = "tr-full"; +char const *const HttpProxyPort::OPT_TRANSPARENT_PASSTHROUGH = "tr-pass"; +char const *const HttpProxyPort::OPT_SSL = "ssl"; +char const *const HttpProxyPort::OPT_PLUGIN = "plugin"; +char const *const HttpProxyPort::OPT_BLIND_TUNNEL = "blind"; +char const *const HttpProxyPort::OPT_COMPRESSED = "compressed"; // File local constants. -namespace { - // Length values for _PREFIX options. - size_t const OPT_FD_PREFIX_LEN = strlen(HttpProxyPort::OPT_FD_PREFIX); - size_t const OPT_OUTBOUND_IP_PREFIX_LEN = strlen(HttpProxyPort::OPT_OUTBOUND_IP_PREFIX); - size_t const OPT_INBOUND_IP_PREFIX_LEN = strlen(HttpProxyPort::OPT_INBOUND_IP_PREFIX); - size_t const OPT_HOST_RES_PREFIX_LEN = strlen(HttpProxyPort::OPT_HOST_RES_PREFIX); - size_t const OPT_PROTO_PREFIX_LEN = strlen(HttpProxyPort::OPT_PROTO_PREFIX); +namespace +{ +// Length values for _PREFIX options. +size_t const OPT_FD_PREFIX_LEN = strlen(HttpProxyPort::OPT_FD_PREFIX); +size_t const OPT_OUTBOUND_IP_PREFIX_LEN = strlen(HttpProxyPort::OPT_OUTBOUND_IP_PREFIX); +size_t const OPT_INBOUND_IP_PREFIX_LEN = strlen(HttpProxyPort::OPT_INBOUND_IP_PREFIX); +size_t const OPT_HOST_RES_PREFIX_LEN = strlen(HttpProxyPort::OPT_HOST_RES_PREFIX); +size_t const OPT_PROTO_PREFIX_LEN = strlen(HttpProxyPort::OPT_PROTO_PREFIX); } -namespace { +namespace +{ // Solaris work around. On that OS the compiler will not let me use an // instantiated instance of Vec<self> inside the class, even if // static. So we have to declare it elsewhere and then import via // reference. Might be a problem with Vec<> creating a fixed array // rather than allocating on first use (compared to std::vector<>). - HttpProxyPort::Group GLOBAL_DATA; +HttpProxyPort::Group GLOBAL_DATA; } -HttpProxyPort::Group& HttpProxyPort::m_global = GLOBAL_DATA; +HttpProxyPort::Group &HttpProxyPort::m_global = GLOBAL_DATA; HttpProxyPort::HttpProxyPort() - : m_fd(ts::NO_FD) - , m_type(TRANSPORT_DEFAULT) - , m_port(0) - , m_family(AF_INET) - , m_inbound_transparent_p(false) - , m_outbound_transparent_p(false) - , m_transparent_passthrough(false) + : m_fd(ts::NO_FD), m_type(TRANSPORT_DEFAULT), m_port(0), m_family(AF_INET), m_inbound_transparent_p(false), + m_outbound_transparent_p(false), m_transparent_passthrough(false) { memcpy(m_host_res_preference, host_res_default_preference_order, sizeof(m_host_res_preference)); } -bool HttpProxyPort::hasSSL(Group const& ports) { +bool +HttpProxyPort::hasSSL(Group const &ports) +{ bool zret = false; - for ( int i = 0 , n = ports.length() ; i < n && !zret ; ++i ) { - if (ports[i].isSSL()) zret = true; + for (int i = 0, n = ports.length(); i < n && !zret; ++i) { + if (ports[i].isSSL()) + zret = true; } return zret; } -HttpProxyPort* HttpProxyPort::findHttp(Group const& ports, uint16_t family) { +HttpProxyPort * +HttpProxyPort::findHttp(Group const &ports, uint16_t family) +{ bool check_family_p = ats_is_ip(family); - self* zret = 0; - for ( int i = 0 , n = ports.length() ; i < n && !zret ; ++i ) { - HttpProxyPort& p = ports[i]; - if (p.m_port && // has a valid port - TRANSPORT_DEFAULT == p.m_type && // is normal HTTP - ( !check_family_p || p.m_family == family) // right address family - ) - zret = &p;; + self *zret = 0; + for (int i = 0, n = ports.length(); i < n && !zret; ++i) { + HttpProxyPort &p = ports[i]; + if (p.m_port && // has a valid port + TRANSPORT_DEFAULT == p.m_type && // is normal HTTP + (!check_family_p || p.m_family == family) // right address family + ) + zret = &p; + ; } return zret; } -char const* -HttpProxyPort::checkPrefix(char const* src, char const* prefix, size_t prefix_len) { - char const* zret = 0; +char const * +HttpProxyPort::checkPrefix(char const *src, char const *prefix, size_t prefix_len) +{ + char const *zret = 0; if (0 == strncasecmp(prefix, src, prefix_len)) { src += prefix_len; - if ('-' == *src || '=' == *src) ++src; // permit optional '-' or '=' + if ('-' == *src || '=' == *src) + ++src; // permit optional '-' or '=' zret = src; } return zret; } bool -HttpProxyPort::loadConfig(Vec<self>& entries) { - char* text; +HttpProxyPort::loadConfig(Vec<self> &entries) +{ + char *text; bool found_p; text = REC_readString(PORTS_CONFIG_NAME, &found_p); - if (found_p) self::loadValue(entries, text); + if (found_p) + self::loadValue(entries, text); ats_free(text); return 0 < entries.length(); } bool -HttpProxyPort::loadDefaultIfEmpty(Group& ports) { +HttpProxyPort::loadDefaultIfEmpty(Group &ports) +{ if (0 == ports.length()) self::loadValue(ports, DEFAULT_VALUE); @@ -205,17 +218,20 @@ HttpProxyPort::loadDefaultIfEmpty(Group& ports) { } bool -HttpProxyPort::loadValue(Vec<self>& ports, char const* text) { +HttpProxyPort::loadValue(Vec<self> &ports, char const *text) +{ unsigned old_port_length = ports.length(); // remember this. if (text && *text) { Tokenizer tokens(", "); int n_ports = tokens.Initialize(text); if (n_ports > 0) { - for ( int p = 0 ; p < n_ports ; ++p ) { - char const* elt = tokens[p]; + for (int p = 0; p < n_ports; ++p) { + char const *elt = tokens[p]; HttpProxyPort entry; - if (entry.processOptions(elt)) ports.push_back(entry); - else Warning("No valid definition was found in proxy port configuration element '%s'", elt); + if (entry.processOptions(elt)) + ports.push_back(entry); + else + Warning("No valid definition was found in proxy port configuration element '%s'", elt); } } } @@ -223,35 +239,38 @@ HttpProxyPort::loadValue(Vec<self>& ports, char const* text) { } bool -HttpProxyPort::processOptions(char const* opts) { - bool zret = false; // found a port? - bool af_set_p = false; // AF explicitly specified? +HttpProxyPort::processOptions(char const *opts) +{ + bool zret = false; // found a port? + bool af_set_p = false; // AF explicitly specified? bool host_res_set_p = false; // Host resolution order set explicitly? - bool sp_set_p = false; // Session protocol set explicitly? - bool bracket_p = false; // found an open bracket in the input? - char const* value; // Temp holder for value of a prefix option. - IpAddr ip; // temp for loading IP addresses. - Vec<char*> values; // Pointers to single option values. + bool sp_set_p = false; // Session protocol set explicitly? + bool bracket_p = false; // found an open bracket in the input? + char const *value; // Temp holder for value of a prefix option. + IpAddr ip; // temp for loading IP addresses. + Vec<char *> values; // Pointers to single option values. // Make a copy we can modify safely. size_t opts_len = strlen(opts) + 1; - char* text = static_cast<char*>(alloca(opts_len)); + char *text = static_cast<char *>(alloca(opts_len)); memcpy(text, opts, opts_len); // Split the copy in to tokens. - char* token = 0; - for (char* spot = text ; *spot ; ++spot ) { + char *token = 0; + for (char *spot = text; *spot; ++spot) { if (bracket_p) { - if (']' == *spot) bracket_p = false; + if (']' == *spot) + bracket_p = false; } else if (':' == *spot) { *spot = 0; token = 0; } else { - if (! token) { + if (!token) { token = spot; values.push_back(token); } - if ('[' == *spot) bracket_p = true; + if ('[' == *spot) + bracket_p = true; } } if (bracket_p) { @@ -259,10 +278,10 @@ HttpProxyPort::processOptions(char const* opts) { return zret; } - for ( int i = 0, n_items = values.length() ; i < n_items ; ++i) { - char const* item = values[i]; + for (int i = 0, n_items = values.length(); i < n_items; ++i) { + char const *item = values[i]; if (isdigit(item[0])) { // leading digit -> port value - char* ptr; + char *ptr; int port = strtoul(item, &ptr, 10); if (ptr == item) { // really, this shouldn't happen, since we checked for a leading digit. @@ -274,7 +293,7 @@ HttpProxyPort::processOptions(char const* opts) { zret = true; } } else if (0 != (value = this->checkPrefix(item, OPT_FD_PREFIX, OPT_FD_PREFIX_LEN))) { - char* ptr; // tmp for syntax check. + char *ptr; // tmp for syntax check. int fd = strtoul(value, &ptr, 10); if (ptr == value) { Warning("Mangled file descriptor value '%s' in port descriptor '%s'", item, opts); @@ -286,9 +305,7 @@ HttpProxyPort::processOptions(char const* opts) { if (0 == ip.load(value)) m_inbound_ip = ip; else - Warning("Invalid IP address value '%s' in port descriptor '%s'", - item, opts - ); + Warning("Invalid IP address value '%s' in port descriptor '%s'", item, opts); } else if (0 != (value = this->checkPrefix(item, OPT_OUTBOUND_IP_PREFIX, OPT_OUTBOUND_IP_PREFIX_LEN))) { if (0 == ip.load(value)) this->outboundIp(ip.family()) = ip; @@ -309,30 +326,30 @@ HttpProxyPort::processOptions(char const* opts) { } else if (0 == strcasecmp(OPT_PLUGIN, item)) { m_type = TRANSPORT_PLUGIN; } else if (0 == strcasecmp(OPT_TRANSPARENT_INBOUND, item)) { -# if TS_USE_TPROXY +#if TS_USE_TPROXY m_inbound_transparent_p = true; -# else +#else Warning("Transparency requested [%s] in port descriptor '%s' but TPROXY was not configured.", item, opts); -# endif +#endif } else if (0 == strcasecmp(OPT_TRANSPARENT_OUTBOUND, item)) { -# if TS_USE_TPROXY +#if TS_USE_TPROXY m_outbound_transparent_p = true; -# else +#else Warning("Transparency requested [%s] in port descriptor '%s' but TPROXY was not configured.", item, opts); -# endif +#endif } else if (0 == strcasecmp(OPT_TRANSPARENT_FULL, item)) { -# if TS_USE_TPROXY +#if TS_USE_TPROXY m_inbound_transparent_p = true; m_outbound_transparent_p = true; -# else +#else Warning("Transparency requested [%s] in port descriptor '%s' but TPROXY was not configured.", item, opts); -# endif +#endif } else if (0 == strcasecmp(OPT_TRANSPARENT_PASSTHROUGH, item)) { -# if TS_USE_TPROXY +#if TS_USE_TPROXY m_transparent_passthrough = true; -# else +#else Warning("Transparent pass-through requested [%s] in port descriptor '%s' but TPROXY was not configured.", item, opts); -# endif +#endif } else if (0 != (value = this->checkPrefix(item, OPT_HOST_RES_PREFIX, OPT_HOST_RES_PREFIX_LEN))) { this->processFamilyPreference(value); host_res_set_p = true; @@ -348,7 +365,8 @@ HttpProxyPort::processOptions(char const* opts) { if (af_set_p) { if (in_ip_set_p && m_family != m_inbound_ip.family()) { - Warning("Invalid port descriptor '%s' - the inbound adddress family [%s] is not the same type as the explicit family value [%s]", + Warning( + "Invalid port descriptor '%s' - the inbound adddress family [%s] is not the same type as the explicit family value [%s]", opts, ats_ip_family_name(m_inbound_ip.family()), ats_ip_family_name(m_family)); zret = false; } @@ -359,15 +377,10 @@ HttpProxyPort::processOptions(char const* opts) { // If the port is outbound transparent only CLIENT host resolution is possible. if (m_outbound_transparent_p) { if (host_res_set_p && - (m_host_res_preference[0] != HOST_RES_PREFER_CLIENT || - m_host_res_preference[1] != HOST_RES_PREFER_NONE - )) { + (m_host_res_preference[0] != HOST_RES_PREFER_CLIENT || m_host_res_preference[1] != HOST_RES_PREFER_NONE)) { Warning("Outbound transparent port '%s' requires the IP address resolution ordering '%s,%s'. " - "This is set automatically and does not need to be set explicitly." - , opts - , HOST_RES_PREFERENCE_STRING[HOST_RES_PREFER_CLIENT] - , HOST_RES_PREFERENCE_STRING[HOST_RES_PREFER_NONE] - ); + "This is set automatically and does not need to be set explicitly.", + opts, HOST_RES_PREFERENCE_STRING[HOST_RES_PREFER_CLIENT], HOST_RES_PREFERENCE_STRING[HOST_RES_PREFER_NONE]); } m_host_res_preference[0] = HOST_RES_PREFER_CLIENT; m_host_res_preference[1] = HOST_RES_PREFER_NONE; @@ -381,34 +394,34 @@ HttpProxyPort::processOptions(char const* opts) { // Set the default session protocols. if (!sp_set_p) - m_session_protocol_preference = this->isSSL() - ? DEFAULT_TLS_SESSION_PROTOCOL_SET - : DEFAULT_NON_TLS_SESSION_PROTOCOL_SET - ; + m_session_protocol_preference = this->isSSL() ? DEFAULT_TLS_SESSION_PROTOCOL_SET : DEFAULT_NON_TLS_SESSION_PROTOCOL_SET; return zret; } void -HttpProxyPort::processFamilyPreference(char const* value) { +HttpProxyPort::processFamilyPreference(char const *value) +{ parse_host_res_preference(value, m_host_res_preference); } void -HttpProxyPort::processSessionProtocolPreference(char const* value) { +HttpProxyPort::processSessionProtocolPreference(char const *value) +{ m_session_protocol_preference.markAllOut(); globalSessionProtocolNameRegistry.markIn(value, m_session_protocol_preference); } void -SessionProtocolNameRegistry::markIn(char const* value, SessionProtocolSet& sp_set) { +SessionProtocolNameRegistry::markIn(char const *value, SessionProtocolSet &sp_set) +{ int n; // # of tokens Tokenizer tokens(" ;|,:"); n = tokens.Initialize(value); - for ( int i = 0 ; i < n ; ++i ) { - char const* elt = tokens[i]; + for (int i = 0; i < n; ++i) { + char const *elt = tokens[i]; /// Check special cases if (0 == strcasecmp(elt, TS_NPN_PROTOCOL_GROUP_HTTP)) { @@ -425,79 +438,82 @@ SessionProtocolNameRegistry::markIn(char const* value, SessionProtocolSet& sp_se } int -HttpProxyPort::print(char* out, size_t n) { +HttpProxyPort::print(char *out, size_t n) +{ size_t zret = 0; // # of chars printed so far. ip_text_buffer ipb; bool need_colon_p = false; if (m_inbound_ip.isValid()) { - zret += snprintf(out+zret, n-zret, "%s=[%s]", - OPT_INBOUND_IP_PREFIX, - m_inbound_ip.toString(ipb, sizeof(ipb)) - ); + zret += snprintf(out + zret, n - zret, "%s=[%s]", OPT_INBOUND_IP_PREFIX, m_inbound_ip.toString(ipb, sizeof(ipb))); need_colon_p = true; } - if (zret >= n) return n; + if (zret >= n) + return n; if (m_outbound_ip4.isValid()) { - if (need_colon_p) out[zret++] = ':'; - zret += snprintf(out+zret, n-zret, "%s=[%s]", - OPT_OUTBOUND_IP_PREFIX, - m_outbound_ip4.toString(ipb, sizeof(ipb)) - ); + if (need_colon_p) + out[zret++] = ':'; + zret += snprintf(out + zret, n - zret, "%s=[%s]", OPT_OUTBOUND_IP_PREFIX, m_outbound_ip4.toString(ipb, sizeof(ipb))); need_colon_p = true; } - if (zret >= n) return n; + if (zret >= n) + return n; if (m_outbound_ip6.isValid()) { - if (need_colon_p) out[zret++] = ':'; - zret += snprintf(out+zret, n-zret, "%s=[%s]", - OPT_OUTBOUND_IP_PREFIX, - m_outbound_ip6.toString(ipb, sizeof(ipb)) - ); + if (need_colon_p) + out[zret++] = ':'; + zret += snprintf(out + zret, n - zret, "%s=[%s]", OPT_OUTBOUND_IP_PREFIX, m_outbound_ip6.toString(ipb, sizeof(ipb))); need_colon_p = true; } - if (zret >= n) return n; + if (zret >= n) + return n; if (0 != m_port) { - if (need_colon_p) out[zret++] = ':'; - zret += snprintf(out+zret, n-zret, "%d", m_port); + if (need_colon_p) + out[zret++] = ':'; + zret += snprintf(out + zret, n - zret, "%d", m_port); need_colon_p = true; } - if (zret >= n) return n; + if (zret >= n) + return n; if (ts::NO_FD != m_fd) { - if (need_colon_p) out[zret++] = ':'; - zret += snprintf(out+zret, n-zret, "fd=%d", m_fd); + if (need_colon_p) + out[zret++] = ':'; + zret += snprintf(out + zret, n - zret, "fd=%d", m_fd); } - if (zret >= n) return n; + if (zret >= n) + return n; // After this point, all of these options require other options which we've already // generated so all of them need a leading colon and we can stop checking for that. if (AF_INET6 == m_family) - zret += snprintf(out+zret, n-zret, ":%s", OPT_IPV6); - if (zret >= n) return n; + zret += snprintf(out + zret, n - zret, ":%s", OPT_IPV6); + if (zret >= n) + return n; if (TRANSPORT_BLIND_TUNNEL == m_type) - zret += snprintf(out+zret, n-zret, ":%s", OPT_BLIND_TUNNEL); + zret += snprintf(out + zret, n - zret, ":%s", OPT_BLIND_TUNNEL); else if (TRANSPORT_SSL == m_type) - zret += snprintf(out+zret, n-zret, ":%s", OPT_SSL); + zret += snprintf(out + zret, n - zret, ":%s", OPT_SSL); else if (TRANSPORT_PLUGIN == m_type) - zret += snprintf(out+zret, n-zret, ":%s", OPT_PLUGIN); + zret += snprintf(out + zret, n - zret, ":%s", OPT_PLUGIN); else if (TRANSPORT_COMPRESSED == m_type) - zret += snprintf(out+zret, n-zret, ":%s", OPT_COMPRESSED); - if (zret >= n) return n; + zret += snprintf(out + zret, n - zret, ":%s", OPT_COMPRESSED); + if (zret >= n) + return n; if (m_outbound_transparent_p && m_inbound_transparent_p) - zret += snprintf(out+zret, n-zret, ":%s", OPT_TRANSPARENT_FULL); + zret += snprintf(out + zret, n - zret, ":%s", OPT_TRANSPARENT_FULL); else if (m_inbound_transparent_p) - zret += snprintf(out+zret, n-zret, ":%s", OPT_TRANSPARENT_INBOUND); + zret += snprintf(out + zret, n - zret, ":%s", OPT_TRANSPARENT_INBOUND); else if (m_outbound_transparent_p) - zret += snprintf(out+zret, n-zret, ":%s", OPT_TRANSPARENT_OUTBOUND); + zret += snprintf(out + zret, n - zret, ":%s", OPT_TRANSPARENT_OUTBOUND); if (m_transparent_passthrough) - zret += snprintf(out+zret, n-zret, ":%s", OPT_TRANSPARENT_PASSTHROUGH); + zret += snprintf(out + zret, n - zret, ":%s", OPT_TRANSPARENT_PASSTHROUGH); /* Don't print the IP resolution preferences if the port is outbound * transparent (which means the preference order is forced) or if @@ -505,14 +521,14 @@ HttpProxyPort::print(char* out, size_t n) { */ if (!m_outbound_transparent_p && 0 != memcmp(m_host_res_preference, host_res_default_preference_order, sizeof(m_host_res_preference))) { - zret += snprintf(out+zret, n-zret, ":%s=", OPT_HOST_RES_PREFIX); - zret += ts_host_res_order_to_string(m_host_res_preference, out+zret, n-zret); + zret += snprintf(out + zret, n - zret, ":%s=", OPT_HOST_RES_PREFIX); + zret += ts_host_res_order_to_string(m_host_res_preference, out + zret, n - zret); } // session protocol options - look for condensed options first // first two cases are the defaults so if those match, print nothing. SessionProtocolSet sp_set = m_session_protocol_preference; // need to modify so copy. - need_colon_p = true; // for listing case, turned off if we do a special case. + need_colon_p = true; // for listing case, turned off if we do a special case. if (sp_set == DEFAULT_NON_TLS_SESSION_PROTOCOL_SET && !this->isSSL()) { sp_set.markOut(DEFAULT_NON_TLS_SESSION_PROTOCOL_SET); } else if (sp_set == DEFAULT_TLS_SESSION_PROTOCOL_SET && this->isSSL()) { @@ -521,53 +537,51 @@ HttpProxyPort::print(char* out, size_t n) { // pull out groups. if (sp_set.contains(HTTP_PROTOCOL_SET)) { - zret += snprintf(out+zret, n-zret, ":%s=%s", OPT_PROTO_PREFIX,TS_NPN_PROTOCOL_GROUP_HTTP); + zret += snprintf(out + zret, n - zret, ":%s=%s", OPT_PROTO_PREFIX, TS_NPN_PROTOCOL_GROUP_HTTP); sp_set.markOut(HTTP_PROTOCOL_SET); need_colon_p = false; } if (sp_set.contains(SPDY_PROTOCOL_SET)) { if (need_colon_p) - zret += snprintf(out+zret, n-zret, ":%s=", OPT_PROTO_PREFIX); + zret += snprintf(out + zret, n - zret, ":%s=", OPT_PROTO_PREFIX); else out[zret++] = ';'; - zret += snprintf(out+zret, n-zret, TS_NPN_PROTOCOL_GROUP_SPDY); + zret += snprintf(out + zret, n - zret, TS_NPN_PROTOCOL_GROUP_SPDY); sp_set.markOut(SPDY_PROTOCOL_SET); need_colon_p = false; } if (sp_set.contains(HTTP2_PROTOCOL_SET)) { if (need_colon_p) - zret += snprintf(out+zret, n-zret, ":%s=", OPT_PROTO_PREFIX); + zret += snprintf(out + zret, n - zret, ":%s=", OPT_PROTO_PREFIX); else out[zret++] = ';'; - zret += snprintf(out+zret, n-zret, "%s", TS_NPN_PROTOCOL_GROUP_HTTP2); + zret += snprintf(out + zret, n - zret, "%s", TS_NPN_PROTOCOL_GROUP_HTTP2); sp_set.markOut(HTTP2_PROTOCOL_SET); need_colon_p = false; } // now enumerate what's left. if (!sp_set.isEmpty()) { if (need_colon_p) - zret += snprintf(out+zret, n-zret, ":%s=", OPT_PROTO_PREFIX); + zret += snprintf(out + zret, n - zret, ":%s=", OPT_PROTO_PREFIX); bool sep_p = !need_colon_p; - for ( int k = 0 ; k < SessionProtocolSet::MAX ; ++k ) { + for (int k = 0; k < SessionProtocolSet::MAX; ++k) { if (sp_set.contains(k)) { - zret += snprintf(out+zret, n-zret, "%s%s", sep_p ? ";" : "", globalSessionProtocolNameRegistry.nameFor(k)); + zret += snprintf(out + zret, n - zret, "%s%s", sep_p ? ";" : "", globalSessionProtocolNameRegistry.nameFor(k)); sep_p = true; } } } - return min(zret,n); + return min(zret, n); } void ts_host_res_global_init() { // Global configuration values. - memcpy(host_res_default_preference_order, - HOST_RES_DEFAULT_PREFERENCE_ORDER, - sizeof(host_res_default_preference_order)); + memcpy(host_res_default_preference_order, HOST_RES_DEFAULT_PREFERENCE_ORDER, sizeof(host_res_default_preference_order)); - char* ip_resolve = REC_ConfigReadString("proxy.config.hostdb.ip_resolve"); + char *ip_resolve = REC_ConfigReadString("proxy.config.hostdb.ip_resolve"); if (ip_resolve) { parse_host_res_preference(ip_resolve, host_res_default_preference_order); } @@ -608,22 +622,23 @@ ts_session_protocol_well_known_name_indices_init() DEFAULT_NON_TLS_SESSION_PROTOCOL_SET = HTTP_PROTOCOL_SET; } -SessionProtocolNameRegistry::SessionProtocolNameRegistry() - : m_n(0) +SessionProtocolNameRegistry::SessionProtocolNameRegistry() : m_n(0) { memset(m_names, 0, sizeof(m_names)); memset(&m_flags, 0, sizeof(m_flags)); } -SessionProtocolNameRegistry::~SessionProtocolNameRegistry() { - for ( size_t i = 0 ; i < m_n ; ++i ) { +SessionProtocolNameRegistry::~SessionProtocolNameRegistry() +{ + for (size_t i = 0; i < m_n; ++i) { if (m_flags[i] & F_ALLOCATED) - ats_free(const_cast<char*>(m_names[i])); // blech - ats_free won't take a char const* + ats_free(const_cast<char *>(m_names[i])); // blech - ats_free won't take a char const* } } int -SessionProtocolNameRegistry::toIndex(char const* name) { +SessionProtocolNameRegistry::toIndex(char const *name) +{ int zret = this->indexFor(name); if (INVALID == zret) { if (m_n < static_cast<size_t>(MAX)) { @@ -638,10 +653,11 @@ SessionProtocolNameRegistry::toIndex(char const* name) { } int -SessionProtocolNameRegistry::toIndexConst(char const* name) { +SessionProtocolNameRegistry::toIndexConst(char const *name) +{ int zret = this->indexFor(name); if (INVALID == zret) { - if ( m_n < static_cast<size_t>(MAX)) { + if (m_n < static_cast<size_t>(MAX)) { m_names[m_n] = name; zret = m_n++; } else { @@ -652,18 +668,17 @@ SessionProtocolNameRegistry::toIndexConst(char const* name) { } int -SessionProtocolNameRegistry::indexFor(char const* name) const { - for ( size_t i = 0 ; i < m_n ; ++i ) { +SessionProtocolNameRegistry::indexFor(char const *name) const +{ + for (size_t i = 0; i < m_n; ++i) { if (0 == strcasecmp(name, m_names[i])) return i; } return INVALID; } -char const* -SessionProtocolNameRegistry::nameFor(int idx) const { - return 0 <= idx && idx < static_cast<int>(m_n) - ? m_names[idx] - : 0 - ; +char const * +SessionProtocolNameRegistry::nameFor(int idx) const +{ + return 0 <= idx && idx < static_cast<int>(m_n) ? m_names[idx] : 0; } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/RecLocal.cc ---------------------------------------------------------------------- diff --git a/lib/records/RecLocal.cc b/lib/records/RecLocal.cc index 10aca66..8dc0dc3 100644 --- a/lib/records/RecLocal.cc +++ b/lib/records/RecLocal.cc @@ -60,10 +60,10 @@ i_am_the_record_owner(RecT rec_type) // sync_thr //------------------------------------------------------------------------- static void * -sync_thr(void * data) +sync_thr(void *data) { textBuffer *tb = new textBuffer(65536); - FileManager * configFiles = (FileManager *)data; + FileManager *configFiles = (FileManager *)data; Rollback *rb; bool inc_version; @@ -83,8 +83,7 @@ sync_thr(void * data) } written = true; } - } - else { + } else { rb = NULL; } if (!written) { @@ -112,7 +111,6 @@ sync_thr(void * data) static void * config_update_thr(void * /* data */) { - while (true) { switch (RecExecConfigUpdateCbs(REC_LOCAL_UPDATE_REQUIRED)) { case RECU_RESTART_TS: @@ -153,9 +151,10 @@ RecMessageInit() // RecLocalInit //------------------------------------------------------------------------- int -RecLocalInit(Diags * _diags) +RecLocalInit(Diags *_diags) { - static bool initialized_p = false;; + static bool initialized_p = false; + ; if (initialized_p) { return REC_ERR_OKAY; @@ -208,7 +207,7 @@ RecLocalInitMessage() // RecLocalStart //------------------------------------------------------------------------- int -RecLocalStart(FileManager * configFiles) +RecLocalStart(FileManager *configFiles) { ink_thread_create(sync_thr, configFiles); ink_thread_create(config_update_thr, NULL); @@ -225,9 +224,9 @@ RecRegisterManagerCb(int id, RecManagerCb _fn, void *_data) void RecSignalManager(int id, const char *, size_t) { - // Signals are messages sent across the management pipe, so by definition, - // you can't send a signal if you are a local process manager. - RecDebug(DL_Debug, "local manager dropping signal %d", id); + // Signals are messages sent across the management pipe, so by definition, + // you can't send a signal if you are a local process manager. + RecDebug(DL_Debug, "local manager dropping signal %d", id); } //------------------------------------------------------------------------- @@ -235,7 +234,7 @@ RecSignalManager(int id, const char *, size_t) //------------------------------------------------------------------------- int -RecMessageSend(RecMessage * msg) +RecMessageSend(RecMessage *msg) { int msg_size; @@ -246,9 +245,8 @@ RecMessageSend(RecMessage * msg) if (g_mode_type == RECM_CLIENT || g_mode_type == RECM_SERVER) { msg->o_end = msg->o_write; msg_size = sizeof(RecMessageHdr) + (msg->o_write - msg->o_start); - lmgmt->signalEvent(MGMT_EVENT_LIBRECORDS, (char *) msg, msg_size); + lmgmt->signalEvent(MGMT_EVENT_LIBRECORDS, (char *)msg, msg_size); } return REC_ERR_OKAY; } - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/RecMessage.cc ---------------------------------------------------------------------- diff --git a/lib/records/RecMessage.cc b/lib/records/RecMessage.cc index ca8b352..0ca2eef 100644 --- a/lib/records/RecMessage.cc +++ b/lib/records/RecMessage.cc @@ -57,7 +57,7 @@ RecMessageAlloc(RecMessageT msg_type, int initial_size) //------------------------------------------------------------------------- int -RecMessageFree(RecMessage * msg) +RecMessageFree(RecMessage *msg) { ats_free(msg); return REC_ERR_OKAY; @@ -67,7 +67,7 @@ RecMessageFree(RecMessage * msg) // RecMessageMarshal_Realloc //------------------------------------------------------------------------- RecMessage * -RecMessageMarshal_Realloc(RecMessage * msg, const RecRecord * record) +RecMessageMarshal_Realloc(RecMessage *msg, const RecRecord *record) { int msg_ele_size; int rec_name_len = -1; @@ -103,49 +103,49 @@ RecMessageMarshal_Realloc(RecMessage * msg, const RecRecord * record) // (msg_ele_size + 7) & ~7 == 5 !!! // msg_ele_size = (msg_ele_size + 7) & ~7; // 8 byte alignmenet - msg_ele_size = INK_ALIGN_DEFAULT(msg_ele_size); // 8 byte alignmenet + msg_ele_size = INK_ALIGN_DEFAULT(msg_ele_size); // 8 byte alignmenet // get some space in our buffer while (msg->o_end - msg->o_write < msg_ele_size) { int realloc_size = (msg->o_end - msg->o_start) * 2; msg = (RecMessage *)ats_realloc(msg, sizeof(RecMessageHdr) + realloc_size); msg->o_end = msg->o_start + realloc_size; } - ele_hdr = (RecMessageEleHdr *) ((char *) msg + msg->o_write); + ele_hdr = (RecMessageEleHdr *)((char *)msg + msg->o_write); // The following memset() is pretty CPU intensive, replacing it with something // like the below would reduce CPU usage a fair amount. /leif. // *((char*)msg + msg->o_write) = 0; - memset((char *) msg + msg->o_write, 0, msg->o_end - msg->o_write); + memset((char *)msg + msg->o_write, 0, msg->o_end - msg->o_write); msg->o_write += msg_ele_size; // store the record ele_hdr->magic = REC_MESSAGE_ELE_MAGIC; ele_hdr->o_next = msg->o_write; - p = (char *) ele_hdr + sizeof(RecMessageEleHdr); + p = (char *)ele_hdr + sizeof(RecMessageEleHdr); memcpy(p, record, sizeof(RecRecord)); - r = (RecRecord *) p; + r = (RecRecord *)p; p += sizeof(RecRecord); if (rec_name_len != -1) { - ink_assert((msg->o_end - ((uintptr_t) p - (uintptr_t) msg)) >= (uintptr_t) rec_name_len); + ink_assert((msg->o_end - ((uintptr_t)p - (uintptr_t)msg)) >= (uintptr_t)rec_name_len); memcpy(p, record->name, rec_name_len); - r->name = (char *) ((uintptr_t) p - (uintptr_t) r); + r->name = (char *)((uintptr_t)p - (uintptr_t)r); p += rec_name_len; } if (rec_data_str_len != -1) { - ink_assert((msg->o_end - ((uintptr_t) p - (uintptr_t) msg)) >= (uintptr_t) rec_data_str_len); + ink_assert((msg->o_end - ((uintptr_t)p - (uintptr_t)msg)) >= (uintptr_t)rec_data_str_len); memcpy(p, record->data.rec_string, rec_data_str_len); - r->data.rec_string = (char *) ((uintptr_t) p - (uintptr_t) r); + r->data.rec_string = (char *)((uintptr_t)p - (uintptr_t)r); p += rec_data_str_len; } if (rec_data_def_str_len != -1) { - ink_assert((msg->o_end - ((uintptr_t) p - (uintptr_t) msg)) >= (uintptr_t) rec_data_def_str_len); + ink_assert((msg->o_end - ((uintptr_t)p - (uintptr_t)msg)) >= (uintptr_t)rec_data_def_str_len); memcpy(p, record->data_default.rec_string, rec_data_def_str_len); - r->data_default.rec_string = (char *) ((uintptr_t) p - (uintptr_t) r); + r->data_default.rec_string = (char *)((uintptr_t)p - (uintptr_t)r); p += rec_data_def_str_len; } if (rec_cfg_chk_len != -1) { - ink_assert((msg->o_end - ((uintptr_t) p - (uintptr_t) msg)) >= (uintptr_t) rec_cfg_chk_len); + ink_assert((msg->o_end - ((uintptr_t)p - (uintptr_t)msg)) >= (uintptr_t)rec_cfg_chk_len); memcpy(p, record->config_meta.check_expr, rec_cfg_chk_len); - r->config_meta.check_expr = (char *) ((uintptr_t) p - (uintptr_t) r); + r->config_meta.check_expr = (char *)((uintptr_t)p - (uintptr_t)r); } msg->entries += 1; @@ -158,9 +158,9 @@ RecMessageMarshal_Realloc(RecMessage * msg, const RecRecord * record) //------------------------------------------------------------------------- int -RecMessageUnmarshalFirst(RecMessage * msg, RecMessageItr * itr, RecRecord ** record) +RecMessageUnmarshalFirst(RecMessage *msg, RecMessageItr *itr, RecRecord **record) { - itr->ele_hdr = (RecMessageEleHdr *) ((char *) msg + msg->o_start); + itr->ele_hdr = (RecMessageEleHdr *)((char *)msg + msg->o_start); itr->next = 1; return RecMessageUnmarshalNext(msg, NULL, record); @@ -171,7 +171,7 @@ RecMessageUnmarshalFirst(RecMessage * msg, RecMessageItr * itr, RecRecord ** rec //------------------------------------------------------------------------- int -RecMessageUnmarshalNext(RecMessage * msg, RecMessageItr * itr, RecRecord ** record) +RecMessageUnmarshalNext(RecMessage *msg, RecMessageItr *itr, RecRecord **record) { RecMessageEleHdr *eh; RecRecord *r; @@ -180,13 +180,13 @@ RecMessageUnmarshalNext(RecMessage * msg, RecMessageItr * itr, RecRecord ** reco if (msg->entries == 0) { return REC_ERR_FAIL; } else { - eh = (RecMessageEleHdr *) ((char *) msg + msg->o_start); + eh = (RecMessageEleHdr *)((char *)msg + msg->o_start); } } else { if (itr->next >= msg->entries) { return REC_ERR_FAIL; } - itr->ele_hdr = (RecMessageEleHdr *) ((char *) (msg) + itr->ele_hdr->o_next); + itr->ele_hdr = (RecMessageEleHdr *)((char *)(msg) + itr->ele_hdr->o_next); itr->next += 1; eh = itr->ele_hdr; } @@ -199,21 +199,21 @@ RecMessageUnmarshalNext(RecMessage * msg, RecMessageItr * itr, RecRecord ** reco return REC_ERR_FAIL; } - r = (RecRecord *) ((char *) eh + sizeof(RecMessageEleHdr)); + r = (RecRecord *)((char *)eh + sizeof(RecMessageEleHdr)); if (r->name) { - r->name = (char *) r + (intptr_t) (r->name); + r->name = (char *)r + (intptr_t)(r->name); } if (r->data_type == RECD_STRING) { if (r->data.rec_string) { - r->data.rec_string = (char *) r + (intptr_t) (r->data.rec_string); + r->data.rec_string = (char *)r + (intptr_t)(r->data.rec_string); } if (r->data_default.rec_string) { - r->data_default.rec_string = (char *) r + (intptr_t) (r->data_default.rec_string); + r->data_default.rec_string = (char *)r + (intptr_t)(r->data_default.rec_string); } } if (REC_TYPE_IS_CONFIG(r->rec_type) && (r->config_meta.check_expr)) { - r->config_meta.check_expr = (char *) r + (intptr_t) (r->config_meta.check_expr); + r->config_meta.check_expr = (char *)r + (intptr_t)(r->config_meta.check_expr); } *record = r; @@ -244,7 +244,7 @@ RecMessageRegisterRecvCb(RecMessageRecvCb recv_cb, void *cookie) void * RecMessageRecvThis(void * /* cookie */, char *data_raw, int /* data_len */) { - RecMessage *msg = (RecMessage *) data_raw; + RecMessage *msg = (RecMessage *)data_raw; g_recv_cb(msg, msg->msg_type, g_recv_cookie); return NULL; } @@ -264,13 +264,12 @@ RecMessageReadFromDisk(const char *fpath) if ((h_file = RecFileOpenR(fpath)) == REC_HANDLE_INVALID) { goto Lerror; } - if (RecFileRead(h_file, (char *) (&msg_hdr), sizeof(RecMessageHdr), &bytes_read) == REC_ERR_FAIL) { + if (RecFileRead(h_file, (char *)(&msg_hdr), sizeof(RecMessageHdr), &bytes_read) == REC_ERR_FAIL) { goto Lerror; } msg = (RecMessage *)ats_malloc((msg_hdr.o_end - msg_hdr.o_start) + sizeof(RecMessageHdr)); memcpy(msg, &msg_hdr, sizeof(RecMessageHdr)); - if (RecFileRead(h_file, (char *) (msg) + msg_hdr.o_start, - msg_hdr.o_end - msg_hdr.o_start, &bytes_read) == REC_ERR_FAIL) { + if (RecFileRead(h_file, (char *)(msg) + msg_hdr.o_start, msg_hdr.o_end - msg_hdr.o_start, &bytes_read) == REC_ERR_FAIL) { goto Lerror; } @@ -306,7 +305,7 @@ RecMessageWriteToDisk(RecMessage *msg, const char *fpath) msg_size = sizeof(RecMessageHdr) + (msg->o_write - msg->o_start); if ((h_file = RecFileOpenW(fpath)) != REC_HANDLE_INVALID) { - if (RecFileWrite(h_file, (char *) msg, msg_size, &bytes_written) == REC_ERR_FAIL) { + if (RecFileWrite(h_file, (char *)msg, msg_size, &bytes_written) == REC_ERR_FAIL) { RecFileClose(h_file); return REC_ERR_FAIL; } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/RecMutex.cc ---------------------------------------------------------------------- diff --git a/lib/records/RecMutex.cc b/lib/records/RecMutex.cc index 797e285..63bdc97 100644 --- a/lib/records/RecMutex.cc +++ b/lib/records/RecMutex.cc @@ -25,7 +25,7 @@ #include "I_RecMutex.h" int -rec_mutex_init(RecMutex * m, const char *name) +rec_mutex_init(RecMutex *m, const char *name) { m->nthread_holding = 0; m->thread_holding = 0; @@ -33,7 +33,7 @@ rec_mutex_init(RecMutex * m, const char *name) } int -rec_mutex_destroy(RecMutex * m) +rec_mutex_destroy(RecMutex *m) { ink_assert(m->nthread_holding == 0); ink_assert(m->thread_holding == 0); @@ -41,9 +41,8 @@ rec_mutex_destroy(RecMutex * m) } int -rec_mutex_acquire(RecMutex * m) +rec_mutex_acquire(RecMutex *m) { - ink_thread this_thread = ink_thread_self(); if (m->thread_holding != this_thread) { @@ -56,9 +55,8 @@ rec_mutex_acquire(RecMutex * m) } int -rec_mutex_release(RecMutex * m) +rec_mutex_release(RecMutex *m) { - if (m->nthread_holding != 0) { m->nthread_holding--; if (m->nthread_holding == 0) { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/RecProcess.cc ---------------------------------------------------------------------- diff --git a/lib/records/RecProcess.cc b/lib/records/RecProcess.cc index de47227..f0c59bb 100644 --- a/lib/records/RecProcess.cc +++ b/lib/records/RecProcess.cc @@ -88,7 +88,8 @@ i_am_the_record_owner(RecT rec_type) // Simple setters for the intervals to decouple this from the proxy //------------------------------------------------------------------------- void -RecProcess_set_raw_stat_sync_interval_ms(int ms) { +RecProcess_set_raw_stat_sync_interval_ms(int ms) +{ Debug("statsproc", "g_rec_raw_stat_sync_interval_ms -> %d", ms); g_rec_raw_stat_sync_interval_ms = ms; if (raw_stat_sync_cont_event) { @@ -97,7 +98,8 @@ RecProcess_set_raw_stat_sync_interval_ms(int ms) { } } void -RecProcess_set_config_update_interval_ms(int ms) { +RecProcess_set_config_update_interval_ms(int ms) +{ Debug("statsproc", "g_rec_config_update_interval_ms -> %d", ms); g_rec_config_update_interval_ms = ms; if (config_update_cont_event) { @@ -106,7 +108,8 @@ RecProcess_set_config_update_interval_ms(int ms) { } } void -RecProcess_set_remote_sync_interval_ms(int ms) { +RecProcess_set_remote_sync_interval_ms(int ms) +{ Debug("statsproc", "g_rec_remote_sync_interval_ms -> %d", ms); g_rec_remote_sync_interval_ms = ms; if (sync_cont_event) { @@ -133,13 +136,13 @@ raw_stat_get_total(RecRawStatBlock *rsb, int id, RecRawStat *total) // get thread local values for (i = 0; i < eventProcessor.n_ethreads; i++) { - tlp = ((RecRawStat *) ((char *) (eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset)) + id; + tlp = ((RecRawStat *)((char *)(eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset)) + id; total->sum += tlp->sum; total->count += tlp->count; } for (i = 0; i < eventProcessor.n_dthreads; i++) { - tlp = ((RecRawStat *) ((char *) (eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset)) + id; + tlp = ((RecRawStat *)((char *)(eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset)) + id; total->sum += tlp->sum; total->count += tlp->count; } @@ -167,13 +170,13 @@ raw_stat_sync_to_global(RecRawStatBlock *rsb, int id) // sum the thread local values for (i = 0; i < eventProcessor.n_ethreads; i++) { - tlp = ((RecRawStat *) ((char *) (eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset)) + id; + tlp = ((RecRawStat *)((char *)(eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset)) + id; total.sum += tlp->sum; total.count += tlp->count; } for (i = 0; i < eventProcessor.n_dthreads; i++) { - tlp = ((RecRawStat *) ((char *) (eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset)) + id; + tlp = ((RecRawStat *)((char *)(eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset)) + id; total.sum += tlp->sum; total.count += tlp->count; } @@ -191,8 +194,9 @@ raw_stat_sync_to_global(RecRawStatBlock *rsb, int id) delta.count = total.count - rsb->global[id]->last_count; // This is too verbose now, so leaving it out / leif - //Debug("stats", "raw_stat_sync_to_global(): rsb pointer:%p id:%d delta:%" PRId64 " total:%" PRId64 " last:%" PRId64 " global:%" PRId64 "\n", - //rsb, id, delta.sum, total.sum, rsb->global[id]->last_sum, rsb->global[id]->sum); + // Debug("stats", "raw_stat_sync_to_global(): rsb pointer:%p id:%d delta:%" PRId64 " total:%" PRId64 " last:%" PRId64 " global:%" + // PRId64 "\n", + // rsb, id, delta.sum, total.sum, rsb->global[id]->last_sum, rsb->global[id]->sum); // increment the global values by the delta ink_atomic_increment(&(rsb->global[id]->sum), delta.sum); @@ -228,13 +232,13 @@ raw_stat_clear(RecRawStatBlock *rsb, int id) // reset the local stats RecRawStat *tlp; for (int i = 0; i < eventProcessor.n_ethreads; i++) { - tlp = ((RecRawStat *) ((char *) (eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset)) + id; + tlp = ((RecRawStat *)((char *)(eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset)) + id; ink_atomic_swap(&(tlp->sum), (int64_t)0); ink_atomic_swap(&(tlp->count), (int64_t)0); } for (int i = 0; i < eventProcessor.n_dthreads; i++) { - tlp = ((RecRawStat *) ((char *) (eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset)) + id; + tlp = ((RecRawStat *)((char *)(eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset)) + id; ink_atomic_swap(&(tlp->sum), (int64_t)0); ink_atomic_swap(&(tlp->count), (int64_t)0); } @@ -261,12 +265,12 @@ raw_stat_clear_sum(RecRawStatBlock *rsb, int id) // reset the local stats RecRawStat *tlp; for (int i = 0; i < eventProcessor.n_ethreads; i++) { - tlp = ((RecRawStat *) ((char *) (eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset)) + id; + tlp = ((RecRawStat *)((char *)(eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset)) + id; ink_atomic_swap(&(tlp->sum), (int64_t)0); } for (int i = 0; i < eventProcessor.n_dthreads; i++) { - tlp = ((RecRawStat *) ((char *) (eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset)) + id; + tlp = ((RecRawStat *)((char *)(eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset)) + id; ink_atomic_swap(&(tlp->sum), (int64_t)0); } @@ -292,12 +296,12 @@ raw_stat_clear_count(RecRawStatBlock *rsb, int id) // reset the local stats RecRawStat *tlp; for (int i = 0; i < eventProcessor.n_ethreads; i++) { - tlp = ((RecRawStat *) ((char *) (eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset)) + id; + tlp = ((RecRawStat *)((char *)(eventProcessor.all_ethreads[i]) + rsb->ethr_stat_offset)) + id; ink_atomic_swap(&(tlp->count), (int64_t)0); } for (int i = 0; i < eventProcessor.n_dthreads; i++) { - tlp = ((RecRawStat *) ((char *) (eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset)) + id; + tlp = ((RecRawStat *)((char *)(eventProcessor.all_dthreads[i]) + rsb->ethr_stat_offset)) + id; ink_atomic_swap(&(tlp->count), (int64_t)0); } @@ -327,15 +331,11 @@ recv_message_cb__process(RecMessage *msg, RecMessageT msg_type, void *cookie) //------------------------------------------------------------------------- // raw_stat_sync_cont //------------------------------------------------------------------------- -struct raw_stat_sync_cont: public Continuation -{ - raw_stat_sync_cont(ProxyMutex *m) - : Continuation(m) - { - SET_HANDLER(&raw_stat_sync_cont::exec_callbacks); - } +struct raw_stat_sync_cont : public Continuation { + raw_stat_sync_cont(ProxyMutex *m) : Continuation(m) { SET_HANDLER(&raw_stat_sync_cont::exec_callbacks); } - int exec_callbacks(int /* event */, Event * /* e */) + int + exec_callbacks(int /* event */, Event * /* e */) { RecExecRawStatSyncCbs(); Debug("statsproc", "raw_stat_sync_cont() processed"); @@ -348,15 +348,11 @@ struct raw_stat_sync_cont: public Continuation //------------------------------------------------------------------------- // config_update_cont //------------------------------------------------------------------------- -struct config_update_cont: public Continuation -{ - config_update_cont(ProxyMutex *m) - : Continuation(m) - { - SET_HANDLER(&config_update_cont::exec_callbacks); - } +struct config_update_cont : public Continuation { + config_update_cont(ProxyMutex *m) : Continuation(m) { SET_HANDLER(&config_update_cont::exec_callbacks); } - int exec_callbacks(int /* event */, Event * /* e */) + int + exec_callbacks(int /* event */, Event * /* e */) { RecExecConfigUpdateCbs(REC_PROCESS_UPDATE_REQUIRED); Debug("statsproc", "config_update_cont() processed"); @@ -369,18 +365,16 @@ struct config_update_cont: public Continuation //------------------------------------------------------------------------- // sync_cont //------------------------------------------------------------------------- -struct sync_cont: public Continuation -{ +struct sync_cont : public Continuation { textBuffer *m_tb; - sync_cont(ProxyMutex *m) - : Continuation(m) + sync_cont(ProxyMutex *m) : Continuation(m) { SET_HANDLER(&sync_cont::sync); m_tb = new textBuffer(65536); } - ~sync_cont() + ~sync_cont() { if (m_tb != NULL) { delete m_tb; @@ -388,12 +382,13 @@ struct sync_cont: public Continuation } } - int sync(int /* event */, Event * /* e */) + int + sync(int /* event */, Event * /* e */) { send_push_message(); RecSyncStatsFile(); if (RecSyncConfigToTB(m_tb) == REC_ERR_OKAY) { - RecWriteConfigFile(m_tb); + RecWriteConfigFile(m_tb); } Debug("statsproc", "sync_cont() processed"); @@ -533,7 +528,7 @@ RecAllocateRawStatBlock(int num_stats) memset(rsb->global, 0, num_stats * sizeof(RecRawStat *)); rsb->num_stats = 0; rsb->max_stats = num_stats; - ink_mutex_init(&(rsb->mutex),"net stat mutex"); + ink_mutex_init(&(rsb->mutex), "net stat mutex"); return rsb; } @@ -543,7 +538,7 @@ RecAllocateRawStatBlock(int num_stats) //------------------------------------------------------------------------- int _RecRegisterRawStat(RecRawStatBlock *rsb, RecT rec_type, const char *name, RecDataT data_type, RecPersistT persist_type, int id, - RecRawStatSyncCb sync_cb) + RecRawStatSyncCb sync_cb) { Debug("stats", "RecRawStatSyncCb(%s): rsb pointer:%p id:%d\n", name, rsb, id); @@ -626,7 +621,7 @@ RecRawStatSyncAvg(const char *name, RecDataT data_type, RecData *data, RecRawSta total.sum = rsb->global[id]->sum; total.count = rsb->global[id]->count; if (total.count != 0) - avg = (float) ((double) total.sum / (double) total.count); + avg = (float)((double)total.sum / (double)total.count); RecDataSetFromFloat(data_type, data, avg); return REC_ERR_OKAY; } @@ -644,8 +639,8 @@ RecRawStatSyncHrTimeAvg(const char *name, RecDataT data_type, RecData *data, Rec if (total.count == 0) { r = 0.0f; } else { - r = (float) ((double) total.sum / (double) total.count); - r = r / (float) (HRTIME_SECOND); + r = (float)((double)total.sum / (double)total.count); + r = r / (float)(HRTIME_SECOND); } RecDataSetFromFloat(data_type, data, r); return REC_ERR_OKAY; @@ -664,7 +659,7 @@ RecRawStatSyncIntMsecsToFloatSeconds(const char *name, RecDataT data_type, RecDa if (total.count == 0) { r = 0.0f; } else { - r = (float) ((double) total.sum / 1000); + r = (float)((double)total.sum / 1000); } RecDataSetFromFloat(data_type, data, r); return REC_ERR_OKAY; @@ -683,8 +678,8 @@ RecRawStatSyncMHrTimeAvg(const char *name, RecDataT data_type, RecData *data, Re if (total.count == 0) { r = 0.0f; } else { - r = (float) ((double) total.sum / (double) total.count); - r = r / (float) (HRTIME_MSECOND); + r = (float)((double)total.sum / (double)total.count); + r = r / (float)(HRTIME_MSECOND); } RecDataSetFromFloat(data_type, data, r); return REC_ERR_OKAY; @@ -695,8 +690,8 @@ RecRawStatSyncMHrTimeAvg(const char *name, RecDataT data_type, RecData *data, Re // RecIncrRawStatXXX //------------------------------------------------------------------------- int -RecIncrRawStatBlock(RecRawStatBlock */* rsb ATS_UNUSED */, EThread */* ethread ATS_UNUSED */, - RecRawStat */* stat_array ATS_UNUSED */) +RecIncrRawStatBlock(RecRawStatBlock * /* rsb ATS_UNUSED */, EThread * /* ethread ATS_UNUSED */, + RecRawStat * /* stat_array ATS_UNUSED */) { return REC_ERR_FAIL; } @@ -722,7 +717,7 @@ RecSetRawStatCount(RecRawStatBlock *rsb, int id, int64_t data) } int -RecSetRawStatBlock(RecRawStatBlock */* rsb ATS_UNUSED */, RecRawStat */* stat_array ATS_UNUSED */) +RecSetRawStatBlock(RecRawStatBlock * /* rsb ATS_UNUSED */, RecRawStat * /* stat_array ATS_UNUSED */) { return REC_ERR_FAIL; } @@ -847,7 +842,7 @@ RecRegisterRawStatSyncCb(const char *name, RecRawStatSyncCb sync_cb, RecRawStatB RecRecord *r; ink_rwlock_rdlock(&g_records_rwlock); - if (ink_hash_table_lookup(g_records_ht, name, (void **) &r)) { + if (ink_hash_table_lookup(g_records_ht, name, (void **)&r)) { rec_mutex_acquire(&(r->lock)); if (REC_TYPE_IS_STAT(r->rec_type)) { if (!(r->stat_meta.sync_cb)) { @@ -887,7 +882,7 @@ RecExecRawStatSyncCbs() raw_stat_clear(r->stat_meta.sync_rsb, r->stat_meta.sync_id); r->stat_meta.sync_rsb->global[r->stat_meta.sync_id]->version = r->version; } else { - (*(r->stat_meta.sync_cb)) (r->name, r->data_type, &(r->data), r->stat_meta.sync_rsb, r->stat_meta.sync_id); + (*(r->stat_meta.sync_cb))(r->name, r->data_type, &(r->data), r->stat_meta.sync_rsb, r->stat_meta.sync_id); } r->sync_required = REC_SYNC_REQUIRED; } @@ -899,7 +894,7 @@ RecExecRawStatSyncCbs() } void -RecSignalManager(int id, const char * msg, size_t msgsize) +RecSignalManager(int id, const char *msg, size_t msgsize) { ink_assert(pmgmt); pmgmt->signalManager(id, msg, msgsize); @@ -916,7 +911,7 @@ RecRegisterManagerCb(int _signal, RecManagerCb _fn, void *_data) //------------------------------------------------------------------------- int -RecMessageSend(RecMessage * msg) +RecMessageSend(RecMessage *msg) { int msg_size; @@ -927,9 +922,8 @@ RecMessageSend(RecMessage * msg) if (g_mode_type == RECM_CLIENT || g_mode_type == RECM_SERVER) { msg->o_end = msg->o_write; msg_size = sizeof(RecMessageHdr) + (msg->o_write - msg->o_start); - pmgmt->signalManager(MGMT_SIGNAL_LIBRECORDS, (char *) msg, msg_size); + pmgmt->signalManager(MGMT_SIGNAL_LIBRECORDS, (char *)msg, msg_size); } return REC_ERR_OKAY; } - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/RecUtils.cc ---------------------------------------------------------------------- diff --git a/lib/records/RecUtils.cc b/lib/records/RecUtils.cc index bee8eec..cd9246b 100644 --- a/lib/records/RecUtils.cc +++ b/lib/records/RecUtils.cc @@ -44,7 +44,7 @@ RecRecordFree(RecRecord *r) //------------------------------------------------------------------------- // RecAlloc //------------------------------------------------------------------------- -RecRecord* +RecRecord * RecAlloc(RecT rec_type, const char *name, RecDataT data_type) { if (g_num_records >= REC_MAX_RECORDS) { @@ -69,7 +69,7 @@ RecAlloc(RecT rec_type, const char *name, RecDataT data_type) // RecDataClear //------------------------------------------------------------------------- void -RecDataClear(RecDataT data_type, RecData * data) +RecDataClear(RecDataT data_type, RecData *data) { if ((data_type == RECD_STRING) && (data->rec_string)) { ats_free(data->rec_string); @@ -78,7 +78,7 @@ RecDataClear(RecDataT data_type, RecData * data) } void -RecDataSetMax(RecDataT type, RecData * data) +RecDataSetMax(RecDataT type, RecData *data) { switch (type) { #if defined(STAT_PROCESSOR) @@ -100,7 +100,7 @@ RecDataSetMax(RecDataT type, RecData * data) } void -RecDataSetMin(RecDataT type, RecData * data) +RecDataSetMin(RecDataT type, RecData *data) { switch (type) { #if defined(STAT_PROCESSOR) @@ -125,7 +125,7 @@ RecDataSetMin(RecDataT type, RecData * data) // RecDataSet //------------------------------------------------------------------------- bool -RecDataSet(RecDataT data_type, RecData * data_dst, RecData * data_src) +RecDataSet(RecDataT data_type, RecData *data_dst, RecData *data_src) { bool rec_set = false; @@ -174,7 +174,6 @@ RecDataSet(RecDataT data_type, RecData * data_dst, RecData * data_src) ink_assert(!"Wrong RECD type!"); } return rec_set; - } int @@ -320,7 +319,7 @@ RecDataDiv(RecDataT type, RecData left, RecData right) // RecDataSetFromInk64 //------------------------------------------------------------------------- bool -RecDataSetFromInk64(RecDataT data_type, RecData * data_dst, int64_t data_int64) +RecDataSetFromInk64(RecDataT data_type, RecData *data_dst, int64_t data_int64) { switch (data_type) { #if defined(STAT_PROCESSOR) @@ -333,17 +332,16 @@ RecDataSetFromInk64(RecDataT data_type, RecData * data_dst, int64_t data_int64) case RECD_CONST: #endif case RECD_FLOAT: - data_dst->rec_float = (float) (data_int64); + data_dst->rec_float = (float)(data_int64); break; - case RECD_STRING: - { - char buf[32 + 1]; + case RECD_STRING: { + char buf[32 + 1]; - ats_free(data_dst->rec_string); - snprintf(buf, 32, "%" PRId64 "", data_int64); - data_dst->rec_string = ats_strdup(buf); - break; - } + ats_free(data_dst->rec_string); + snprintf(buf, 32, "%" PRId64 "", data_int64); + data_dst->rec_string = ats_strdup(buf); + break; + } case RECD_COUNTER: data_dst->rec_counter = data_int64; break; @@ -360,32 +358,31 @@ RecDataSetFromInk64(RecDataT data_type, RecData * data_dst, int64_t data_int64) // RecDataSetFromFloat //------------------------------------------------------------------------- bool -RecDataSetFromFloat(RecDataT data_type, RecData * data_dst, float data_float) +RecDataSetFromFloat(RecDataT data_type, RecData *data_dst, float data_float) { switch (data_type) { #if defined(STAT_PROCESSOR) case RECD_FX: #endif case RECD_INT: - data_dst->rec_int = (RecInt) data_float; + data_dst->rec_int = (RecInt)data_float; break; #if defined(STAT_PROCESSOR) case RECD_CONST: #endif case RECD_FLOAT: - data_dst->rec_float = (float) (data_float); + data_dst->rec_float = (float)(data_float); break; - case RECD_STRING: - { - char buf[32 + 1]; + case RECD_STRING: { + char buf[32 + 1]; - ats_free(data_dst->rec_string); - snprintf(buf, 32, "%f", data_float); - data_dst->rec_string = ats_strdup(buf); - break; - } + ats_free(data_dst->rec_string); + snprintf(buf, 32, "%f", data_float); + data_dst->rec_string = ats_strdup(buf); + break; + } case RECD_COUNTER: - data_dst->rec_counter = (RecCounter) data_float; + data_dst->rec_counter = (RecCounter)data_float; break; default: ink_assert(!"Unexpected RecD type"); @@ -400,7 +397,7 @@ RecDataSetFromFloat(RecDataT data_type, RecData * data_dst, float data_float) // RecDataSetFromString //------------------------------------------------------------------------- bool -RecDataSetFromString(RecDataT data_type, RecData * data_dst, const char *data_string) +RecDataSetFromString(RecDataT data_type, RecData *data_dst, const char *data_string) { bool rec_set; RecData data_src; @@ -437,4 +434,3 @@ RecDataSetFromString(RecDataT data_type, RecData * data_dst, const char *data_st return rec_set; } - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/test_I_RecLocal.cc ---------------------------------------------------------------------- diff --git a/lib/records/test_I_RecLocal.cc b/lib/records/test_I_RecLocal.cc index b545f92..5616f66 100644 --- a/lib/records/test_I_RecLocal.cc +++ b/lib/records/test_I_RecLocal.cc @@ -41,10 +41,9 @@ int g_config_update_result = 0; int cb_test_1a(const char *name, RecDataT data_type, RecData data, void *cookie) { - if ((cookie == (void *) 0x12345678) && (strcmp(data.rec_string, "cb_test_1__changed") == 0)) { + if ((cookie == (void *)0x12345678) && (strcmp(data.rec_string, "cb_test_1__changed") == 0)) { g_config_update_result++; - printf(" - cb_test_1(%d) name: %s, data: %s, cookie: 0x%x\n", - g_config_update_result, name, data.rec_string, cookie); + printf(" - cb_test_1(%d) name: %s, data: %s, cookie: 0x%x\n", g_config_update_result, name, data.rec_string, cookie); } else { g_config_update_result = 0; } @@ -58,8 +57,8 @@ cb_test_1b(const char *name, RecDataT data_type, RecData data, void *cookie) } int -cb_test_2a(const char */* name ATS_UNUSED */, RecDataT /* data_type ATS_UNUSED */, - RecData /* data ATS_UNUSED */, void */* cookie ATS_UNUSED */) +cb_test_2a(const char * /* name ATS_UNUSED */, RecDataT /* data_type ATS_UNUSED */, RecData /* data ATS_UNUSED */, + void * /* cookie ATS_UNUSED */) { g_config_update_result = -1; return REC_ERR_FAIL; @@ -87,10 +86,10 @@ Test01() sleep(2 * REC_CONFIG_UPDATE_INTERVAL_SEC); // Register config update callbacks - RecRegisterConfigUpdateCb("proxy.config.local.cb_test_1", cb_test_1a, (void *) 0x12345678); - RecRegisterConfigUpdateCb("proxy.config.local.cb_test_1", cb_test_1b, (void *) 0x12345678); - RecRegisterConfigUpdateCb("proxy.config.local.cb_test_2", cb_test_2a, (void *) 0x87654321); - RecRegisterConfigUpdateCb("proxy.config.local.cb_test_2", cb_test_2b, (void *) 0x87654321); + RecRegisterConfigUpdateCb("proxy.config.local.cb_test_1", cb_test_1a, (void *)0x12345678); + RecRegisterConfigUpdateCb("proxy.config.local.cb_test_1", cb_test_1b, (void *)0x12345678); + RecRegisterConfigUpdateCb("proxy.config.local.cb_test_2", cb_test_2a, (void *)0x87654321); + RecRegisterConfigUpdateCb("proxy.config.local.cb_test_2", cb_test_2b, (void *)0x87654321); // Change proxy.config.cb_test_1 RecSetRecordString("proxy.config.local.cb_test_1", "cb_test_1__changed"); @@ -103,7 +102,6 @@ Test01() } else { printf(" SUMMARY: FAIL (%d)\n", g_config_update_result); } - } @@ -121,9 +119,7 @@ cb_test_3a(const char *name, RecDataT data_type, RecData data, void *cookie) RecString rec_result; int rec_status = RecGetRecordString_Xmalloc(name, &rec_result); - if ((rec_status == REC_ERR_OKAY) && - (cookie == (void *) 0x12344321) && (strcmp(rec_result, "cb_test_3__changed") == 0)) { - + if ((rec_status == REC_ERR_OKAY) && (cookie == (void *)0x12344321) && (strcmp(rec_result, "cb_test_3__changed") == 0)) { ink_assert(strcmp(rec_result, data.rec_string) == 0); g_config_update_result++; @@ -155,8 +151,8 @@ Test02() sleep(2 * REC_CONFIG_UPDATE_INTERVAL_SEC); // Register config update callbacks - RecRegisterConfigUpdateCb("proxy.config.local.cb_test_3", cb_test_3a, (void *) 0x12344321); - RecRegisterConfigUpdateCb("proxy.config.local.cb_test_3", cb_test_3b, (void *) 0x12344321); + RecRegisterConfigUpdateCb("proxy.config.local.cb_test_3", cb_test_3a, (void *)0x12344321); + RecRegisterConfigUpdateCb("proxy.config.local.cb_test_3", cb_test_3b, (void *)0x12344321); // Change proxy.config.cb_test_1 RecSetRecordString("proxy.config.local.cb_test_3", "cb_test_3__changed"); @@ -169,7 +165,6 @@ Test02() } else { printf(" SUMMARY: FAIL (%d)\n", g_config_update_result); } - } @@ -200,9 +195,9 @@ main(int argc, char **argv) RecLocalStart(); // test - Test01(); // Local callbacks - Test02(); // Local callbacks -- mulit-lock - Test03(); // RecTree + Test01(); // Local callbacks + Test02(); // Local callbacks -- mulit-lock + Test03(); // RecTree while (true) { RecDumpRecordsHt(RECT_NULL); @@ -210,5 +205,4 @@ main(int argc, char **argv) } return 0; - } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/records/test_RecordsConfig.cc ---------------------------------------------------------------------- diff --git a/lib/records/test_RecordsConfig.cc b/lib/records/test_RecordsConfig.cc index e62e4a8..da1daa2 100644 --- a/lib/records/test_RecordsConfig.cc +++ b/lib/records/test_RecordsConfig.cc @@ -30,7 +30,6 @@ void RecordsConfigRegister() { - RecRegisterConfigString(RECT_CONFIG, "proxy.config.parse_test_2a", NULL, RECU_DYNAMIC, RECC_NULL, NULL); RecRegisterConfigString(RECT_CONFIG, "proxy.config.parse_test_2b", NULL, RECU_DYNAMIC, RECC_NULL, NULL); RecRegisterConfigString(RECT_CONFIG, "proxy.config.parse_test_3a", NULL, RECU_DYNAMIC, RECC_NULL, NULL); @@ -40,12 +39,9 @@ RecordsConfigRegister() RecRegisterConfigString(RECT_CONFIG, "proxy.config.cb_test_1", "cb_test_1__original", RECU_DYNAMIC, RECC_NULL, NULL); RecRegisterConfigString(RECT_CONFIG, "proxy.config.cb_test_2", "cb_test_2__original", RECU_DYNAMIC, RECC_NULL, NULL); - RecRegisterConfigString(RECT_CONFIG, "proxy.config.local.cb_test_1", "cb_test_1__original", RECU_DYNAMIC, RECC_NULL, - NULL); - RecRegisterConfigString(RECT_CONFIG, "proxy.config.local.cb_test_2", "cb_test_2__original", RECU_DYNAMIC, RECC_NULL, - NULL); - RecRegisterConfigString(RECT_CONFIG, "proxy.config.local.cb_test_3", "cb_test_3__original", RECU_DYNAMIC, RECC_NULL, - NULL); + RecRegisterConfigString(RECT_CONFIG, "proxy.config.local.cb_test_1", "cb_test_1__original", RECU_DYNAMIC, RECC_NULL, NULL); + RecRegisterConfigString(RECT_CONFIG, "proxy.config.local.cb_test_2", "cb_test_2__original", RECU_DYNAMIC, RECC_NULL, NULL); + RecRegisterConfigString(RECT_CONFIG, "proxy.config.local.cb_test_3", "cb_test_3__original", RECU_DYNAMIC, RECC_NULL, NULL); RecRegisterConfigInt(RECT_CONFIG, "proxy.config.link_test_1", 0, RECU_DYNAMIC, RECC_NULL, NULL); RecRegisterConfigFloat(RECT_CONFIG, "proxy.config.link_test_2", 0.0f, RECU_DYNAMIC, RECC_NULL, NULL); RecRegisterConfigCounter(RECT_CONFIG, "proxy.config.link_test_3", 0, RECU_DYNAMIC, RECC_NULL, NULL); @@ -56,5 +52,4 @@ RecordsConfigRegister() RecRegisterStatInt(RECT_NODE, "proxy.node.cb_test_int", 0, RECP_NON_PERSISTENT); RecRegisterStatFloat(RECT_NODE, "proxy.node.cb_test_float", 0.0f, RECP_NON_PERSISTENT); RecRegisterStatCounter(RECT_NODE, "proxy.node.cb_test_count", 0, RECP_NON_PERSISTENT); - } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/Allocator.h ---------------------------------------------------------------------- diff --git a/lib/ts/Allocator.h b/lib/ts/Allocator.h index 9f4edde..b243901 100644 --- a/lib/ts/Allocator.h +++ b/lib/ts/Allocator.h @@ -45,7 +45,7 @@ #include "ink_defs.h" #include "ink_resource.h" -#define RND16(_x) (((_x)+15)&~15) +#define RND16(_x) (((_x) + 15) & ~15) /** Allocator for fixed size memory blocks. */ class Allocator @@ -75,10 +75,7 @@ public: ink_freelist_free_bulk(this->fl, head, tail, num_item); } - Allocator() - { - fl = NULL; - } + Allocator() { fl = NULL; } /** Creates a new allocator. @@ -88,8 +85,7 @@ public: @param chunk_size number of units to be allocated if free pool is empty. @param alignment of objects must be a power of 2. */ - Allocator(const char *name, unsigned int element_size, - unsigned int chunk_size = 128, unsigned int alignment = 8) + Allocator(const char *name, unsigned int element_size, unsigned int chunk_size = 128, unsigned int alignment = 8) { ink_freelist_init(&fl, name, element_size, chunk_size, alignment); } @@ -114,16 +110,17 @@ protected: copied onto the new objects. This is done for performance reasons. */ -template<class C> class ClassAllocator: public Allocator { +template <class C> class ClassAllocator : public Allocator +{ public: /** Allocates objects of the templated type. */ - C* + C * alloc() { void *ptr = ink_freelist_new(this->fl); memcpy(ptr, (void *)&this->proto.typeObject, sizeof(C)); - return (C *) ptr; + return (C *)ptr; } /** @@ -132,7 +129,7 @@ public: @param ptr pointer to be freed. */ void - free(C * ptr) + free(C *ptr) { ink_freelist_free(this->fl, ptr); } @@ -154,10 +151,10 @@ public: Allocate objects of the templated type via the inherited interface using void pointers. */ - void* + void * alloc_void() { - return (void *) alloc(); + return (void *)alloc(); } /** @@ -169,7 +166,7 @@ public: void free_void(void *ptr) { - free((C *) ptr); + free((C *)ptr); } /** @@ -183,7 +180,7 @@ public: void free_void_bulk(void *head, void *tail, size_t num_item) { - free_bulk((C *) head, (C *) tail, num_item); + free_bulk((C *)head, (C *)tail, num_item); } /** @@ -193,14 +190,12 @@ public: @param chunk_size number of units to be allocated if free pool is empty. @param alignment of objects must be a power of 2. */ - ClassAllocator(const char *name, unsigned int chunk_size = 128, - unsigned int alignment = 16) + ClassAllocator(const char *name, unsigned int chunk_size = 128, unsigned int alignment = 16) { ink_freelist_init(&this->fl, name, RND16(sizeof(C)), chunk_size, RND16(alignment)); } - struct - { + struct { C typeObject; int64_t space_holder; } proto; @@ -216,11 +211,11 @@ public: all of the members. */ -template<class C> class SparseClassAllocator:public ClassAllocator<C> { +template <class C> class SparseClassAllocator : public ClassAllocator<C> +{ public: - /** Allocates objects of the templated type. */ - C* + C * alloc() { void *ptr = ink_freelist_new(this->fl); @@ -228,8 +223,8 @@ public: if (!_instantiate) { memcpy(ptr, (void *)&this->proto.typeObject, sizeof(C)); } else - (*_instantiate) ((C *) &this->proto.typeObject, (C *) ptr); - return (C *) ptr; + (*_instantiate)((C *)&this->proto.typeObject, (C *)ptr); + return (C *)ptr; } @@ -242,16 +237,15 @@ public: @param instantiate_func */ - SparseClassAllocator(const char *name, unsigned int chunk_size = 128, - unsigned int alignment = 16, - void (*instantiate_func) (C * proto, C * instance) = NULL) + SparseClassAllocator(const char *name, unsigned int chunk_size = 128, unsigned int alignment = 16, + void (*instantiate_func)(C *proto, C *instance) = NULL) : ClassAllocator<C>(name, chunk_size, alignment) { - _instantiate = instantiate_func; // NULL by default + _instantiate = instantiate_func; // NULL by default } private: - void (*_instantiate) (C* proto, C* instance); + void (*_instantiate)(C *proto, C *instance); }; -#endif // _Allocator_h_ +#endif // _Allocator_h_ http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/Arena.cc ---------------------------------------------------------------------- diff --git a/lib/ts/Arena.cc b/lib/ts/Arena.cc index 95e3cdd..6ab9bdb 100644 --- a/lib/ts/Arena.cc +++ b/lib/ts/Arena.cc @@ -26,8 +26,8 @@ #include <string.h> -#define DEFAULT_ALLOC_SIZE 1024 -#define DEFAULT_BLOCK_SIZE (DEFAULT_ALLOC_SIZE - (sizeof (ArenaBlock) - 8)) +#define DEFAULT_ALLOC_SIZE 1024 +#define DEFAULT_BLOCK_SIZE (DEFAULT_ALLOC_SIZE - (sizeof(ArenaBlock) - 8)) static Allocator defaultSizeArenaBlock("ArenaBlock", DEFAULT_ALLOC_SIZE); @@ -42,7 +42,7 @@ blk_alloc(int size) ArenaBlock *blk; if (size == DEFAULT_BLOCK_SIZE) { - blk = (ArenaBlock *) defaultSizeArenaBlock.alloc_void(); + blk = (ArenaBlock *)defaultSizeArenaBlock.alloc_void(); } else { blk = (ArenaBlock *)ats_malloc(size + sizeof(ArenaBlock) - 8); } @@ -58,7 +58,7 @@ blk_alloc(int size) -------------------------------------------------------------------------*/ static inline void -blk_free(ArenaBlock * blk) +blk_free(ArenaBlock *blk) { int size; @@ -75,16 +75,16 @@ blk_free(ArenaBlock * blk) -------------------------------------------------------------------------*/ static void * -block_alloc(ArenaBlock * block, size_t size, size_t alignment) +block_alloc(ArenaBlock *block, size_t size, size_t alignment) { char *mem; mem = block->m_water_level; - if (((size_t) mem) & (alignment - 1)) { - mem += (alignment - ((size_t) mem)) & (alignment - 1); + if (((size_t)mem) & (alignment - 1)) { + mem += (alignment - ((size_t)mem)) & (alignment - 1); } - if ((block->m_heap_end >= mem) && (((size_t) block->m_heap_end - (size_t) mem) >= size)) { + if ((block->m_heap_end >= mem) && (((size_t)block->m_heap_end - (size_t)mem) >= size)) { block->m_water_level = mem + size; return mem; } @@ -110,7 +110,7 @@ Arena::alloc(size_t size, size_t alignment) b = b->next; } - block_size = (unsigned int) (size * 1.5); + block_size = (unsigned int)(size * 1.5); if (block_size < DEFAULT_BLOCK_SIZE) { block_size = DEFAULT_BLOCK_SIZE; } @@ -137,8 +137,8 @@ Arena::free(void *mem, size_t size) b = b->next; } - if (b->m_water_level == ((char *) mem + size)) { - b->m_water_level = (char *) mem; + if (b->m_water_level == ((char *)mem + size)) { + b->m_water_level = (char *)mem; } } } http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/Arena.h ---------------------------------------------------------------------- diff --git a/lib/ts/Arena.h b/lib/ts/Arena.h index e3c26f5..0fda648 100644 --- a/lib/ts/Arena.h +++ b/lib/ts/Arena.h @@ -30,8 +30,7 @@ #include "ink_assert.h" -struct ArenaBlock -{ +struct ArenaBlock { ArenaBlock *next; char *m_heap_end; char *m_water_level; @@ -42,13 +41,8 @@ struct ArenaBlock class Arena { public: - Arena():m_blocks(NULL) - { - } - ~Arena() - { - reset(); - } + Arena() : m_blocks(NULL) {} + ~Arena() { reset(); } inkcoreapi void *alloc(size_t size, size_t alignment = sizeof(double)); void free(void *mem, size_t size); @@ -60,7 +54,7 @@ public: inkcoreapi void reset(); private: - ArenaBlock * m_blocks; + ArenaBlock *m_blocks; }; @@ -73,7 +67,7 @@ Arena::str_length(const char *str) unsigned char *s, *e; size_t len; - e = (unsigned char *) str; + e = (unsigned char *)str; s = e - 1; while (*s >= 128) { @@ -120,19 +114,19 @@ Arena::str_alloc(size_t len) tmp /= 128; } - mem = (unsigned char *) alloc(size, 1); + mem = (unsigned char *)alloc(size, 1); mem += (size - len - 1); p = mem - 1; tmp = len; while (tmp >= 128) { - *p-- = (unsigned char) (255 - (tmp % 128)); + *p-- = (unsigned char)(255 - (tmp % 128)); tmp /= 128; } - *p = (unsigned char) tmp; + *p = (unsigned char)tmp; - return (char *) mem; + return (char *)mem; } /*------------------------------------------------------------------------- @@ -144,7 +138,7 @@ Arena::str_free(char *str) unsigned char *p, *s, *e; size_t len; - e = (unsigned char *) str; + e = (unsigned char *)str; s = e - 1; while (*s >= 128) { @@ -179,4 +173,3 @@ Arena::str_store(const char *str, size_t len) #endif /* __ARENA_H__ */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/Bitops.cc ---------------------------------------------------------------------- diff --git a/lib/ts/Bitops.cc b/lib/ts/Bitops.cc index 44a9942..ee0a26f 100644 --- a/lib/ts/Bitops.cc +++ b/lib/ts/Bitops.cc @@ -25,39 +25,19 @@ unsigned char bit_table[256] = { - 0, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 7, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 8, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 7, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, - 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, + 0, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, + 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 7, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, + 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 8, + 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, + 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 7, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, + 1, 4, 1, 2, 1, 3, 1, 2, 1, 6, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, 5, 1, 2, 1, 3, 1, 2, 1, 4, 1, 2, 1, 3, 1, 2, 1, }; unsigned char bit_count_table[256] = { - 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, - 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, + 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, + 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, + 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 1, + 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, + 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6, 3, 4, 4, 5, 4, 5, 5, + 6, 4, 5, 5, 6, 5, 6, 6, 7, 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7, 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8, }; http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/Bitops.h ---------------------------------------------------------------------- diff --git a/lib/ts/Bitops.h b/lib/ts/Bitops.h index 76ed1f0..8bf7b59 100644 --- a/lib/ts/Bitops.h +++ b/lib/ts/Bitops.h @@ -136,7 +136,7 @@ bitops_next_set(unsigned char *start, unsigned char *end, int offset) idx = bit_table[*p]; if (idx) { c = *p; - while (idx && (idx <= (size_t) t)) { + while (idx && (idx <= (size_t)t)) { c &= ~(1 << (idx - 1)); idx = bit_table[c]; } @@ -153,10 +153,10 @@ bitops_next_set(unsigned char *start, unsigned char *end, int offset) idx -= 1; idx += (p - start) * 8; } else { - idx = (size_t) - 1; + idx = (size_t)-1; } - return (int) idx; + return (int)idx; } static inline int @@ -177,7 +177,7 @@ bitops_next_unset(unsigned char *start, unsigned char *end, int offset) c = ~(*p); idx = bit_table[c]; if (idx) { - while (idx && (idx <= (size_t) t)) { + while (idx && (idx <= (size_t)t)) { c &= ~(1 << (idx - 1)); idx = bit_table[c]; } @@ -194,10 +194,10 @@ bitops_next_unset(unsigned char *start, unsigned char *end, int offset) idx -= 1; idx += (p - start) * 8; } else { - idx = (size_t) - 1; + idx = (size_t)-1; } - return (int) idx; + return (int)idx; } static inline int @@ -272,4 +272,3 @@ bitops_isset(unsigned char *val, int bit) } #endif /* __BITOPS_H__ */ - http://git-wip-us.apache.org/repos/asf/trafficserver/blob/65477944/lib/ts/CompileParseRules.cc ---------------------------------------------------------------------- diff --git a/lib/ts/CompileParseRules.cc b/lib/ts/CompileParseRules.cc index 20a10f3..53406fe 100644 --- a/lib/ts/CompileParseRules.cc +++ b/lib/ts/CompileParseRules.cc @@ -25,9 +25,9 @@ #include "ParseRules.h" -const unsigned int parseRulesCType[256] = { 0 }; -const char parseRulesCTypeToUpper[256] = { 0 }; -const char parseRulesCTypeToLower[256] = { 0 }; +const unsigned int parseRulesCType[256] = {0}; +const char parseRulesCTypeToUpper[256] = {0}; +const char parseRulesCTypeToLower[256] = {0}; unsigned int tparseRulesCType[256]; char tparseRulesCTypeToUpper[256]; @@ -130,7 +130,7 @@ main() for (c = 0; c < 256; c++) { fprintf(fp, "/* %3d (%c) */\t", c, (isprint(c) ? c : '?')); fprintf(fp, "0x%08X%c\t\t", tparseRulesCType[c], (c != 255 ? ',' : ' ')); - fprintf(fp, "/* [%s] */\n", uint_to_binary((unsigned int) (tparseRulesCType[c]))); + fprintf(fp, "/* [%s] */\n", uint_to_binary((unsigned int)(tparseRulesCType[c]))); } fclose(fp); fp = fopen("ParseRulesCTypeToUpper", "w");
