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
@ -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
@ -3298,8 +3300,7 @@ 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,
int32_t stream_id, const nghttp2_priority_spec *pri_spec,
const nghttp2_nv *nva, size_t nvlen,
void *stream_user_data);

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

@ -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

@ -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

@ -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

@ -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

@ -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;