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:
@ -22,7 +22,8 @@
|
||||
|
||||
unsigned char leading[2] = { 0x12, 0x34 };
|
||||
|
||||
bool tcp_init(const char *address, uint16_t port, int *fd)
|
||||
bool
|
||||
tcp_init(const char *address, uint16_t port, int *fd)
|
||||
{
|
||||
int sock;
|
||||
struct sockaddr_in servaddr;
|
||||
@ -35,7 +36,7 @@ bool tcp_init(const char *address, uint16_t port, int *fd)
|
||||
servaddr.sin_addr.s_addr = inet_addr(address);
|
||||
servaddr.sin_port = htons(port);
|
||||
|
||||
if (connect(sock, (SA*) &servaddr, sizeof(servaddr)) != 0) {
|
||||
if (connect(sock, (SA *)&servaddr, sizeof(servaddr)) != 0) {
|
||||
close(sock);
|
||||
return false;
|
||||
}
|
||||
@ -44,7 +45,8 @@ bool tcp_init(const char *address, uint16_t port, int *fd)
|
||||
return true;
|
||||
}
|
||||
|
||||
int parse_baudrate(int baud)
|
||||
int
|
||||
parse_baudrate(int baud)
|
||||
{
|
||||
switch (baud) {
|
||||
case 9600:
|
||||
@ -88,7 +90,8 @@ int parse_baudrate(int baud)
|
||||
}
|
||||
}
|
||||
|
||||
bool uart_init(const char *device, int baudrate, int *fd)
|
||||
bool
|
||||
uart_init(const char *device, int baudrate, int *fd)
|
||||
{
|
||||
int uart_fd;
|
||||
struct termios uart_term;
|
||||
@ -118,12 +121,13 @@ bool uart_init(const char *device, int baudrate, int *fd)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool udp_send(const char *address, int port, const char *buf, int len)
|
||||
bool
|
||||
udp_send(const char *address, int port, const char *buf, int len)
|
||||
{
|
||||
int sockfd;
|
||||
struct sockaddr_in servaddr;
|
||||
|
||||
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0 )
|
||||
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
return false;
|
||||
|
||||
memset(&servaddr, 0, sizeof(servaddr));
|
||||
@ -132,14 +136,15 @@ bool udp_send(const char *address, int port, const char *buf, int len)
|
||||
servaddr.sin_port = htons(port);
|
||||
servaddr.sin_addr.s_addr = INADDR_ANY;
|
||||
|
||||
sendto(sockfd, buf, len, MSG_CONFIRM,
|
||||
(const struct sockaddr *)&servaddr, sizeof(servaddr));
|
||||
sendto(sockfd, buf, len, MSG_CONFIRM, (const struct sockaddr *)&servaddr,
|
||||
sizeof(servaddr));
|
||||
|
||||
close(sockfd);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool host_tool_send_data(int fd, const char *buf, unsigned int len)
|
||||
bool
|
||||
host_tool_send_data(int fd, const char *buf, unsigned int len)
|
||||
{
|
||||
int cnt = 0;
|
||||
ssize_t ret;
|
||||
@ -170,7 +175,11 @@ resend:
|
||||
return (ret == len);
|
||||
}
|
||||
|
||||
#define SET_RECV_PHASE(ctx, new_phase) {ctx->phase = new_phase; ctx->size_in_phase = 0;}
|
||||
#define SET_RECV_PHASE(ctx, new_phase) \
|
||||
do { \
|
||||
ctx->phase = new_phase; \
|
||||
ctx->size_in_phase = 0; \
|
||||
} while (0)
|
||||
|
||||
/*
|
||||
* input: 1 byte from remote
|
||||
@ -180,7 +189,8 @@ resend:
|
||||
* 0 completed packet
|
||||
* 2 in receiving payload
|
||||
*/
|
||||
int on_imrt_link_byte_arrive(unsigned char ch, imrt_link_recv_context_t *ctx)
|
||||
int
|
||||
on_imrt_link_byte_arrive(unsigned char ch, imrt_link_recv_context_t *ctx)
|
||||
{
|
||||
if (ctx->phase == Phase_Non_Start) {
|
||||
if (ctx->message.payload) {
|
||||
@ -206,7 +216,7 @@ int on_imrt_link_byte_arrive(unsigned char ch, imrt_link_recv_context_t *ctx)
|
||||
}
|
||||
}
|
||||
else if (ctx->phase == Phase_Type) {
|
||||
unsigned char *p = (unsigned char *) &ctx->message.message_type;
|
||||
unsigned char *p = (unsigned char *)&ctx->message.message_type;
|
||||
p[ctx->size_in_phase++] = ch;
|
||||
|
||||
if (ctx->size_in_phase == sizeof(ctx->message.message_type)) {
|
||||
@ -215,7 +225,7 @@ int on_imrt_link_byte_arrive(unsigned char ch, imrt_link_recv_context_t *ctx)
|
||||
}
|
||||
}
|
||||
else if (ctx->phase == Phase_Size) {
|
||||
unsigned char * p = (unsigned char *) &ctx->message.payload_size;
|
||||
unsigned char *p = (unsigned char *)&ctx->message.payload_size;
|
||||
p[ctx->size_in_phase++] = ch;
|
||||
|
||||
if (ctx->size_in_phase == sizeof(ctx->message.payload_size)) {
|
||||
@ -233,7 +243,7 @@ int on_imrt_link_byte_arrive(unsigned char ch, imrt_link_recv_context_t *ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
ctx->message.payload = (char *) malloc(ctx->message.payload_size);
|
||||
ctx->message.payload = (char *)malloc(ctx->message.payload_size);
|
||||
SET_RECV_PHASE(ctx, Phase_Payload);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user