From 3a673575dda439a675c072295819c8cb6eeb1815 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Wed, 8 Jul 2020 10:39:46 -0700 Subject: [PATCH] clang format --- ixwebsocket/IXHttpClient.h | 6 +++--- ixwebsocket/IXHttpServer.cpp | 16 +++++++++------- ixwebsocket/IXUrlParser.cpp | 2 +- .../IXWebSocketPerMessageDeflateCodec.cpp | 12 ++++++++---- .../IXWebSocketPerMessageDeflateCodec.h | 6 ++++-- ixwebsocket/IXWebSocketTransport.h | 7 ++----- test/IXCobraToSentryBotTest.cpp | 2 +- test/IXCobraToStatsdBotTest.cpp | 2 +- test/IXCobraToStdoutBotTest.cpp | 2 +- test/IXHttpServerTest.cpp | 3 ++- ...bSocketPerMessageDeflateCompressorTest.cpp | 10 +++++++--- ws/ws.cpp | 19 ++++++++----------- ws/ws.h | 4 +--- ws/ws_connect.cpp | 2 +- ws/ws_redis_cli.cpp | 12 ++++-------- 15 files changed, 53 insertions(+), 52 deletions(-) diff --git a/ixwebsocket/IXHttpClient.h b/ixwebsocket/IXHttpClient.h index 828a5fe7..97727e6e 100644 --- a/ixwebsocket/IXHttpClient.h +++ b/ixwebsocket/IXHttpClient.h @@ -103,9 +103,9 @@ namespace ix std::thread _thread; std::unique_ptr _socket; - std::recursive_mutex _mutex; // to protect accessing the _socket (only one socket per client) - // the mutex needs to be recursive as this function might - // be called recursively to follow HTTP redirections + std::recursive_mutex _mutex; // to protect accessing the _socket (only one socket per + // client) the mutex needs to be recursive as this function + // might be called recursively to follow HTTP redirections SocketTLSOptions _tlsOptions; diff --git a/ixwebsocket/IXHttpServer.cpp b/ixwebsocket/IXHttpServer.cpp index 9c252392..7096e816 100644 --- a/ixwebsocket/IXHttpServer.cpp +++ b/ixwebsocket/IXHttpServer.cpp @@ -9,11 +9,11 @@ #include "IXNetSystem.h" #include "IXSocketConnect.h" #include "IXUserAgent.h" +#include #include #include #include #include -#include namespace { @@ -50,8 +50,11 @@ namespace const int windowBits = 15; const int GZIP_ENCODING = 16; - deflateInit2(&zs, Z_DEFAULT_COMPRESSION, Z_DEFLATED, - windowBits | GZIP_ENCODING, 8, + deflateInit2(&zs, + Z_DEFAULT_COMPRESSION, + Z_DEFLATED, + windowBits | GZIP_ENCODING, + 8, Z_DEFAULT_STRATEGY); zs.next_in = (Bytef*) str.data(); @@ -69,13 +72,12 @@ namespace ret = deflate(&zs, Z_FINISH); - if(outstring.size() < zs.total_out) + if (outstring.size() < zs.total_out) { // append the block to the output string - outstring.append(outbuffer, - zs.total_out - outstring.size()); + outstring.append(outbuffer, zs.total_out - outstring.size()); } - } while(ret == Z_OK); + } while (ret == Z_OK); deflateEnd(&zs); diff --git a/ixwebsocket/IXUrlParser.cpp b/ixwebsocket/IXUrlParser.cpp index 76683722..9963052c 100644 --- a/ixwebsocket/IXUrlParser.cpp +++ b/ixwebsocket/IXUrlParser.cpp @@ -32,8 +32,8 @@ #include "IXUrlParser.h" #include -#include #include +#include namespace { diff --git a/ixwebsocket/IXWebSocketPerMessageDeflateCodec.cpp b/ixwebsocket/IXWebSocketPerMessageDeflateCodec.cpp index e762c800..fb02e755 100644 --- a/ixwebsocket/IXWebSocketPerMessageDeflateCodec.cpp +++ b/ixwebsocket/IXWebSocketPerMessageDeflateCodec.cpp @@ -75,22 +75,26 @@ namespace ix return compressData(in, out); } - bool WebSocketPerMessageDeflateCompressor::compress(const std::string& in, std::vector& out) + bool WebSocketPerMessageDeflateCompressor::compress(const std::string& in, + std::vector& out) { return compressData(in, out); } - bool WebSocketPerMessageDeflateCompressor::compress(const std::vector& in, std::string& out) + bool WebSocketPerMessageDeflateCompressor::compress(const std::vector& in, + std::string& out) { return compressData(in, out); } - bool WebSocketPerMessageDeflateCompressor::compress(const std::vector& in, std::vector& out) + bool WebSocketPerMessageDeflateCompressor::compress(const std::vector& in, + std::vector& out) { return compressData(in, out); } - template bool WebSocketPerMessageDeflateCompressor::compressData(const T& in, S& out) + template + bool WebSocketPerMessageDeflateCompressor::compressData(const T& in, S& out) { // // 7.2.1. Compression diff --git a/ixwebsocket/IXWebSocketPerMessageDeflateCodec.h b/ixwebsocket/IXWebSocketPerMessageDeflateCodec.h index b4d3687b..476d3c79 100644 --- a/ixwebsocket/IXWebSocketPerMessageDeflateCodec.h +++ b/ixwebsocket/IXWebSocketPerMessageDeflateCodec.h @@ -26,8 +26,10 @@ namespace ix bool compress(const std::vector& in, std::vector& out); private: - template bool compressData(const T& in, S& out); - template bool endsWithEmptyUnCompressedBlock(const T& value); + template + bool compressData(const T& in, S& out); + template + bool endsWithEmptyUnCompressedBlock(const T& value); int _flush; size_t _compressBufferSize; diff --git a/ixwebsocket/IXWebSocketTransport.h b/ixwebsocket/IXWebSocketTransport.h index 6d185ad6..139f12db 100644 --- a/ixwebsocket/IXWebSocketTransport.h +++ b/ixwebsocket/IXWebSocketTransport.h @@ -246,11 +246,8 @@ namespace ix const OnProgressCallback& onProgressCallback = nullptr); template - bool sendFragment(wsheader_type::opcode_type type, - bool fin, - Iterator begin, - Iterator end, - bool compress); + bool sendFragment( + wsheader_type::opcode_type type, bool fin, Iterator begin, Iterator end, bool compress); void emitMessage(MessageKind messageKind, const std::string& message, diff --git a/test/IXCobraToSentryBotTest.cpp b/test/IXCobraToSentryBotTest.cpp index 2b442349..03c20d92 100644 --- a/test/IXCobraToSentryBotTest.cpp +++ b/test/IXCobraToSentryBotTest.cpp @@ -12,8 +12,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/test/IXCobraToStatsdBotTest.cpp b/test/IXCobraToStatsdBotTest.cpp index 90555934..67db5928 100644 --- a/test/IXCobraToStatsdBotTest.cpp +++ b/test/IXCobraToStatsdBotTest.cpp @@ -12,8 +12,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/test/IXCobraToStdoutBotTest.cpp b/test/IXCobraToStdoutBotTest.cpp index d0d561d5..a4c58304 100644 --- a/test/IXCobraToStdoutBotTest.cpp +++ b/test/IXCobraToStdoutBotTest.cpp @@ -12,8 +12,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/test/IXHttpServerTest.cpp b/test/IXHttpServerTest.cpp index a3ed1da4..17b4904f 100644 --- a/test/IXHttpServerTest.cpp +++ b/test/IXHttpServerTest.cpp @@ -67,7 +67,8 @@ TEST_CASE("http server", "[httpd]") TEST_CASE("http server redirection", "[httpd_redirect]") { - SECTION("Connect to a local HTTP server, with redirection enabled, but we do not follow redirects") + SECTION( + "Connect to a local HTTP server, with redirection enabled, but we do not follow redirects") { int port = getFreePort(); ix::HttpServer server(port, "127.0.0.1"); diff --git a/test/IXWebSocketPerMessageDeflateCompressorTest.cpp b/test/IXWebSocketPerMessageDeflateCompressorTest.cpp index 8b9e1f7d..b067b825 100644 --- a/test/IXWebSocketPerMessageDeflateCompressorTest.cpp +++ b/test/IXWebSocketPerMessageDeflateCompressorTest.cpp @@ -56,7 +56,8 @@ namespace ix REQUIRE(compressAndDecompress("foo") == "foo"); REQUIRE(compressAndDecompress("bar") == "bar"); REQUIRE(compressAndDecompress("asdcaseqw`21897dehqwed") == "asdcaseqw`21897dehqwed"); - REQUIRE(compressAndDecompress("/usr/local/include/ixwebsocket/IXSocketAppleSSL.h") == "/usr/local/include/ixwebsocket/IXSocketAppleSSL.h"); + REQUIRE(compressAndDecompress("/usr/local/include/ixwebsocket/IXSocketAppleSSL.h") == + "/usr/local/include/ixwebsocket/IXSocketAppleSSL.h"); } SECTION("vector api") @@ -64,8 +65,11 @@ namespace ix REQUIRE(compressAndDecompressVector("") == ""); REQUIRE(compressAndDecompressVector("foo") == "foo"); REQUIRE(compressAndDecompressVector("bar") == "bar"); - REQUIRE(compressAndDecompressVector("asdcaseqw`21897dehqwed") == "asdcaseqw`21897dehqwed"); - REQUIRE(compressAndDecompressVector("/usr/local/include/ixwebsocket/IXSocketAppleSSL.h") == "/usr/local/include/ixwebsocket/IXSocketAppleSSL.h"); + REQUIRE(compressAndDecompressVector("asdcaseqw`21897dehqwed") == + "asdcaseqw`21897dehqwed"); + REQUIRE( + compressAndDecompressVector("/usr/local/include/ixwebsocket/IXSocketAppleSSL.h") == + "/usr/local/include/ixwebsocket/IXSocketAppleSSL.h"); } } diff --git a/ws/ws.cpp b/ws/ws.cpp index c415f7fa..d94d1fe7 100644 --- a/ws/ws.cpp +++ b/ws/ws.cpp @@ -11,13 +11,13 @@ #include #include +#include #include #include #include #include -#include -#include #include +#include #include #include #include @@ -193,8 +193,7 @@ int main(int argc, char** argv) "--limit_received_events", cobraBotConfig.limitReceivedEvents, "Max events per minute"); app->add_option( "--max_events_per_minute", cobraBotConfig.maxEventsPerMinute, "Max events per minute"); - app->add_option( - "--batch_size", cobraBotConfig.batchSize, "Subscription batch size"); + app->add_option("--batch_size", cobraBotConfig.batchSize, "Subscription batch size"); }; app.add_flag("--version", version, "Print ws version"); @@ -358,7 +357,8 @@ int main(int argc, char** argv) cobra2python->add_option("--host", hostname, "Statsd host"); cobra2python->add_option("--port", statsdPort, "Statsd port"); cobra2python->add_option("--prefix", prefix, "Statsd prefix"); - cobra2python->add_option("--script", scriptPath, "Python script path")->check(CLI::ExistingPath); + cobra2python->add_option("--script", scriptPath, "Python script path") + ->check(CLI::ExistingPath); cobra2python->add_option("--pidfile", pidfile, "Pid file"); addTLSOptions(cobra2python); addCobraBotConfig(cobra2python); @@ -604,8 +604,7 @@ int main(int argc, char** argv) } else { - ret = (int) ix::cobra_to_python_bot( - cobraBotConfig, statsdClient, scriptPath); + ret = (int) ix::cobra_to_python_bot(cobraBotConfig, statsdClient, scriptPath); } } else if (app.got_subcommand("cobra_to_sentry")) @@ -620,14 +619,12 @@ int main(int argc, char** argv) ix::RedisClient redisClient; if (!redisClient.connect(hostname, redisPort)) { - spdlog::error("Cannot connect to redis host {}:{}", - redisHosts, redisPort); + spdlog::error("Cannot connect to redis host {}:{}", redisHosts, redisPort); return 1; } else { - ret = (int) ix::cobra_metrics_to_redis_bot( - cobraBotConfig, redisClient, verbose); + ret = (int) ix::cobra_metrics_to_redis_bot(cobraBotConfig, redisClient, verbose); } } else if (app.got_subcommand("snake")) diff --git a/ws/ws.h b/ws/ws.h index 73c04973..6109660b 100644 --- a/ws/ws.h +++ b/ws/ws.h @@ -64,9 +64,7 @@ namespace ix bool disablePerMessageDeflate, const ix::SocketTLSOptions& tlsOptions); - int ws_redis_cli_main(const std::string& hostname, - int port, - const std::string& password); + int ws_redis_cli_main(const std::string& hostname, int port, const std::string& password); int ws_redis_publish_main(const std::string& hostname, int port, diff --git a/ws/ws_connect.cpp b/ws/ws_connect.cpp index 3f4c969b..458134f3 100644 --- a/ws/ws_connect.cpp +++ b/ws/ws_connect.cpp @@ -6,12 +6,12 @@ #include "IXBench.h" #include "linenoise.hpp" +#include #include #include #include #include #include -#include namespace ix diff --git a/ws/ws_redis_cli.cpp b/ws/ws_redis_cli.cpp index 8cfc3364..efb206c9 100644 --- a/ws/ws_redis_cli.cpp +++ b/ws/ws_redis_cli.cpp @@ -4,17 +4,15 @@ * Copyright (c) 2019 Machine Zone, Inc. All rights reserved. */ +#include "linenoise.hpp" +#include #include #include #include -#include -#include "linenoise.hpp" namespace ix { - int ws_redis_cli_main(const std::string& hostname, - int port, - const std::string& password) + int ws_redis_cli_main(const std::string& hostname, int port, const std::string& password) { RedisClient redisClient; if (!redisClient.connect(hostname, port)) @@ -71,9 +69,7 @@ namespace ix { if (response.first != RespType::String) { - std::cout << "(" - << redisClient.getRespTypeDescription(response.first) - << ")" + std::cout << "(" << redisClient.getRespTypeDescription(response.first) << ")" << " "; }