Skip to content

Commit 1af6641

Browse files
committed
clang-format && fix tests
1 parent f38975a commit 1af6641

File tree

11 files changed

+29
-22
lines changed

11 files changed

+29
-22
lines changed

include/swoole_base64.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
#define BASE64_DECODE_OUT_SIZE(s) (((s)) / 4 * 3)
2525

2626
namespace swoole {
27-
size_t base64_encode(const unsigned char *in, size_t inlen, char *out);
28-
size_t base64_decode(const char *in, size_t inlen, char *out);
29-
}
27+
size_t base64_encode(const unsigned char *in, size_t inlen, char *out);
28+
size_t base64_decode(const char *in, size_t inlen, char *out);
29+
} // namespace swoole

include/swoole_client.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Client {
5555
bool closed = false;
5656
bool high_watermark = false;
5757
bool async_connect = false;
58-
bool onerror_called{};
58+
bool onerror_called = false;
5959

6060
/**
6161
* one package: length check

include/swoole_heap.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct HeapNode {
2525
};
2626

2727
class Heap {
28-
public:
28+
public:
2929
enum Type {
3030
MIN_HEAP,
3131
MAX_HEAP,
@@ -53,7 +53,7 @@ class Heap {
5353
return nodes[1];
5454
}
5555

56-
private:
56+
private:
5757
uint32_t num;
5858
uint32_t size;
5959
enum Type type;
@@ -63,5 +63,4 @@ class Heap {
6363
uint32_t maxchild(uint32_t i);
6464
void percolate_down(uint32_t i);
6565
};
66-
}
67-
66+
} // namespace swoole

include/swoole_http.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ class Context {
240240
ContextImpl *impl;
241241
};
242242

243-
std::shared_ptr<Server> listen(const std::string& addr, std::function<void(Context &ctx)> cb, int mode = 1);
243+
std::shared_ptr<Server> listen(const std::string &addr, std::function<void(Context &ctx)> cb, int mode = 1);
244244
//-----------------------------------------------------------------
245245
} // namespace http_server
246246
} // namespace swoole

include/swoole_memory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace swoole {
2424

2525
class MemoryPool {
2626
public:
27-
virtual ~MemoryPool()= default;
27+
virtual ~MemoryPool() = default;
2828
virtual void *alloc(uint32_t size) = 0;
2929
virtual void free(void *ptr) = 0;
3030

include/swoole_reactor.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class ReactorImpl {
4242
reactor_ = _reactor;
4343
}
4444
void after_removal_failure(network::Socket *_socket);
45-
virtual ~ReactorImpl()= default;
45+
virtual ~ReactorImpl() = default;
4646
virtual bool ready() = 0;
4747
virtual int add(network::Socket *socket, int events) = 0;
4848
virtual int set(network::Socket *socket, int events) = 0;
@@ -53,10 +53,10 @@ class ReactorImpl {
5353
class CallbackManager {
5454
public:
5555
typedef std::list<std::pair<Callback, void *>> TaskList;
56-
void append(const Callback& fn, void *private_data) {
56+
void append(const Callback &fn, void *private_data) {
5757
list_.emplace_back(fn, private_data);
5858
}
59-
void prepend(const Callback& fn, void *private_data) {
59+
void prepend(const Callback &fn, void *private_data) {
6060
list_.emplace_front(fn, private_data);
6161
auto t = list_.back();
6262
}
@@ -183,7 +183,7 @@ class Reactor {
183183
explicit Reactor(int max_event = SW_REACTOR_MAXEVENTS, Type _type = TYPE_AUTO);
184184
~Reactor();
185185
bool if_exit();
186-
void defer(const Callback& cb, void *data = nullptr);
186+
void defer(const Callback &cb, void *data = nullptr);
187187
void set_end_callback(EndCallback id, const std::function<void(Reactor *)> &fn);
188188
void erase_end_callback(EndCallback id);
189189
void set_exit_condition(ExitCondition id, const std::function<bool(Reactor *, size_t &)> &fn);
@@ -351,7 +351,7 @@ class Reactor {
351351
switch (errno) {
352352
case EINTR:
353353
return true;
354-
default:
354+
default:
355355
break;
356356
}
357357
return false;

include/swoole_table.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ class Table {
238238
}
239239

240240
void init_row(TableRow *new_row, const char *key, int keylen) {
241-
sw_memset_zero(reinterpret_cast<char *>(new_row) + offsetof(TableRow, active), sizeof(TableRow) - offsetof(TableRow, active));
241+
sw_memset_zero(reinterpret_cast<char *>(new_row) + offsetof(TableRow, active),
242+
sizeof(TableRow) - offsetof(TableRow, active));
242243
memcpy(new_row->key, key, keylen);
243244
new_row->key[keylen] = '\0';
244245
new_row->key_len = keylen;

src/network/socket.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
#include "swoole_string.h"
2424
#include "swoole_timer.h"
2525

26+
#ifdef SW_USE_OPENSSL
27+
#include <openssl/x509.h>
28+
#include <openssl/x509v3.h>
29+
#include <openssl/rand.h>
30+
#include <openssl/conf.h>
31+
#endif
32+
2633
namespace swoole {
2734
namespace network {
2835

src/reactor/base.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ void Reactor::set_exit_condition(ExitCondition id, const std::function<bool(Reac
386386
exit_conditions[id] = fn;
387387
}
388388

389-
void Reactor::defer(const Callback& cb, void *data) {
389+
void Reactor::defer(const Callback &cb, void *data) {
390390
if (defer_tasks == nullptr) {
391391
defer_tasks = new CallbackManager;
392392
}

src/server/static_handler.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ bool StaticHandler::is_modified_range(const std::string &date_range) {
5454
return false;
5555
}
5656

57-
tm tm3 {};
57+
tm tm3{};
5858
const char *date_format = nullptr;
5959

6060
if (strptime(date_range.c_str(), SW_HTTP_RFC1123_DATE_GMT, &tm3) != nullptr) {
@@ -118,7 +118,7 @@ bool StaticHandler::hit() {
118118
p += l_document_root;
119119

120120
if (!serv->locations->empty()) {
121-
for (const auto & i : *serv->locations) {
121+
for (const auto &i : *serv->locations) {
122122
if (swoole_str_istarts_with(url, url_length, i.c_str(), i.size())) {
123123
last = true;
124124
}
@@ -219,7 +219,7 @@ size_t StaticHandler::make_index_page(String *buffer) {
219219
dir_path.c_str(),
220220
dir_path.c_str());
221221

222-
for (const auto & dir_file : dir_files) {
222+
for (const auto &dir_file : dir_files) {
223223
if (dir_file == "." || (dir_path == "/" && dir_file == "..")) {
224224
continue;
225225
}
@@ -594,7 +594,7 @@ bool Server::select_static_handler(http_server::Request *request, Connection *co
594594
auto task = static_cast<network::SendfileTask *>(sw_malloc(task_size));
595595
strcpy(task->filename, handler.get_filename());
596596
if (tasks.size() > 1) {
597-
for (const auto & i : tasks) {
597+
for (const auto &i : tasks) {
598598
response.info.type = SW_SERVER_EVENT_SEND_DATA;
599599
response.info.len = strlen(i.part_header);
600600
response.data = i.part_header;

0 commit comments

Comments
 (0)