From bacae3e2cee01f4fcc8c4b47fcaf3d53965c83cb Mon Sep 17 00:00:00 2001 From: lixianjing Date: Tue, 6 Apr 2021 19:10:01 +0800 Subject: [PATCH] format code --- src/base/timer.c | 3 +- src/base/timer.h | 3 +- src/base/widget.c | 16 ++++---- src/base/widget.h | 2 +- .../image_animation/image_animation.c | 11 +++--- src/font_loader/font_loader_ft.c | 3 +- src/native_window/native_window_fb_gl.c | 3 +- src/native_window/native_window_fb_gl.h | 3 +- src/streams/inet/iostream_mbedtls.c | 4 +- src/streams/inet/iostream_mbedtls.h | 4 +- src/streams/inet/istream_mbedtls.c | 11 +++--- src/streams/inet/mbedtls_client.c | 37 +++++++++---------- src/streams/inet/mbedtls_client.h | 3 +- src/streams/inet/mbedtls_helper.c | 4 +- src/streams/inet/mbedtls_helper.h | 22 +++++------ src/streams/inet/mbedtls_server.c | 14 +++---- src/streams/inet/mbedtls_server.h | 8 ++-- src/streams/inet/ostream_mbedtls.c | 18 +++++---- src/streams/tools/https_client.c | 6 +-- src/streams/tools/https_get.c | 1 - src/streams/tools/https_server.c | 12 +++--- src/tkc/event.h | 1 - src/tkc/idle_info.h | 2 +- src/tkc/timer_info.h | 2 +- src/tkc/wstr.h | 2 +- tests/input_engine_test.cc | 3 +- tests/wstr_test.cc | 9 ++--- 27 files changed, 103 insertions(+), 104 deletions(-) diff --git a/src/base/timer.c b/src/base/timer.c index 000dee814..70ed284b1 100644 --- a/src/base/timer.c +++ b/src/base/timer.c @@ -96,7 +96,8 @@ uint32_t timer_next_time(void) { #include "base/main_loop.h" -ret_t timer_queue_ex(timer_func_t on_timer, void* ctx, uint32_t duration, tk_destroy_t on_destroy, void* on_destroy_ctx) { +ret_t timer_queue_ex(timer_func_t on_timer, void* ctx, uint32_t duration, tk_destroy_t on_destroy, + void* on_destroy_ctx) { #ifdef AWTK_WEB timer_add(on_timer, ctx, duration); diff --git a/src/base/timer.h b/src/base/timer.h index 81ff1364b..ebb151d64 100644 --- a/src/base/timer.h +++ b/src/base/timer.h @@ -98,7 +98,8 @@ ret_t timer_queue(timer_func_t on_timer, void* ctx, uint32_t duration); * * @return {ret_t} 返回RET_OK表示成功,否则表示失败。 */ -ret_t timer_queue_ex(timer_func_t on_timer, void* ctx, uint32_t duration, tk_destroy_t on_destroy, void* on_destroy_ctx); +ret_t timer_queue_ex(timer_func_t on_timer, void* ctx, uint32_t duration, tk_destroy_t on_destroy, + void* on_destroy_ctx); /** * @method timer_remove diff --git a/src/base/widget.c b/src/base/widget.c index 0bf16875d..61ec68158 100644 --- a/src/base/widget.c +++ b/src/base/widget.c @@ -4510,48 +4510,48 @@ bool_t widget_is_direct_parent_of(widget_t* widget, widget_t* child) { bool_t widget_get_enable(widget_t* widget) { return_value_if_fail(widget != NULL, FALSE); - + return widget->enable; } bool_t widget_get_floating(widget_t* widget) { return_value_if_fail(widget != NULL, FALSE); - + return widget->floating; } bool_t widget_get_auto_adjust_size(widget_t* widget) { return_value_if_fail(widget != NULL, FALSE); - + return widget->auto_adjust_size; } bool_t widget_get_with_focus_state(widget_t* widget) { return_value_if_fail(widget != NULL, FALSE); - + return widget->with_focus_state; } bool_t widget_get_focusable(widget_t* widget) { return_value_if_fail(widget != NULL, FALSE); - + return widget->focusable; } bool_t widget_get_sensitive(widget_t* widget) { return_value_if_fail(widget != NULL, FALSE); - + return widget->sensitive; } bool_t widget_get_visible(widget_t* widget) { return_value_if_fail(widget != NULL, FALSE); - + return widget->visible; } bool_t widget_get_feedback(widget_t* widget) { return_value_if_fail(widget != NULL, FALSE); - + return widget->feedback; } diff --git a/src/base/widget.h b/src/base/widget.h index c1645ab87..1d775bf55 100644 --- a/src/base/widget.h +++ b/src/base/widget.h @@ -1417,7 +1417,7 @@ widget_t* widget_lookup_by_type(widget_t* widget, const char* type, bool_t recur ret_t widget_set_visible(widget_t* widget, bool_t visible); #else ret_t widget_set_visible(widget_t* widget, bool_t visible, ...); -#endif/*AWTK_GO*/ +#endif /*AWTK_GO*/ /** * @method widget_set_visible_only diff --git a/src/ext_widgets/image_animation/image_animation.c b/src/ext_widgets/image_animation/image_animation.c index 4c6ac77af..b578ee5d8 100644 --- a/src/ext_widgets/image_animation/image_animation.c +++ b/src/ext_widgets/image_animation/image_animation.c @@ -33,7 +33,7 @@ static ret_t image_animation_play_to_done(image_animation_t* image_animation) { image_animation->index = -1; } image_animation->playing = FALSE; - + return RET_OK; } @@ -44,12 +44,13 @@ ret_t image_animation_get_image_name(image_animation_t* image_animation, if (image_animation->sequence != NULL) { uint32_t len = strlen(image_animation->sequence); tk_strncpy(name, image_animation->image, TK_NAME_LEN); - image_animation->index = - image_animation->index >= len ? 0 : image_animation->index; - index = image_animation->reverse ? len - image_animation->index - 1: image_animation->index; + image_animation->index = image_animation->index >= len ? 0 : image_animation->index; + index = image_animation->reverse ? len - image_animation->index - 1 : image_animation->index; name[strlen(name)] = image_animation->sequence[index]; } else { - index = image_animation->reverse ? image_animation->end_index + image_animation->start_index - image_animation->index : image_animation->index; + index = image_animation->reverse + ? image_animation->end_index + image_animation->start_index - image_animation->index + : image_animation->index; const char* format = image_animation->format ? image_animation->format : "%s%d"; tk_snprintf(name, TK_NAME_LEN, format, image_animation->image, index); } diff --git a/src/font_loader/font_loader_ft.c b/src/font_loader/font_loader_ft.c index 8e2e7eb1a..87d130100 100644 --- a/src/font_loader/font_loader_ft.c +++ b/src/font_loader/font_loader_ft.c @@ -69,7 +69,8 @@ static ret_t font_ft_get_glyph(font_t* f, wchar_t c, font_size_t font_size, glyp ft_fontinfo* sf = &(font->ft_font); FT_Glyph glyph; FT_GlyphSlot glyf; - uint32_t flags = FT_LOAD_DEFAULT | FT_LOAD_RENDER | FT_LOAD_NO_AUTOHINT | FT_OUTLINE_HIGH_PRECISION; + uint32_t flags = + FT_LOAD_DEFAULT | FT_LOAD_RENDER | FT_LOAD_NO_AUTOHINT | FT_OUTLINE_HIGH_PRECISION; g->data = NULL; if (glyph_cache_lookup(&(font->cache), c, font_size, g) == RET_OK) { diff --git a/src/native_window/native_window_fb_gl.c b/src/native_window/native_window_fb_gl.c index e2f367796..671463350 100644 --- a/src/native_window/native_window_fb_gl.c +++ b/src/native_window/native_window_fb_gl.c @@ -64,8 +64,7 @@ ret_t native_window_fb_gl_set_make_current_func(native_window_t* win, return RET_OK; } -ret_t native_window_fb_gl_set_destroy_func(native_window_t* win, - native_window_destroy_t destroy) { +ret_t native_window_fb_gl_set_destroy_func(native_window_t* win, native_window_destroy_t destroy) { native_window_fb_gl_t* fb_gl = NATIVE_WINDOW_FB_GL(win); return_value_if_fail(fb_gl != NULL && destroy != NULL, RET_BAD_PARAMS); fb_gl->destroy = destroy; diff --git a/src/native_window/native_window_fb_gl.h b/src/native_window/native_window_fb_gl.h index 7080f971c..61c44744b 100644 --- a/src/native_window/native_window_fb_gl.h +++ b/src/native_window/native_window_fb_gl.h @@ -38,8 +38,7 @@ ret_t native_window_fb_gl_set_swap_buffer_func(native_window_t* win, ret_t native_window_fb_gl_set_make_current_func(native_window_t* win, native_window_gl_make_current_t make_current); -ret_t native_window_fb_gl_set_destroy_func(native_window_t* win, - native_window_destroy_t destroy); +ret_t native_window_fb_gl_set_destroy_func(native_window_t* win, native_window_destroy_t destroy); END_C_DECLS diff --git a/src/streams/inet/iostream_mbedtls.c b/src/streams/inet/iostream_mbedtls.c index 98f289171..d681499cc 100644 --- a/src/streams/inet/iostream_mbedtls.c +++ b/src/streams/inet/iostream_mbedtls.c @@ -54,7 +54,7 @@ static ret_t tk_iostream_mbedtls_get_prop(object_t* obj, const char* name, value static ret_t tk_iostream_mbedtls_on_destroy(object_t* obj) { tk_iostream_mbedtls_t* iostream_mbedtls = TK_IOSTREAM_MBEDTLS(obj); - if(iostream_mbedtls->conn != NULL) { + if (iostream_mbedtls->conn != NULL) { mbedtls_conn_destroy(iostream_mbedtls->conn); } @@ -99,4 +99,4 @@ tk_iostream_t* tk_iostream_mbedtls_create(mbedtls_conn_t* conn) { return TK_IOSTREAM(obj); } -#endif/*WITH_MBEDTLS*/ +#endif /*WITH_MBEDTLS*/ diff --git a/src/streams/inet/iostream_mbedtls.h b/src/streams/inet/iostream_mbedtls.h index 3e41832c1..da1020046 100644 --- a/src/streams/inet/iostream_mbedtls.h +++ b/src/streams/inet/iostream_mbedtls.h @@ -40,7 +40,7 @@ typedef struct _tk_iostream_mbedtls_t tk_iostream_mbedtls_t; struct _tk_iostream_mbedtls_t { tk_iostream_t iostream; - mbedtls_conn_t* conn; + mbedtls_conn_t* conn; tk_istream_t* istream; tk_ostream_t* ostream; }; @@ -57,10 +57,8 @@ struct _tk_iostream_mbedtls_t { */ tk_iostream_t* tk_iostream_mbedtls_create(mbedtls_conn_t* conn); - #define TK_IOSTREAM_MBEDTLS(obj) ((tk_iostream_mbedtls_t*)(obj)) END_C_DECLS #endif /*TK_IOSTREAM_MBEDTLS_H*/ - diff --git a/src/streams/inet/istream_mbedtls.c b/src/streams/inet/istream_mbedtls.c index 194711635..1939f4b8b 100644 --- a/src/streams/inet/istream_mbedtls.c +++ b/src/streams/inet/istream_mbedtls.c @@ -64,10 +64,11 @@ static ret_t tk_istream_mbedtls_get_prop(object_t* obj, const char* name, value_ return RET_NOT_FOUND; } -static const object_vtable_t s_tk_istream_mbedtls_vtable = {.type = "tk_istream_mbedtls", - .desc = "tk_istream_mbedtls", - .size = sizeof(tk_istream_mbedtls_t), - .get_prop = tk_istream_mbedtls_get_prop}; +static const object_vtable_t s_tk_istream_mbedtls_vtable = { + .type = "tk_istream_mbedtls", + .desc = "tk_istream_mbedtls", + .size = sizeof(tk_istream_mbedtls_t), + .get_prop = tk_istream_mbedtls_get_prop}; tk_istream_t* tk_istream_mbedtls_create(mbedtls_ssl_context* ssl) { object_t* obj = NULL; @@ -94,4 +95,4 @@ tk_istream_mbedtls_t* tk_istream_mbedtls_cast(tk_istream_t* s) { return (tk_istream_mbedtls_t*)s; } -#endif/*WITH_MBEDTLS*/ +#endif /*WITH_MBEDTLS*/ diff --git a/src/streams/inet/mbedtls_client.c b/src/streams/inet/mbedtls_client.c index 0a397dbd4..d078283e3 100644 --- a/src/streams/inet/mbedtls_client.c +++ b/src/streams/inet/mbedtls_client.c @@ -18,19 +18,19 @@ static ret_t mbedtls_conn_client_destroy(mbedtls_conn_t* conn) { return RET_OK; } -mbedtls_conn_t* mbedtls_conn_client_create(const char* host, const char* port, const uint8_t* cas_pem, - uint32_t cas_pem_len) { - int ret = 0; - int flags = 0; - mbedtls_conn_t* conn = NULL; - const char* pers = TK_MBEDTLS_PERS; - mbedtls_conn_client_t* client = NULL; - return_value_if_fail(host != NULL && port != NULL, NULL); - client = TKMEM_ZALLOC(mbedtls_conn_client_t); - return_value_if_fail(client != NULL, NULL); - conn = (mbedtls_conn_t*)client; +mbedtls_conn_t* mbedtls_conn_client_create(const char* host, const char* port, + const uint8_t* cas_pem, uint32_t cas_pem_len) { + int ret = 0; + int flags = 0; + mbedtls_conn_t* conn = NULL; + const char* pers = TK_MBEDTLS_PERS; + mbedtls_conn_client_t* client = NULL; + return_value_if_fail(host != NULL && port != NULL, NULL); + client = TKMEM_ZALLOC(mbedtls_conn_client_t); + return_value_if_fail(client != NULL, NULL); + conn = (mbedtls_conn_t*)client; - conn->destroy = mbedtls_conn_client_destroy; + conn->destroy = mbedtls_conn_client_destroy; #if defined(MBEDTLS_DEBUG_C) mbedtls_debug_set_threshold(DEBUG_LEVEL); @@ -59,10 +59,9 @@ mbedtls_conn_t* mbedtls_conn_client_create(const char* host, const char* port, c /* * 0. Initialize certificates */ - if(cas_pem != NULL) { + if (cas_pem != NULL) { log_debug(" . Loading the CA root certificate ..."); - ret = mbedtls_x509_crt_parse(&(client->cacert), (const unsigned char*)cas_pem, - cas_pem_len); + ret = mbedtls_x509_crt_parse(&(client->cacert), (const unsigned char*)cas_pem, cas_pem_len); if (ret < 0) { log_debug(" failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", (unsigned int)-ret); goto error; @@ -74,8 +73,7 @@ mbedtls_conn_t* mbedtls_conn_client_create(const char* host, const char* port, c * 1. Start the connection */ log_debug(" . Connecting to tcp/%s/%s...", host, port); - if ((ret = mbedtls_net_connect(&(client->server_fd), host, port, MBEDTLS_NET_PROTO_TCP)) != - 0) { + if ((ret = mbedtls_net_connect(&(client->server_fd), host, port, MBEDTLS_NET_PROTO_TCP)) != 0) { log_debug(" failed\n ! mbedtls_net_connect returned %d\n\n", ret); goto error; } @@ -87,7 +85,8 @@ mbedtls_conn_t* mbedtls_conn_client_create(const char* host, const char* port, c */ log_debug(" . Setting up the SSL/TLS structure..."); - if ((ret = mbedtls_ssl_config_defaults(&(client->conf), MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_TRANSPORT_STREAM, + if ((ret = mbedtls_ssl_config_defaults(&(client->conf), MBEDTLS_SSL_IS_CLIENT, + MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT)) != 0) { log_debug(" failed\n ! mbedtls_ssl_config_defaults returned %d\n\n", ret); goto error; @@ -150,4 +149,4 @@ error: return NULL; } -#endif/*WITH_MBEDTLS*/ +#endif /*WITH_MBEDTLS*/ diff --git a/src/streams/inet/mbedtls_client.h b/src/streams/inet/mbedtls_client.h index 7913775f2..cb8dc5adf 100644 --- a/src/streams/inet/mbedtls_client.h +++ b/src/streams/inet/mbedtls_client.h @@ -13,6 +13,7 @@ typedef struct _mbedtls_conn_client_t { mbedtls_x509_crt cacert; } mbedtls_conn_client_t; -mbedtls_conn_t* mbedtls_conn_client_create(const char* host, const char* port, const uint8_t* cas_pem, uint32_t cas_len); +mbedtls_conn_t* mbedtls_conn_client_create(const char* host, const char* port, + const uint8_t* cas_pem, uint32_t cas_len); #endif /* TK_MBEDTLS_CLIENT_H */ diff --git a/src/streams/inet/mbedtls_helper.c b/src/streams/inet/mbedtls_helper.c index 139ff543f..6e6f838ca 100644 --- a/src/streams/inet/mbedtls_helper.c +++ b/src/streams/inet/mbedtls_helper.c @@ -16,11 +16,11 @@ void mbedtls_awtk_debug(void* ctx, int level, const char* file, int line, const ret_t mbedtls_conn_destroy(mbedtls_conn_t* conn) { return_value_if_fail(conn != NULL, RET_BAD_PARAMS); - if(conn->destroy != NULL) { + if (conn->destroy != NULL) { conn->destroy(conn); } return RET_OK; } -#endif/*WITH_MBEDTLS*/ +#endif /*WITH_MBEDTLS*/ diff --git a/src/streams/inet/mbedtls_helper.h b/src/streams/inet/mbedtls_helper.h index 23f843d81..44c289bbf 100644 --- a/src/streams/inet/mbedtls_helper.h +++ b/src/streams/inet/mbedtls_helper.h @@ -31,16 +31,16 @@ #else #include #include -#define mbedtls_calloc calloc -#define mbedtls_free free -#define mbedtls_time time -#define mbedtls_time_t time_t -#define mbedtls_printf printf -#define mbedtls_fprintf fprintf -#define mbedtls_snprintf snprintf -#define mbedtls_exit exit -#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS -#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE +#define mbedtls_calloc calloc +#define mbedtls_free free +#define mbedtls_time time +#define mbedtls_time_t time_t +#define mbedtls_printf printf +#define mbedtls_fprintf fprintf +#define mbedtls_snprintf snprintf +#define mbedtls_exit exit +#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE #endif #include "mbedtls/net_sockets.h" @@ -83,7 +83,7 @@ ret_t mbedtls_conn_destroy(mbedtls_conn_t* conn); #ifndef TK_MBEDTLS_PERS #define TK_MBEDTLS_PERS "awtk_pers" -#endif/*TK_MBEDTLS_PERS*/ +#endif /*TK_MBEDTLS_PERS*/ void mbedtls_awtk_debug(void* ctx, int level, const char* file, int line, const char* str); diff --git a/src/streams/inet/mbedtls_server.c b/src/streams/inet/mbedtls_server.c index d0ff748af..a9eeb0360 100644 --- a/src/streams/inet/mbedtls_server.c +++ b/src/streams/inet/mbedtls_server.c @@ -4,7 +4,6 @@ #include "tkc/utils.h" #include "mbedtls_server.h" - static ret_t mbedtls_conn_server_destroy(mbedtls_conn_t* conn) { int ret = 0; mbedtls_conn_server_t* server_conn = (mbedtls_conn_server_t*)conn; @@ -34,7 +33,7 @@ mbedtls_conn_t* mbedtls_server_accept(mbedtls_server_t* server) { mbedtls_net_init(&(server_conn->client_fd)); mbedtls_ssl_init(&(conn->ssl)); - + if ((ret = mbedtls_ssl_setup(&(conn->ssl), &(server->conf))) != 0) { log_debug(" failed\n ! mbedtls_ssl_setup returned %d\n\n", ret); goto error; @@ -61,16 +60,17 @@ mbedtls_conn_t* mbedtls_server_accept(mbedtls_server_t* server) { log_debug(" ok\n"); return conn; - + error: mbedtls_conn_server_destroy(conn); return NULL; } -mbedtls_server_t* mbedtls_server_create(const char* port, const uint8_t* srv_crt, uint32_t srv_crt_len, - const uint8_t* srv_key, uint32_t srv_key_len, - const uint8_t* cas_pem, uint32_t cas_pem_len) { +mbedtls_server_t* mbedtls_server_create(const char* port, const uint8_t* srv_crt, + uint32_t srv_crt_len, const uint8_t* srv_key, + uint32_t srv_key_len, const uint8_t* cas_pem, + uint32_t cas_pem_len) { int ret = 0; mbedtls_server_t* server = NULL; const char* pers = TK_MBEDTLS_PERS; @@ -193,4 +193,4 @@ ret_t mbedtls_server_destroy(mbedtls_server_t* server) { return RET_OK; } -#endif/*WITH_MBEDTLS*/ +#endif /*WITH_MBEDTLS*/ diff --git a/src/streams/inet/mbedtls_server.h b/src/streams/inet/mbedtls_server.h index 290120b18..3747953e6 100644 --- a/src/streams/inet/mbedtls_server.h +++ b/src/streams/inet/mbedtls_server.h @@ -25,10 +25,10 @@ typedef struct _mbedtls_conn_server_t { mbedtls_server_t* server; } mbedtls_conn_server_t; -mbedtls_server_t* mbedtls_server_create(const char* port, - const uint8_t* srv_crt, uint32_t srv_crt_len, - const uint8_t* srv_key, uint32_t srv_key_len, - const uint8_t* cas_pem, uint32_t cas_pem_len); +mbedtls_server_t* mbedtls_server_create(const char* port, const uint8_t* srv_crt, + uint32_t srv_crt_len, const uint8_t* srv_key, + uint32_t srv_key_len, const uint8_t* cas_pem, + uint32_t cas_pem_len); mbedtls_conn_t* mbedtls_server_accept(mbedtls_server_t* server); diff --git a/src/streams/inet/ostream_mbedtls.c b/src/streams/inet/ostream_mbedtls.c index 889c46445..d29fbe167 100644 --- a/src/streams/inet/ostream_mbedtls.c +++ b/src/streams/inet/ostream_mbedtls.c @@ -27,13 +27,14 @@ #include "tkc/mem.h" #include "streams/inet/ostream_mbedtls.h" -static int32_t tk_ostream_mbedtls_write(tk_ostream_t* stream, const uint8_t* buff, uint32_t max_size) { +static int32_t tk_ostream_mbedtls_write(tk_ostream_t* stream, const uint8_t* buff, + uint32_t max_size) { int32_t ret = 0; tk_ostream_mbedtls_t* ostream_mbedtls = TK_OSTREAM_MBEDTLS(stream); ret = mbedtls_ssl_write(ostream_mbedtls->ssl, buff, max_size); if (ret <= 0) { - if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) { + if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) { perror("send"); ostream_mbedtls->is_broken = TRUE; } @@ -56,10 +57,11 @@ static ret_t tk_ostream_mbedtls_get_prop(object_t* obj, const char* name, value_ return RET_NOT_FOUND; } -static const object_vtable_t s_tk_ostream_mbedtls_vtable = {.type = "tk_ostream_mbedtls", - .desc = "tk_ostream_mbedtls", - .size = sizeof(tk_ostream_mbedtls_t), - .get_prop = tk_ostream_mbedtls_get_prop}; +static const object_vtable_t s_tk_ostream_mbedtls_vtable = { + .type = "tk_ostream_mbedtls", + .desc = "tk_ostream_mbedtls", + .size = sizeof(tk_ostream_mbedtls_t), + .get_prop = tk_ostream_mbedtls_get_prop}; tk_ostream_t* tk_ostream_mbedtls_create(mbedtls_ssl_context* ssl) { object_t* obj = NULL; @@ -73,7 +75,7 @@ tk_ostream_t* tk_ostream_mbedtls_create(mbedtls_ssl_context* ssl) { return_value_if_fail(ostream_mbedtls != NULL, NULL); ostream_mbedtls->ssl = ssl; - ostream_mbedtls->sock = bio->fd; + ostream_mbedtls->sock = bio->fd; TK_OSTREAM(obj)->write = tk_ostream_mbedtls_write; return TK_OSTREAM(obj); @@ -85,4 +87,4 @@ tk_ostream_mbedtls_t* tk_ostream_mbedtls_cast(tk_ostream_t* s) { return (tk_ostream_mbedtls_t*)s; } -#endif/*WITH_MBEDTLS*/ +#endif /*WITH_MBEDTLS*/ diff --git a/src/streams/tools/https_client.c b/src/streams/tools/https_client.c index 3ad0b16de..2a9b51439 100644 --- a/src/streams/tools/https_client.c +++ b/src/streams/tools/https_client.c @@ -8,10 +8,10 @@ int main(int argc, char* argv[]) { const char* request = "GET / HTTP/1.1\r\nHost: localhost\r\n"; platform_prepare(); - conn = mbedtls_conn_client_create("localhost", "4433", - (const uint8_t*)mbedtls_test_cas_pem, mbedtls_test_cas_pem_len); + conn = mbedtls_conn_client_create("localhost", "4433", (const uint8_t*)mbedtls_test_cas_pem, + mbedtls_test_cas_pem_len); - if(conn != NULL) { + if (conn != NULL) { char buff[1024] = {0}; tk_iostream_t* io = tk_iostream_mbedtls_create(conn); tk_istream_t* in = tk_iostream_get_istream(io); diff --git a/src/streams/tools/https_get.c b/src/streams/tools/https_get.c index a3f7471a7..808c76dea 100644 --- a/src/streams/tools/https_get.c +++ b/src/streams/tools/https_get.c @@ -1,6 +1,5 @@ #include "streams/inet/iostream_mbedtls.h" int main(int argc, char* argv[]) { - return 0; } diff --git a/src/streams/tools/https_server.c b/src/streams/tools/https_server.c index 8a029193d..7c08032ab 100644 --- a/src/streams/tools/https_server.c +++ b/src/streams/tools/https_server.c @@ -7,19 +7,19 @@ int main(int argc, char* argv[]) { mbedtls_server_t* server = NULL; platform_prepare(); - server = mbedtls_server_create("4433", - (const uint8_t*)mbedtls_test_srv_crt, mbedtls_test_srv_crt_len, - (const uint8_t*)mbedtls_test_srv_key, mbedtls_test_srv_key_len, - (const uint8_t*)mbedtls_test_cas_pem, mbedtls_test_cas_pem_len); + server = + mbedtls_server_create("4433", (const uint8_t*)mbedtls_test_srv_crt, mbedtls_test_srv_crt_len, + (const uint8_t*)mbedtls_test_srv_key, mbedtls_test_srv_key_len, + (const uint8_t*)mbedtls_test_cas_pem, mbedtls_test_cas_pem_len); - if(server != NULL) { + if (server != NULL) { char buff[1024]; mbedtls_conn_t* conn = mbedtls_server_accept(server); tk_iostream_t* io = tk_iostream_mbedtls_create(conn); tk_istream_t* in = tk_iostream_get_istream(io); tk_ostream_t* out = tk_iostream_get_ostream(io); ret = tk_istream_read(in, buff, sizeof(buff)); - ret = tk_ostream_write(out, "hello\r\n", 7); + ret = tk_ostream_write(out, "hello\r\n", 7); OBJECT_UNREF(io); mbedtls_server_destroy(server); diff --git a/src/tkc/event.h b/src/tkc/event.h index 38abef000..6b2cf2f24 100644 --- a/src/tkc/event.h +++ b/src/tkc/event.h @@ -160,7 +160,6 @@ event_t* event_cast(event_t* event); */ int event_get_type(event_t* event); - /** * @method event_create * @annotation ["constructor", "scriptable", "gc"] diff --git a/src/tkc/idle_info.h b/src/tkc/idle_info.h index 2384bd768..cb3f745c3 100644 --- a/src/tkc/idle_info.h +++ b/src/tkc/idle_info.h @@ -62,7 +62,7 @@ struct _idle_info_t { * idle回调函数上下文。 */ void* ctx; - + /** * @property {void*} extra_ctx * @annotation ["readable", "scriptable"] diff --git a/src/tkc/timer_info.h b/src/tkc/timer_info.h index 8a1be4106..9042efe6e 100644 --- a/src/tkc/timer_info.h +++ b/src/tkc/timer_info.h @@ -64,7 +64,7 @@ struct _timer_info_t { * */ void* ctx; - + /** * @property {void*} extra_ctx * @annotation ["readable", "scriptable"] diff --git a/src/tkc/wstr.h b/src/tkc/wstr.h index 8ac6a5e49..290566080 100644 --- a/src/tkc/wstr.h +++ b/src/tkc/wstr.h @@ -365,7 +365,7 @@ wchar_t* wcs_dup(const wchar_t* s); #ifdef WITH_WCSXXX wchar_t* wcsdup(const wchar_t* s); -#endif/*WITH_WCSXXX*/ +#endif /*WITH_WCSXXX*/ END_C_DECLS diff --git a/tests/input_engine_test.cc b/tests/input_engine_test.cc index 00d0b4744..f9df3a74b 100644 --- a/tests/input_engine_test.cc +++ b/tests/input_engine_test.cc @@ -233,8 +233,7 @@ TEST(input_engine, add_candidates) { ARRAY_SIZE(s_pinyin_chinese_items), key_str, FALSE); ASSERT_EQ(im->engine->candidates_nr, 63); ASSERT_EQ(im->engine->candidates.data != NULL, TRUE); - ASSERT_EQ(check_candidates_from_char((const char*)(im->engine->candidates.data), py_ji, - 63), + ASSERT_EQ(check_candidates_from_char((const char*)(im->engine->candidates.data), py_ji, 63), TRUE); #endif diff --git a/tests/wstr_test.cc b/tests/wstr_test.cc index 06d4b4b12..3acee508c 100644 --- a/tests/wstr_test.cc +++ b/tests/wstr_test.cc @@ -361,23 +361,22 @@ TEST(WStr, set_utf8_with_len) { ASSERT_EQ(wstr_set_utf8_with_len(&str, "123123", 0), RET_OK); ASSERT_EQ(str.size, 0); ASSERT_EQ(wcscmp(str.str, L""), 0); - + ASSERT_EQ(wstr_set_utf8_with_len(&str, "123123", 1), RET_OK); ASSERT_EQ(str.size, 1); ASSERT_EQ(wcscmp(str.str, L"1"), 0); - + ASSERT_EQ(wstr_set_utf8_with_len(&str, "123123", 3), RET_OK); ASSERT_EQ(str.size, 3); ASSERT_EQ(wcscmp(str.str, L"123"), 0); - + ASSERT_EQ(wstr_set_utf8_with_len(&str, "123123", 6), RET_OK); ASSERT_EQ(str.size, 6); ASSERT_EQ(wcscmp(str.str, L"123123"), 0); - + ASSERT_EQ(wstr_set_utf8_with_len(&str, "123123", 6), RET_OK); ASSERT_EQ(str.size, 6); ASSERT_EQ(wcscmp(str.str, L"123123"), 0); wstr_reset(&str); } -