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

@ -3,7 +3,6 @@
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#include "native_interface.h"
#include "app_manager.h"
#include "app_manager_export.h"
@ -13,14 +12,15 @@
typedef struct _app_res_register {
struct _app_res_register *next;
char * url;
char *url;
void (*request_handler)(request_t *, void *);
uint32 register_id;
} app_res_register_t;
static app_res_register_t * g_resources = NULL;
static app_res_register_t *g_resources = NULL;
void module_request_handler(request_t *request, void *user_data)
void
module_request_handler(request_t *request, void *user_data)
{
unsigned int mod_id = (unsigned int)(uintptr_t)user_data;
bh_message_t msg;
@ -54,10 +54,11 @@ void module_request_handler(request_t *request, void *user_data)
}
app_manager_printf("Send request to app %s success.\n",
m_data->module_name);
m_data->module_name);
}
void targeted_app_request_handler(request_t *request, void *unused)
void
targeted_app_request_handler(request_t *request, void *unused)
{
char applet_name[128] = { 0 };
int offset;
@ -74,7 +75,8 @@ void targeted_app_request_handler(request_t *request, void *unused)
char *p = strchr(applet_name, '/');
if (p) {
*p = 0;
} else
}
else
return;
app_manager_printf("Send request to applet: %s\n", applet_name);
@ -84,16 +86,17 @@ void targeted_app_request_handler(request_t *request, void *unused)
m_data = module_data_list_lookup(applet_name);
if (!m_data) {
SEND_ERR_RESPONSE(request->mid,
"Send request to applet failed: invalid applet name");
"Send request to applet failed: invalid applet name");
goto end;
}
module_request_handler(request, (void *)(uintptr_t)m_data->id);
end: request->url = url;
end:
request->url = url;
}
void am_send_response(response_t *response)
void
am_send_response(response_t *response)
{
module_data *m_data;
@ -101,15 +104,15 @@ void am_send_response(response_t *response)
m_data = module_data_list_lookup_id(response->reciever);
if (!m_data) {
send_response_to_host(response);
} else {
response_t * resp_for_send = clone_response(response);
}
else {
response_t *resp_for_send = clone_response(response);
if (!resp_for_send) {
return;
}
bh_message_t msg = bh_new_msg(RESTFUL_RESPONSE, resp_for_send,
sizeof(*resp_for_send), response_cleaner);
sizeof(*resp_for_send), response_cleaner);
if (!msg) {
response_cleaner(resp_for_send);
return;
@ -121,7 +124,8 @@ void am_send_response(response_t *response)
}
}
void * am_dispatch_request(request_t *request)
void *
am_dispatch_request(request_t *request)
{
app_res_register_t *r = g_resources;
@ -135,11 +139,12 @@ void * am_dispatch_request(request_t *request)
return NULL;
}
bool am_register_resource(const char *url,
void (*request_handler)(request_t *, void *),
uint32 register_id)
bool
am_register_resource(const char *url,
void (*request_handler)(request_t *, void *),
uint32 register_id)
{
app_res_register_t * r = g_resources;
app_res_register_t *r = g_resources;
int register_num = 0;
while (r) {
@ -178,10 +183,11 @@ bool am_register_resource(const char *url,
return true;
}
void am_cleanup_registeration(uint32 register_id)
void
am_cleanup_registeration(uint32 register_id)
{
app_res_register_t * r = g_resources;
app_res_register_t * prev = NULL;
app_res_register_t *r = g_resources;
app_res_register_t *prev = NULL;
while (r) {
app_res_register_t *next = r->next;
@ -194,7 +200,8 @@ void am_cleanup_registeration(uint32 register_id)
APP_MGR_FREE(r->url);
APP_MGR_FREE(r);
} else
}
else
/* if r is freed, should not change prev. Only set prev to r
when r isn't freed. */
prev = r;