Apply clang-format for more source files (#795)

Apply clang-format for C source files in folder core/app-mgr,
core/app-framework, and test-tools.
And rename folder component_test to component-test, update
zephyr build document.

Signed-off-by: Wenyong Huang <wenyong.huang@intel.com>
This commit is contained in:
Wenyong Huang
2021-10-21 13:58:34 +08:00
committed by GitHub
parent 225f5d0a64
commit 32242988ed
143 changed files with 5377 additions and 4627 deletions

View File

@ -24,10 +24,9 @@ typedef struct _connection {
/* Raw connections list */
static connection_t *g_conns = NULL;
connection_t *api_open_connection(const char *name,
attr_container_t *args,
on_connection_event_f on_event,
void *user_data)
connection_t *
api_open_connection(const char *name, attr_container_t *args,
on_connection_event_f on_event, void *user_data)
{
connection_t *conn;
char *args_buffer = (char *)args;
@ -51,14 +50,16 @@ connection_t *api_open_connection(const char *name,
if (g_conns != NULL) {
conn->next = g_conns;
g_conns = conn;
} else {
}
else {
g_conns = conn;
}
return conn;
}
void api_close_connection(connection_t *c)
void
api_close_connection(connection_t *c)
{
connection_t *conn = g_conns, *prev = NULL;
@ -71,19 +72,22 @@ void api_close_connection(connection_t *c)
g_conns = conn->next;
free(conn);
return;
} else {
}
else {
prev = conn;
conn = conn->next;
}
}
}
int api_send_on_connection(connection_t *conn, const char *data, uint32 len)
int
api_send_on_connection(connection_t *conn, const char *data, uint32 len)
{
return wasm_send_on_connection(conn->handle, data, len);
}
bool api_config_connection(connection_t *conn, attr_container_t *cfg)
bool
api_config_connection(connection_t *conn, attr_container_t *cfg)
{
char *cfg_buffer = (char *)cfg;
uint32 cfg_len = attr_container_get_serialize_length(cfg);
@ -91,23 +95,19 @@ bool api_config_connection(connection_t *conn, attr_container_t *cfg)
return wasm_config_connection(conn->handle, cfg_buffer, cfg_len);
}
void on_connection_data(uint32 handle, char *buffer, uint32 len)
void
on_connection_data(uint32 handle, char *buffer, uint32 len)
{
connection_t *conn = g_conns;
while (conn != NULL) {
if (conn->handle == handle) {
if (len == 0) {
conn->on_event(conn,
CONN_EVENT_TYPE_DISCONNECT,
NULL,
0,
conn->on_event(conn, CONN_EVENT_TYPE_DISCONNECT, NULL, 0,
conn->user_data);
} else {
conn->on_event(conn,
CONN_EVENT_TYPE_DATA,
buffer,
len,
}
else {
conn->on_event(conn, CONN_EVENT_TYPE_DATA, buffer, len,
conn->user_data);
}
@ -116,4 +116,3 @@ void on_connection_data(uint32 handle, char *buffer, uint32 len)
conn = conn->next;
}
}

View File

@ -28,5 +28,4 @@ wasm_config_connection(uint32 handle, const char *cfg_buf, uint32 cfg_buf_len);
}
#endif
#endif /* end of CONNECTION_API_H_ */

View File

@ -33,10 +33,8 @@ typedef enum {
* @param user_data user data
*/
typedef void (*on_connection_event_f)(connection_t *conn,
conn_event_type_t type,
const char *data,
uint32 len,
void *user_data);
conn_event_type_t type, const char *data,
uint32 len, void *user_data);
/*
*****************
@ -54,17 +52,17 @@ typedef void (*on_connection_event_f)(connection_t *conn,
*
* @return the connection or NULL means fail
*/
connection_t *api_open_connection(const char *name,
attr_container_t *args,
on_connection_event_f on_event,
void *user_data);
connection_t *
api_open_connection(const char *name, attr_container_t *args,
on_connection_event_f on_event, void *user_data);
/*
* @brief Close a connection.
*
* @param conn connection
*/
void api_close_connection(connection_t *conn);
void
api_close_connection(connection_t *conn);
/*
* Send data to the connection in non-blocking manner which returns immediately
@ -75,7 +73,8 @@ void api_close_connection(connection_t *conn);
*
* @return actual length sent, or -1 if fail(maybe underlying buffer is full)
*/
int api_send_on_connection(connection_t *conn, const char *data, uint32 len);
int
api_send_on_connection(connection_t *conn, const char *data, uint32 len);
/*
* @brief Configure connection.
@ -85,8 +84,8 @@ int api_send_on_connection(connection_t *conn, const char *data, uint32 len);
*
* @return true if success, false otherwise
*/
bool api_config_connection(connection_t *conn, attr_container_t *cfg);
bool
api_config_connection(connection_t *conn, attr_container_t *cfg);
#ifdef __cplusplus
}