Switch to clang-format-3.6

This commit is contained in:
Tatsuhiro Tsujikawa 2015-11-13 00:53:29 +09:00
parent 7c613386db
commit c6ef1c02b9
32 changed files with 255 additions and 274 deletions

View File

@ -27,7 +27,7 @@ We use clang-format to format source code consistently. The
clang-format configuration file .clang-format is located at the root
directory. Since clang-format produces slightly different results
between versions, we currently use clang-format which comes with
clang-3.5.
clang-3.6.
To detect any violation to the coding style, we recommend to setup git
pre-commit hook to check coding style of the changes you introduced.
@ -35,7 +35,7 @@ The pre-commit file is located at the root directory. Copy it under
.git/hooks and make sure that it is executable. The pre-commit script
uses clang-format-diff.py to detect any style errors. If it is not in
your PATH or it exists under different name (e.g.,
clang-format-diff-3.5 in debian), either add it to PATH variable or
clang-format-diff-3.6 in debian), either add it to PATH variable or
add git option ``clangformatdiff.binary`` to point to the script.
For emacs users, integrating clang-format to emacs is very easy.

View File

@ -459,10 +459,9 @@ static void ctl_poll(struct pollfd *pollfd, struct Connection *connection) {
static void submit_request(struct Connection *connection, struct Request *req) {
int32_t stream_id;
/* Make sure that the last item is NULL */
const nghttp2_nv nva[] = {MAKE_NV(":method", "GET"),
MAKE_NV_CS(":path", req->path),
MAKE_NV(":scheme", "https"),
MAKE_NV_CS(":authority", req->hostport),
const nghttp2_nv nva[] = {
MAKE_NV(":method", "GET"), MAKE_NV_CS(":path", req->path),
MAKE_NV(":scheme", "https"), MAKE_NV_CS(":authority", req->hostport),
MAKE_NV("accept", "*/*"),
MAKE_NV("user-agent", "nghttp2/" NGHTTP2_VERSION)};

View File

@ -2339,8 +2339,8 @@ NGHTTP2_EXTERN int nghttp2_session_send(nghttp2_session *session);
* buffer up small chunks of data as necessary to avoid this
* situation.
*/
NGHTTP2_EXTERN ssize_t nghttp2_session_mem_send(nghttp2_session *session,
const uint8_t **data_ptr);
NGHTTP2_EXTERN ssize_t
nghttp2_session_mem_send(nghttp2_session *session, const uint8_t **data_ptr);
/**
* @function
@ -2538,7 +2538,7 @@ nghttp2_session_set_stream_user_data(nghttp2_session *session,
* include the deferred DATA frames.
*/
NGHTTP2_EXTERN size_t
nghttp2_session_get_outbound_queue_size(nghttp2_session *session);
nghttp2_session_get_outbound_queue_size(nghttp2_session *session);
/**
* @function
@ -2554,8 +2554,9 @@ NGHTTP2_EXTERN size_t
*
* This function returns -1 if it fails.
*/
NGHTTP2_EXTERN int32_t nghttp2_session_get_stream_effective_recv_data_length(
nghttp2_session *session, int32_t stream_id);
NGHTTP2_EXTERN int32_t
nghttp2_session_get_stream_effective_recv_data_length(nghttp2_session *session,
int32_t stream_id);
/**
* @function
@ -2567,8 +2568,9 @@ NGHTTP2_EXTERN int32_t nghttp2_session_get_stream_effective_recv_data_length(
*
* This function returns -1 if it fails.
*/
NGHTTP2_EXTERN int32_t nghttp2_session_get_stream_effective_local_window_size(
nghttp2_session *session, int32_t stream_id);
NGHTTP2_EXTERN int32_t
nghttp2_session_get_stream_effective_local_window_size(nghttp2_session *session,
int32_t stream_id);
/**
* @function
@ -2585,7 +2587,7 @@ NGHTTP2_EXTERN int32_t nghttp2_session_get_stream_effective_local_window_size(
* This function returns -1 if it fails.
*/
NGHTTP2_EXTERN int32_t
nghttp2_session_get_effective_recv_data_length(nghttp2_session *session);
nghttp2_session_get_effective_recv_data_length(nghttp2_session *session);
/**
* @function
@ -2598,7 +2600,7 @@ NGHTTP2_EXTERN int32_t
* This function returns -1 if it fails.
*/
NGHTTP2_EXTERN int32_t
nghttp2_session_get_effective_local_window_size(nghttp2_session *session);
nghttp2_session_get_effective_local_window_size(nghttp2_session *session);
/**
* @function
@ -2615,7 +2617,7 @@ NGHTTP2_EXTERN int32_t
* This function returns -1 if it fails.
*/
NGHTTP2_EXTERN int32_t
nghttp2_session_get_stream_remote_window_size(nghttp2_session *session,
nghttp2_session_get_stream_remote_window_size(nghttp2_session *session,
int32_t stream_id);
/**
@ -2626,7 +2628,7 @@ NGHTTP2_EXTERN int32_t
* This function always succeeds.
*/
NGHTTP2_EXTERN int32_t
nghttp2_session_get_remote_window_size(nghttp2_session *session);
nghttp2_session_get_remote_window_size(nghttp2_session *session);
/**
* @function
@ -2752,7 +2754,7 @@ NGHTTP2_EXTERN int nghttp2_submit_shutdown_notice(nghttp2_session *session);
* :enum:`nghttp2_settings_id`.
*/
NGHTTP2_EXTERN uint32_t
nghttp2_session_get_remote_settings(nghttp2_session *session,
nghttp2_session_get_remote_settings(nghttp2_session *session,
nghttp2_settings_id id);
/**
@ -2782,7 +2784,7 @@ NGHTTP2_EXTERN int nghttp2_session_set_next_stream_id(nghttp2_session *session,
* function returns 1 << 31.
*/
NGHTTP2_EXTERN uint32_t
nghttp2_session_get_next_stream_id(nghttp2_session *session);
nghttp2_session_get_next_stream_id(nghttp2_session *session);
/**
* @function
@ -2970,7 +2972,7 @@ NGHTTP2_EXTERN int nghttp2_session_upgrade2(nghttp2_session *session,
* The provided |buflen| size is too small to hold the output.
*/
NGHTTP2_EXTERN ssize_t
nghttp2_pack_settings_payload(uint8_t *buf, size_t buflen,
nghttp2_pack_settings_payload(uint8_t *buf, size_t buflen,
const nghttp2_settings_entry *iv, size_t niv);
/**
@ -3082,7 +3084,7 @@ nghttp2_priority_spec_check_default(const nghttp2_priority_spec *pri_spec);
*
*/
NGHTTP2_EXTERN int32_t
nghttp2_submit_request(nghttp2_session *session,
nghttp2_submit_request(nghttp2_session *session,
const nghttp2_priority_spec *pri_spec,
const nghttp2_nv *nva, size_t nvlen,
const nghttp2_data_provider *data_prd,
@ -3297,9 +3299,8 @@ NGHTTP2_EXTERN int nghttp2_submit_trailer(nghttp2_session *session,
*
*/
NGHTTP2_EXTERN int32_t
nghttp2_submit_headers(nghttp2_session *session, uint8_t flags,
int32_t stream_id,
const nghttp2_priority_spec *pri_spec,
nghttp2_submit_headers(nghttp2_session *session, uint8_t flags,
int32_t stream_id, const nghttp2_priority_spec *pri_spec,
const nghttp2_nv *nva, size_t nvlen,
void *stream_user_data);
@ -3504,7 +3505,7 @@ NGHTTP2_EXTERN int nghttp2_submit_settings(nghttp2_session *session,
*
*/
NGHTTP2_EXTERN int32_t
nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags,
nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags,
int32_t stream_id, const nghttp2_nv *nva,
size_t nvlen, void *promised_stream_user_data);
@ -3595,7 +3596,7 @@ NGHTTP2_EXTERN int nghttp2_submit_goaway(nghttp2_session *session,
* This function always succeeds.
*/
NGHTTP2_EXTERN int32_t
nghttp2_session_get_last_proc_stream_id(nghttp2_session *session);
nghttp2_session_get_last_proc_stream_id(nghttp2_session *session);
/**
* @function
@ -3880,7 +3881,7 @@ nghttp2_hd_deflate_change_table_size(nghttp2_hd_deflater *deflater,
* The provided |buflen| size is too small to hold the output.
*/
NGHTTP2_EXTERN ssize_t
nghttp2_hd_deflate_hd(nghttp2_hd_deflater *deflater, uint8_t *buf,
nghttp2_hd_deflate_hd(nghttp2_hd_deflater *deflater, uint8_t *buf,
size_t buflen, const nghttp2_nv *nva, size_t nvlen);
/**
@ -4239,7 +4240,7 @@ typedef enum {
* :enum:`NGHTTP2_STREAM_STATE_IDLE`.
*/
NGHTTP2_EXTERN nghttp2_stream_proto_state
nghttp2_stream_get_state(nghttp2_stream *stream);
nghttp2_stream_get_state(nghttp2_stream *stream);
/**
* @function
@ -4302,7 +4303,7 @@ NGHTTP2_EXTERN int32_t nghttp2_stream_get_weight(nghttp2_stream *stream);
* Returns the sum of the weight for |stream|'s children.
*/
NGHTTP2_EXTERN int32_t
nghttp2_stream_get_sum_dependency_weight(nghttp2_stream *stream);
nghttp2_stream_get_sum_dependency_weight(nghttp2_stream *stream);
#ifdef __cplusplus
}

View File

@ -41,7 +41,7 @@
#define lstreq(A, B, N) ((sizeof((A)) - 1) == (N) && memcmp((A), (B), (N)) == 0)
#define nghttp2_struct_of(ptr, type, member) \
((type *)(void *)((char *)(ptr) - offsetof(type, member)))
((type *)(void *)((char *)(ptr)-offsetof(type, member)))
/*
* Copies 2 byte unsigned integer |n| in host byte order to |buf| in

View File

@ -610,9 +610,8 @@ void nghttp2_session_del(nghttp2_session *session) {
nghttp2_mem_free(mem, session);
}
int
nghttp2_session_reprioritize_stream(nghttp2_session *session,
nghttp2_stream *stream,
int nghttp2_session_reprioritize_stream(
nghttp2_session *session, nghttp2_stream *stream,
const nghttp2_priority_spec *pri_spec_in) {
int rv;
nghttp2_stream *dep_stream = NULL;

View File

@ -45,8 +45,8 @@ session_tls_impl::session_tls_impl(boost::asio::io_service &io_service,
session_tls_impl::~session_tls_impl() {}
void session_tls_impl::start_connect(tcp::resolver::iterator endpoint_it) {
boost::asio::async_connect(socket(), endpoint_it,
[this](const boost::system::error_code &ec,
boost::asio::async_connect(
socket(), endpoint_it, [this](const boost::system::error_code &ec,
tcp::resolver::iterator endpoint_it) {
if (ec) {
not_connected(ec);
@ -62,8 +62,8 @@ void session_tls_impl::start_connect(tcp::resolver::iterator endpoint_it) {
}
if (!tls_h2_negotiated(socket_)) {
not_connected(
make_error_code(NGHTTP2_ASIO_ERR_TLS_NO_APP_PROTO_NEGOTIATED));
not_connected(make_error_code(
NGHTTP2_ASIO_ERR_TLS_NO_APP_PROTO_NEGOTIATED));
return;
}

View File

@ -90,8 +90,9 @@ generator_cb string_generator(std::string data) {
}
generator_cb deferred_generator() {
return [](uint8_t *buf, size_t len,
uint32_t *data_flags) { return NGHTTP2_ERR_DEFERRED; };
return [](uint8_t *buf, size_t len, uint32_t *data_flags) {
return NGHTTP2_ERR_DEFERRED;
};
}
template <typename F, typename... T>

View File

@ -123,11 +123,13 @@ void server::start_accept(boost::asio::ssl::context &tls_context,
auto new_connection = std::make_shared<connection<ssl_socket>>(
mux, io_service_pool_.get_io_service(), tls_context);
acceptor.async_accept(new_connection->socket().lowest_layer(),
acceptor.async_accept(
new_connection->socket().lowest_layer(),
[this, &tls_context, &acceptor, &mux, new_connection](
const boost::system::error_code &e) {
if (!e) {
new_connection->socket().lowest_layer().set_option(tcp::no_delay(true));
new_connection->socket().lowest_layer().set_option(
tcp::no_delay(true));
new_connection->socket().async_handshake(
boost::asio::ssl::stream_base::server,
[new_connection](const boost::system::error_code &e) {
@ -151,8 +153,8 @@ void server::start_accept(tcp::acceptor &acceptor, serve_mux &mux) {
auto new_connection = std::make_shared<connection<tcp::socket>>(
mux, io_service_pool_.get_io_service());
acceptor.async_accept(new_connection->socket(),
[this, &acceptor, &mux, new_connection](
acceptor.async_accept(
new_connection->socket(), [this, &acceptor, &mux, new_connection](
const boost::system::error_code &e) {
if (!e) {
new_connection->socket().set_option(tcp::no_delay(true));

View File

@ -83,7 +83,8 @@ public:
void do_read() {
auto self = this->shared_from_this();
socket_.async_read_some(boost::asio::buffer(buffer_),
socket_.async_read_some(
boost::asio::buffer(buffer_),
[this, self](const boost::system::error_code &e,
std::size_t bytes_transferred) {
if (!e) {

View File

@ -119,20 +119,20 @@ nghttp2_nv make_nv_nocopy(const std::string &name, const std::string &value,
// Create nghttp2_nv from string literal |name| and |value|.
template <size_t N, size_t M>
constexpr nghttp2_nv make_nv_ll(const char (&name)[N], const char (&value)[M]) {
constexpr nghttp2_nv make_nv_ll(const char(&name)[N], const char(&value)[M]) {
return {(uint8_t *)name, (uint8_t *)value, N - 1, M - 1,
NGHTTP2_NV_FLAG_NO_COPY_NAME | NGHTTP2_NV_FLAG_NO_COPY_VALUE};
}
// Create nghttp2_nv from string literal |name| and c-string |value|.
template <size_t N>
nghttp2_nv make_nv_lc(const char (&name)[N], const char *value) {
nghttp2_nv make_nv_lc(const char(&name)[N], const char *value) {
return {(uint8_t *)name, (uint8_t *)value, N - 1, strlen(value),
NGHTTP2_NV_FLAG_NO_COPY_NAME};
}
template <size_t N>
nghttp2_nv make_nv_lc_nocopy(const char (&name)[N], const char *value) {
nghttp2_nv make_nv_lc_nocopy(const char(&name)[N], const char *value) {
return {(uint8_t *)name, (uint8_t *)value, N - 1, strlen(value),
NGHTTP2_NV_FLAG_NO_COPY_NAME | NGHTTP2_NV_FLAG_NO_COPY_VALUE};
}
@ -140,13 +140,13 @@ nghttp2_nv make_nv_lc_nocopy(const char (&name)[N], const char *value) {
// Create nghttp2_nv from string literal |name| and std::string
// |value|.
template <size_t N>
nghttp2_nv make_nv_ls(const char (&name)[N], const std::string &value) {
nghttp2_nv make_nv_ls(const char(&name)[N], const std::string &value) {
return {(uint8_t *)name, (uint8_t *)value.c_str(), N - 1, value.size(),
NGHTTP2_NV_FLAG_NO_COPY_NAME};
}
template <size_t N>
nghttp2_nv make_nv_ls_nocopy(const char (&name)[N], const std::string &value) {
nghttp2_nv make_nv_ls_nocopy(const char(&name)[N], const std::string &value) {
return {(uint8_t *)name, (uint8_t *)value.c_str(), N - 1, value.size(),
NGHTTP2_NV_FLAG_NO_COPY_NAME | NGHTTP2_NV_FLAG_NO_COPY_VALUE};
}

View File

@ -89,8 +89,8 @@ typedef std::function<void(uint32_t)> close_cb;
// are not available right now, return NGHTTP2_ERR_DEFERRED. In case
// of the error and request/response must be closed, return
// NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE.
typedef std::function<
ssize_t(uint8_t *buf, std::size_t len, uint32_t *data_flags)> generator_cb;
typedef std::function<ssize_t(uint8_t *buf, std::size_t len,
uint32_t *data_flags)> generator_cb;
// Convenient function to create function to read file denoted by
// |path|. This can be passed to response::end().

View File

@ -161,7 +161,7 @@ template <typename Memchunk> struct Memchunks {
return count;
}
template <size_t N> size_t append(const char (&s)[N]) {
template <size_t N> size_t append(const char(&s)[N]) {
return append(s, N - 1);
}
size_t append(const std::string &s) { return append(s.c_str(), s.size()); }

View File

@ -226,8 +226,7 @@ void test_peek_memchunks_append(void) {
std::array<uint8_t, 32> b{{
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4',
'5', '6', '7', '8', '9', '0', '1',
}},
'5', '6', '7', '8', '9', '0', '1', }},
d;
pchunks.append(b.data(), b.size());
@ -261,8 +260,7 @@ void test_peek_memchunks_disable_peek_drain(void) {
std::array<uint8_t, 32> b{{
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4',
'5', '6', '7', '8', '9', '0', '1',
}},
'5', '6', '7', '8', '9', '0', '1', }},
d;
pchunks.append(b.data(), b.size());
@ -289,8 +287,7 @@ void test_peek_memchunks_disable_peek_no_drain(void) {
std::array<uint8_t, 32> b{{
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4',
'5', '6', '7', '8', '9', '0', '1',
}},
'5', '6', '7', '8', '9', '0', '1', }},
d;
pchunks.append(b.data(), b.size());
@ -317,8 +314,7 @@ void test_peek_memchunks_reset(void) {
std::array<uint8_t, 32> b{{
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4',
'5', '6', '7', '8', '9', '0', '1',
}},
'5', '6', '7', '8', '9', '0', '1', }},
d;
pchunks.append(b.data(), b.size());

View File

@ -89,8 +89,7 @@ enum {
namespace {
constexpr auto anchors = std::array<Anchor, 5>{{
{3, 0, 201}, {5, 0, 101}, {7, 0, 1}, {9, 7, 1}, {11, 3, 1},
}};
{3, 0, 201}, {5, 0, 101}, {7, 0, 1}, {9, 7, 1}, {11, 3, 1}, }};
} // namespace
Config::Config()
@ -554,8 +553,9 @@ int HttpClient::initiate_connection() {
// If the user overrode the :authority or host header, use that
// value for the SNI extension
const char *host_string = nullptr;
auto i = std::find_if(std::begin(config.headers),
std::end(config.headers), [](const Header &nv) {
auto i =
std::find_if(std::begin(config.headers), std::end(config.headers),
[](const Header &nv) {
return ":authority" == nv.name || "host" == nv.name;
});
if (i != std::end(config.headers)) {
@ -2027,7 +2027,8 @@ namespace {
int communicate(
const std::string &scheme, const std::string &host, uint16_t port,
std::vector<std::tuple<std::string, nghttp2_data_provider *, int64_t>>
requests, const nghttp2_session_callbacks *callbacks) {
requests,
const nghttp2_session_callbacks *callbacks) {
int result = 0;
auto loop = EV_DEFAULT;
SSL_CTX *ssl_ctx = nullptr;

View File

@ -401,8 +401,8 @@ void ConnectionHandler::accept_pending_connection() {
}
}
void
ConnectionHandler::set_ticket_keys(std::shared_ptr<TicketKeys> ticket_keys) {
void ConnectionHandler::set_ticket_keys(
std::shared_ptr<TicketKeys> ticket_keys) {
ticket_keys_ = std::move(ticket_keys);
if (single_worker_) {
single_worker_->set_ticket_keys(ticket_keys_);
@ -740,8 +740,8 @@ void ConnectionHandler::on_tls_ticket_key_get_success(
set_ticket_keys_to_worker(ticket_keys);
}
void
ConnectionHandler::schedule_next_tls_ticket_key_memcached_get(ev_timer *w) {
void ConnectionHandler::schedule_next_tls_ticket_key_memcached_get(
ev_timer *w) {
ev_timer_set(w, get_config()->tls_ticket_key_memcached_interval, 0.);
ev_timer_start(loop_, w);
}

View File

@ -553,8 +553,8 @@ void Http2Session::add_downstream_connection(Http2DownstreamConnection *dconn) {
dconns_.append(dconn);
}
void
Http2Session::remove_downstream_connection(Http2DownstreamConnection *dconn) {
void Http2Session::remove_downstream_connection(
Http2DownstreamConnection *dconn) {
dconns_.remove(dconn);
dconn->detach_stream_data();
}

View File

@ -1391,8 +1391,8 @@ int Http2Upstream::error_reply(Downstream *downstream,
return 0;
}
void
Http2Upstream::add_pending_downstream(std::unique_ptr<Downstream> downstream) {
void Http2Upstream::add_pending_downstream(
std::unique_ptr<Downstream> downstream) {
downstream_queue_.add_pending(std::move(downstream));
}
@ -1670,9 +1670,8 @@ int Http2Upstream::consume(int32_t stream_id, size_t len) {
return 0;
}
void
Http2Upstream::log_response_headers(Downstream *downstream,
const std::vector<nghttp2_nv> &nva) const {
void Http2Upstream::log_response_headers(
Downstream *downstream, const std::vector<nghttp2_nv> &nva) const {
std::stringstream ss;
for (auto &nv : nva) {
ss << TTY_HTTP_HD << nv.name << TTY_RST << ": " << nv.value << "\n";

View File

@ -184,7 +184,7 @@ std::pair<OutputIterator, size_t> copy(const std::string &src, size_t avail,
namespace {
template <size_t N, typename OutputIterator>
std::pair<OutputIterator, size_t> copy_l(const char (&src)[N], size_t avail,
std::pair<OutputIterator, size_t> copy_l(const char(&src)[N], size_t avail,
OutputIterator oitr) {
return copy(src, N - 1, avail, oitr);
}

View File

@ -52,8 +52,8 @@ static LogConfig *config = new LogConfig();
LogConfig *log_config(void) { return config; }
#endif // NOTHREADS
void
LogConfig::update_tstamp(const std::chrono::system_clock::time_point &now) {
void LogConfig::update_tstamp(
const std::chrono::system_clock::time_point &now) {
auto t0 = std::chrono::system_clock::to_time_t(time_str_updated_);
auto t1 = std::chrono::system_clock::to_time_t(now);
if (t0 == t1) {

View File

@ -888,13 +888,11 @@ int SpdyUpstream::error_reply(Downstream *downstream,
std::string content_length = util::utos(html.size());
std::string status_string = http2::get_status_string(status_code);
const char *nv[] = {":status", status_string.c_str(),
":version", "http/1.1",
"content-type", "text/html; charset=UTF-8",
"server", get_config()->server_name,
"content-length", content_length.c_str(),
"date", lgconf->time_http_str.c_str(),
nullptr};
const char *nv[] = {":status", status_string.c_str(), ":version", "http/1.1",
"content-type", "text/html; charset=UTF-8", "server",
get_config()->server_name, "content-length",
content_length.c_str(), "date",
lgconf->time_http_str.c_str(), nullptr};
rv = spdylay_submit_response(session_, downstream->get_stream_id(), nv,
&data_prd);

View File

@ -43,10 +43,9 @@ void test_shrpx_ssl_create_lookup_tree(void) {
SSL_CTX_new(SSLv23_method()), SSL_CTX_new(SSLv23_method()),
SSL_CTX_new(SSLv23_method()), SSL_CTX_new(SSLv23_method())};
const char *hostnames[] = {"example.com", "www.example.org",
"*www.example.org", "x*.host.domain",
"*yy.host.domain", "nghttp2.sourceforge.net",
"sourceforge.net",
const char *hostnames[] = {
"example.com", "www.example.org", "*www.example.org", "x*.host.domain",
"*yy.host.domain", "nghttp2.sourceforge.net", "sourceforge.net",
"sourceforge.net", // duplicate
"*.foo.bar", // oo.bar is suffix of *.foo.bar
"oo.bar"};

View File

@ -60,11 +60,11 @@ make_array(T &&... t) {
sizeof...(T)>{{std::forward<T>(t)...}};
}
template <typename T, size_t N> constexpr size_t array_size(T (&)[N]) {
template <typename T, size_t N> constexpr size_t array_size(T(&)[N]) {
return N;
}
template <typename T, size_t N> constexpr size_t str_size(T (&)[N]) {
template <typename T, size_t N> constexpr size_t str_size(T(&)[N]) {
return N - 1;
}
@ -76,8 +76,8 @@ template <typename F, typename... T> struct Defer {
Defer(Defer &&o) : f(std::move(o.f)) {}
~Defer() { f(); }
using ResultType = typename std::result_of<
typename std::decay<F>::type(typename std::decay<T>::type...)>::type;
using ResultType = typename std::result_of<typename std::decay<F>::type(
typename std::decay<T>::type...)>::type;
std::function<ResultType()> f;
};

View File

@ -220,7 +220,7 @@ std::string quote_string(const std::string &target);
std::string format_hex(const unsigned char *s, size_t len);
template <size_t N> std::string format_hex(const unsigned char (&s)[N]) {
template <size_t N> std::string format_hex(const unsigned char(&s)[N]) {
return format_hex(s, N);
}
@ -366,11 +366,11 @@ inline bool strieq(const char *a, const std::string &b) {
}
template <typename InputIt, size_t N>
bool strieq_l(const char (&a)[N], InputIt b, size_t blen) {
bool strieq_l(const char(&a)[N], InputIt b, size_t blen) {
return strieq(a, N - 1, b, blen);
}
template <size_t N> bool strieq_l(const char (&a)[N], const std::string &b) {
template <size_t N> bool strieq_l(const char(&a)[N], const std::string &b) {
return strieq(a, N - 1, std::begin(b), b.size());
}
@ -400,11 +400,11 @@ inline bool streq(const char *a, const char *b) {
}
template <typename InputIt, size_t N>
bool streq_l(const char (&a)[N], InputIt b, size_t blen) {
bool streq_l(const char(&a)[N], InputIt b, size_t blen) {
return streq(a, N - 1, b, blen);
}
template <size_t N> bool streq_l(const char (&a)[N], const std::string &b) {
template <size_t N> bool streq_l(const char(&a)[N], const std::string &b) {
return streq(a, N - 1, std::begin(b), b.size());
}

View File

@ -1007,25 +1007,20 @@ void test_nghttp2_hd_deflate_inflate(void) {
nghttp2_hd_deflater deflater;
nghttp2_hd_inflater inflater;
nghttp2_nv nv1[] = {
MAKE_NV(":status", "200 OK"),
MAKE_NV("access-control-allow-origin", "*"),
MAKE_NV(":status", "200 OK"), MAKE_NV("access-control-allow-origin", "*"),
MAKE_NV("cache-control", "private, max-age=0, must-revalidate"),
MAKE_NV("content-length", "76073"),
MAKE_NV("content-type", "text/html"),
MAKE_NV("content-length", "76073"), MAKE_NV("content-type", "text/html"),
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
MAKE_NV("expires", "Sat, 27 Jul 2013 06:22:12 GMT"),
MAKE_NV("server", "Apache"),
MAKE_NV("vary", "foobar"),
MAKE_NV("server", "Apache"), MAKE_NV("vary", "foobar"),
MAKE_NV("via", "1.1 alphabravo (squid/3.x.x), 1.1 nghttpx"),
MAKE_NV("x-cache", "MISS from alphabravo"),
MAKE_NV("x-cache-action", "MISS"),
MAKE_NV("x-cache-age", "0"),
MAKE_NV("x-cache-action", "MISS"), MAKE_NV("x-cache-age", "0"),
MAKE_NV("x-cache-lookup", "MISS from alphabravo:3128"),
MAKE_NV("x-lb-nocache", "true"),
};
nghttp2_nv nv2[] = {
MAKE_NV(":status", "304 Not Modified"),
MAKE_NV("age", "0"),
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
MAKE_NV("cache-control", "max-age=56682045"),
MAKE_NV("content-type", "text/css"),
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
@ -1036,8 +1031,7 @@ void test_nghttp2_hd_deflate_inflate(void) {
MAKE_NV("x-cache", "HIT from alphabravo"),
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128")};
nghttp2_nv nv3[] = {
MAKE_NV(":status", "304 Not Modified"),
MAKE_NV("age", "0"),
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
MAKE_NV("cache-control", "max-age=56682072"),
MAKE_NV("content-type", "text/css"),
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
@ -1049,8 +1043,7 @@ void test_nghttp2_hd_deflate_inflate(void) {
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
};
nghttp2_nv nv4[] = {
MAKE_NV(":status", "304 Not Modified"),
MAKE_NV("age", "0"),
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
MAKE_NV("cache-control", "max-age=56682022"),
MAKE_NV("content-type", "text/css"),
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
@ -1062,8 +1055,7 @@ void test_nghttp2_hd_deflate_inflate(void) {
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
};
nghttp2_nv nv5[] = {
MAKE_NV(":status", "304 Not Modified"),
MAKE_NV("age", "0"),
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
MAKE_NV("cache-control", "max-age=4461139"),
MAKE_NV("content-type", "application/x-javascript"),
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
@ -1075,8 +1067,7 @@ void test_nghttp2_hd_deflate_inflate(void) {
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
};
nghttp2_nv nv6[] = {
MAKE_NV(":status", "304 Not Modified"),
MAKE_NV("age", "0"),
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
MAKE_NV("cache-control", "max-age=18645951"),
MAKE_NV("content-type", "application/x-javascript"),
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
@ -1088,8 +1079,7 @@ void test_nghttp2_hd_deflate_inflate(void) {
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
};
nghttp2_nv nv7[] = {
MAKE_NV(":status", "304 Not Modified"),
MAKE_NV("age", "0"),
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
MAKE_NV("cache-control", "max-age=31536000"),
MAKE_NV("content-type", "application/javascript"),
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
@ -1101,8 +1091,7 @@ void test_nghttp2_hd_deflate_inflate(void) {
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
};
nghttp2_nv nv8[] = {
MAKE_NV(":status", "304 Not Modified"),
MAKE_NV("age", "0"),
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
MAKE_NV("cache-control", "max-age=31536000"),
MAKE_NV("content-type", "application/javascript"),
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
@ -1114,8 +1103,7 @@ void test_nghttp2_hd_deflate_inflate(void) {
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
};
nghttp2_nv nv9[] = {
MAKE_NV(":status", "304 Not Modified"),
MAKE_NV("age", "0"),
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
MAKE_NV("cache-control", "max-age=31536000"),
MAKE_NV("content-type", "application/javascript"),
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),
@ -1127,8 +1115,7 @@ void test_nghttp2_hd_deflate_inflate(void) {
MAKE_NV("x-cache-lookup", "HIT from alphabravo:3128"),
};
nghttp2_nv nv10[] = {
MAKE_NV(":status", "304 Not Modified"),
MAKE_NV("age", "0"),
MAKE_NV(":status", "304 Not Modified"), MAKE_NV("age", "0"),
MAKE_NV("cache-control", "max-age=56682045"),
MAKE_NV("content-type", "text/css"),
MAKE_NV("date", "Sat, 27 Jul 2013 06:22:12 GMT"),

View File

@ -45,9 +45,7 @@ static string_entry *string_entry_new(const char *s) {
return ent;
}
static void string_entry_del(string_entry *ent) {
free(ent);
}
static void string_entry_del(string_entry *ent) { free(ent); }
static int pq_less(const void *lhs, const void *rhs) {
return strcmp(((string_entry *)lhs)->s, ((string_entry *)rhs)->s) < 0;