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:
@ -8,7 +8,7 @@
|
||||
#include "sensor_api.h"
|
||||
|
||||
typedef struct _sensor {
|
||||
struct _sensor * next;
|
||||
struct _sensor *next;
|
||||
char *name;
|
||||
uint32 handle;
|
||||
void (*sensor_callback)(sensor_t, attr_container_t *, void *);
|
||||
@ -17,16 +17,16 @@ typedef struct _sensor {
|
||||
|
||||
static sensor_t g_sensors = NULL;
|
||||
|
||||
sensor_t sensor_open(const char* name, int index,
|
||||
sensor_event_handler_f sensor_event_handler,
|
||||
void *user_data)
|
||||
sensor_t
|
||||
sensor_open(const char *name, int index,
|
||||
sensor_event_handler_f sensor_event_handler, void *user_data)
|
||||
{
|
||||
uint32 id = wasm_sensor_open(name, index);
|
||||
if (id == -1)
|
||||
return NULL;
|
||||
|
||||
//create local node for holding the user callback
|
||||
sensor_t sensor = (sensor_t) malloc(sizeof(struct _sensor));
|
||||
// create local node for holding the user callback
|
||||
sensor_t sensor = (sensor_t)malloc(sizeof(struct _sensor));
|
||||
if (sensor == NULL)
|
||||
return NULL;
|
||||
|
||||
@ -43,7 +43,8 @@ sensor_t sensor_open(const char* name, int index,
|
||||
|
||||
if (g_sensors == NULL) {
|
||||
g_sensors = sensor;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
sensor->next = g_sensors;
|
||||
g_sensors = sensor;
|
||||
}
|
||||
@ -51,7 +52,8 @@ sensor_t sensor_open(const char* name, int index,
|
||||
return sensor;
|
||||
}
|
||||
|
||||
bool sensor_config_with_attr_container(sensor_t sensor, attr_container_t *cfg)
|
||||
bool
|
||||
sensor_config_with_attr_container(sensor_t sensor, attr_container_t *cfg)
|
||||
{
|
||||
char *buffer = (char *)cfg;
|
||||
int len = attr_container_get_serialize_length(cfg);
|
||||
@ -59,13 +61,15 @@ bool sensor_config_with_attr_container(sensor_t sensor, attr_container_t *cfg)
|
||||
return wasm_sensor_config_with_attr_container(sensor->handle, buffer, len);
|
||||
}
|
||||
|
||||
bool sensor_config(sensor_t sensor, int interval, int bit_cfg, int delay)
|
||||
bool
|
||||
sensor_config(sensor_t sensor, int interval, int bit_cfg, int delay)
|
||||
{
|
||||
bool ret = wasm_sensor_config(sensor->handle, interval, bit_cfg, delay);
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool sensor_close(sensor_t sensor)
|
||||
bool
|
||||
sensor_close(sensor_t sensor)
|
||||
{
|
||||
wasm_sensor_close(sensor->handle);
|
||||
|
||||
@ -76,13 +80,15 @@ bool sensor_close(sensor_t sensor)
|
||||
if (s == sensor) {
|
||||
if (prev == NULL) {
|
||||
g_sensors = s->next;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
prev->next = s->next;
|
||||
}
|
||||
free(s->name);
|
||||
free(s);
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
prev = s;
|
||||
s = s->next;
|
||||
}
|
||||
@ -97,9 +103,10 @@ bool sensor_close(sensor_t sensor)
|
||||
*
|
||||
*/
|
||||
|
||||
void on_sensor_event(uint32 sensor_id, char * buffer, int len)
|
||||
void
|
||||
on_sensor_event(uint32 sensor_id, char *buffer, int len)
|
||||
{
|
||||
attr_container_t * sensor_data = (attr_container_t *) buffer;
|
||||
attr_container_t *sensor_data = (attr_container_t *)buffer;
|
||||
|
||||
// lookup the sensor and call the handlers
|
||||
sensor_t s = g_sensors;
|
||||
|
||||
@ -13,7 +13,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
uint32
|
||||
wasm_sensor_open(const char* name, int instance);
|
||||
wasm_sensor_open(const char *name, int instance);
|
||||
|
||||
bool
|
||||
wasm_sensor_config(uint32 sensor, int interval, int bit_cfg, int delay);
|
||||
@ -29,4 +29,3 @@ wasm_sensor_close(uint32 sensor);
|
||||
#endif
|
||||
|
||||
#endif /* end of _SENSOR_API_H_ */
|
||||
|
||||
|
||||
@ -30,8 +30,8 @@ typedef struct _sensor *sensor_t;
|
||||
* @see sensor_open
|
||||
*/
|
||||
typedef void (*sensor_event_handler_f)(sensor_t sensor,
|
||||
attr_container_t *sensor_event,
|
||||
void *user_data);
|
||||
attr_container_t *sensor_event,
|
||||
void *user_data);
|
||||
|
||||
/*
|
||||
*****************
|
||||
@ -49,10 +49,9 @@ typedef void (*sensor_event_handler_f)(sensor_t sensor,
|
||||
*
|
||||
* @return the sensor opened if success, NULL otherwise
|
||||
*/
|
||||
sensor_t sensor_open(const char* name,
|
||||
int index,
|
||||
sensor_event_handler_f handler,
|
||||
void *user_data);
|
||||
sensor_t
|
||||
sensor_open(const char *name, int index, sensor_event_handler_f handler,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* @brief Configure sensor with interval/bit_cfg/delay values.
|
||||
@ -64,7 +63,8 @@ sensor_t sensor_open(const char* name,
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool sensor_config(sensor_t sensor, int interval, int bit_cfg, int delay);
|
||||
bool
|
||||
sensor_config(sensor_t sensor, int interval, int bit_cfg, int delay);
|
||||
|
||||
/**
|
||||
* @brief Configure sensor with attr_container_t object.
|
||||
@ -74,7 +74,8 @@ bool sensor_config(sensor_t sensor, int interval, int bit_cfg, int delay);
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool sensor_config_with_attr_container(sensor_t sensor, attr_container_t *cfg);
|
||||
bool
|
||||
sensor_config_with_attr_container(sensor_t sensor, attr_container_t *cfg);
|
||||
|
||||
/**
|
||||
* @brief Close sensor.
|
||||
@ -83,7 +84,8 @@ bool sensor_config_with_attr_container(sensor_t sensor, attr_container_t *cfg);
|
||||
*
|
||||
* @return true if success, false otherwise
|
||||
*/
|
||||
bool sensor_close(sensor_t sensor);
|
||||
bool
|
||||
sensor_close(sensor_t sensor);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user