apps: examples: nxstyle fixes

Fix for errors reported by the nxstyle tool.

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
This commit is contained in:
Alin Jerpelea 2022-03-08 09:57:25 +00:00 committed by Petro Karashchenko
parent abf34e5d5a
commit 3984796156
9 changed files with 128 additions and 105 deletions

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/examples/touchscreen/tp_cal.c
* apps/examples/lvgldemo/tp_cal.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with

View File

@ -47,7 +47,7 @@ extern "C"
void tp_cal_create(void);
#ifdef __cplusplus
} /* extern "C" */
}
#endif
#endif /*__APPS_EXAMPLES_LVGLDEMO_TP_CAL_H*/
#endif /* __APPS_EXAMPLES_LVGLDEMO_TP_CAL_H */

View File

@ -82,12 +82,14 @@ int main(int argc, FAR char *argv[])
/* Start reading each file and print sensor temperature if acquired */
printf("Starting...\n");
while(1)
while (1)
{
printf("Channel SSP0/SPI1 Device 0: ");
if (fd0 < 0)
{
/* The file could not be open, probably the device is not registered */
/* The file could not be open,
* probably the device is not registered
*/
printf("Not enabled!\n");
}
@ -106,14 +108,16 @@ int main(int argc, FAR char *argv[])
{
/* Print temperature value of target device */
printf("Temperature = %d!\n",temp/4);
printf("Temperature = %d!\n", temp / 4);
}
}
printf("Channel SSP0/SPI1 Device 1: ");
if (fd1 < 0)
{
/* The file could not be open, probably the device is not registered */
/* The file could not be open,
* probably the device is not registered
*/
printf("Not enabled!\n");
}
@ -122,8 +126,8 @@ int main(int argc, FAR char *argv[])
ret = read(fd1, &temp, 2);
if (ret < 0)
{
/* The file could not be read, probably some max31855 pin is not
* connected to the channel.
/* The file could not be read, probably some max31855 pin is
* not connected to the channel.
*/
printf("Disconnected!\n");
@ -132,14 +136,16 @@ int main(int argc, FAR char *argv[])
{
/* Print temperature value of target device */
printf("Temperature = %d!\n",temp/4);
printf("Temperature = %d!\n", temp / 4);
}
}
printf("Channel SSP1/SPI2 Device 0: ");
if (fd2 < 0)
{
/* The file could not be open, probably the device is not registered */
/* The file could not be open,
* probably the device is not registered
*/
printf("Not enabled!\n");
}
@ -148,8 +154,8 @@ int main(int argc, FAR char *argv[])
ret = read(fd2, &temp, 2);
if (ret < 0)
{
/* The file could not be read, probably some max31855 pin is not
* connected to the channel.
/* The file could not be read, probably some max31855 pin is
* not connected to the channel.
*/
printf("Disconnected!\n");
@ -158,14 +164,16 @@ int main(int argc, FAR char *argv[])
{
/* Print temperature value of target device */
printf("Temperature = %d!\n",temp/4);
printf("Temperature = %d!\n", temp / 4);
}
}
printf("Channel SSP1/SPI2 Device 1: ");
if (fd3 < 0)
{
/* The file could not be open, probably the device is not registered */
/* The file could not be open,
* probably the device is not registered
*/
printf("Not enabled!\n");
}
@ -184,7 +192,7 @@ int main(int argc, FAR char *argv[])
{
/* Print temperature value of target device */
printf("Temperature = %d!\n",temp/4);
printf("Temperature = %d!\n", temp / 4);
}
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* net/recvfrom.c
* apps/examples/netpkt/netpkt_main.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@ -76,11 +76,11 @@ static void print_buf(const uint8_t *buf, int len)
{
printf("%02X", buf[i]);
if ((i+1) % 16 == 0 || (i+1) == len)
if ((i + 1) % 16 == 0 || (i + 1) == len)
{
printf("\n");
}
else if ((i+1) % 8 == 0)
else if ((i + 1) % 8 == 0)
{
printf(" ");
}
@ -88,7 +88,7 @@ static void print_buf(const uint8_t *buf, int len)
{
printf(" ");
}
}
}
}
/****************************************************************************
@ -122,8 +122,15 @@ int main(int argc, FAR char *argv[])
int rxc;
uint8_t *buf;
const int buflen = 128;
const char da[6] = {0xf0, 0xde, 0xf1, 0x02, 0x43, 0x01};
const char sa[6] = {0x00, 0xe0, 0xde, 0xad, 0xbe, 0xef};
const char da[6] =
{
0xf0, 0xde, 0xf1, 0x02, 0x43, 0x01
};
const char sa[6] =
{
0x00, 0xe0, 0xde, 0xad, 0xbe, 0xef
};
int opt;
int verbose = 0;
@ -142,7 +149,7 @@ int main(int argc, FAR char *argv[])
while ((opt = getopt(argc, argv, "artv")) != -1)
{
switch(opt)
switch (opt)
{
case 'a':
do_rx = 1;
@ -179,7 +186,7 @@ int main(int argc, FAR char *argv[])
buf = malloc(buflen);
memset(buf, 0, buflen);
memcpy(buf, da, 6);
memcpy(buf+6, sa, 6);
memcpy(buf + 6, sa, 6);
for (i = 0; i < do_txtimes; i++)
{
if ((txc = write(sd, buf, buflen)) < 0)

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/examples/nxdemo/nxdemo.h
* apps/examples/nxdemo/images.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@ -31,12 +31,16 @@
* Public Data
****************************************************************************/
static uint8_t g_battery [] =
static uint8_t g_battery[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xfc, 0x10, 0x00, 0x04, 0x37, 0x77,
0x74, 0x37, 0x77, 0x74, 0x37, 0x77, 0x74, 0x37, 0x77, 0x74, 0x10, 0x00, 0x04, 0x0f, 0xff, 0xfc,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x0f, 0xff, 0xfc, 0x10, 0x00, 0x04, 0x37, 0x77,
0x74, 0x37, 0x77, 0x74, 0x37, 0x77, 0x74, 0x37,
0x77, 0x74, 0x10, 0x00, 0x04, 0x0f, 0xff, 0xfc,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

View File

@ -80,7 +80,8 @@
static void nxdemo_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
bool morem, FAR void *arg);
static void nxdemo_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size,
static void nxdemo_position(NXWINDOW hwnd,
FAR const struct nxgl_size_s *size,
FAR const struct nxgl_point_s *pos,
FAR const struct nxgl_rect_s *bounds,
FAR void *arg);
@ -137,10 +138,11 @@ static void nxdemo_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect,
* Name: nxdemo_position
****************************************************************************/
static void nxdemo_position(NXWINDOW hwnd, FAR const struct nxgl_size_s *size,
FAR const struct nxgl_point_s *pos,
FAR const struct nxgl_rect_s *bounds,
FAR void *arg)
static void nxdemo_position(NXWINDOW hwnd,
FAR const struct nxgl_size_s *size,
FAR const struct nxgl_point_s *pos,
FAR const struct nxgl_rect_s *bounds,
FAR void *arg)
{
/* Report the position */
@ -276,7 +278,7 @@ static void nxdemo_demo_1(NXWINDOW hwnd)
center.x = g_nxdemo.xres >> 1;
center.y = g_nxdemo.yres >> 1;
for (i = 0; i<MIN(g_nxdemo.xres, g_nxdemo.yres)>> 1; i++)
for (i = 0; i < (MIN(g_nxdemo.xres, g_nxdemo.yres) >> 1); i++)
{
circle_radius = i;
@ -334,7 +336,7 @@ static void nxdemo_demo_2(NXWINDOW hwnd)
center.x = g_nxdemo.xres >> 1;
center.y = g_nxdemo.yres >> 1;
for (i = 0; i<MIN(g_nxdemo.xres, g_nxdemo.yres)>> 1; i++)
for (i = 0; i < (MIN(g_nxdemo.xres, g_nxdemo.yres) >> 1); i++)
{
rect.pt1.x = center.x - i;
rect.pt1.y = center.y - i;
@ -360,7 +362,6 @@ static void nxdemo_demo_2(NXWINDOW hwnd)
for (i = MIN(g_nxdemo.xres, g_nxdemo.yres) >> 1; i > 1; i--)
{
rect.pt1.x = center.x - i;
rect.pt1.y = center.y - i;
rect.pt2.x = center.x + i;

View File

@ -58,6 +58,7 @@
****************************************************************************/
/* Configuration ************************************************************/
/* If not specified, assume that the hardware supports one video plane */
#ifndef CONFIG_EXAMPLES_NXDEMO_VPLANE
@ -115,7 +116,8 @@ static inline int nxdemo_initialize(void)
ret = boardctl(BOARDIOC_NX_START, 0);
if (ret < 0)
{
printf("nxdemo_initialize: Failed to start the NX server: %d\n", errno);
printf("nxdemo_initialize: "
"Failed to start the NX server: %d\n", errno);
return ERROR;
}
@ -124,52 +126,53 @@ static inline int nxdemo_initialize(void)
g_nxdemo.hnx = nx_connect();
if (g_nxdemo.hnx)
{
pthread_attr_t attr;
pthread_attr_t attr;
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
struct boardioc_vncstart_s vnc =
{
0, g_nxdemo.hnx
};
struct boardioc_vncstart_s vnc =
{
0, g_nxdemo.hnx
};
ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
if (ret < 0)
{
printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
nx_disconnect(g_nxdemo.hnx);
return ERROR;
}
ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
if (ret < 0)
{
printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
nx_disconnect(g_nxdemo.hnx);
return ERROR;
}
#endif
/* Start a separate thread to listen for server events. This is probably
* the least efficient way to do this, but it makes this example flow more
* smoothly.
*/
/* Start a separate thread to listen for server events.
* This is probably the least efficient way to do this,
* but it makes this example flow more smoothly.
*/
pthread_attr_init(&attr);
param.sched_priority = CONFIG_EXAMPLES_NXDEMO_LISTENERPRIO;
pthread_attr_setschedparam(&attr, &param);
pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_NXDEMO_LISTENER_STACKSIZE);
pthread_attr_init(&attr);
param.sched_priority = CONFIG_EXAMPLES_NXDEMO_LISTENERPRIO;
pthread_attr_setschedparam(&attr, &param);
pthread_attr_setstacksize(&attr,
CONFIG_EXAMPLES_NXDEMO_LISTENER_STACKSIZE);
ret = pthread_create(&thread, &attr, nxdemo_listener, NULL);
if (ret != 0)
{
printf("nxdemo_initialize: pthread_create failed: %d\n", ret);
return ERROR;
}
ret = pthread_create(&thread, &attr, nxdemo_listener, NULL);
if (ret != 0)
{
printf("nxdemo_initialize: pthread_create failed: %d\n", ret);
return ERROR;
}
/* Don't return until we are connected to the server */
/* Don't return until we are connected to the server */
while (!g_nxdemo.connected)
{
/* Wait for the listener thread to wake us up when we really
* are connected.
*/
while (!g_nxdemo.connected)
{
/* Wait for the listener thread to wake us up when we really
* are connected.
*/
sem_wait(&g_nxdemo.eventsem);
}
sem_wait(&g_nxdemo.eventsem);
}
}
else
{

View File

@ -110,15 +110,15 @@ int main(int argc, FAR char *argv[])
if (optind == argc - 1)
{
stat = argv[optind];
set_stat = (!strcmp(stat,"on") || !strcmp(stat,"ON")) ? true : false ;
set_stat = (strcmp(stat, "on") == 0 || strcmp(stat, "ON") == 0);
}
up_relaysinit();
if (n >= 0)
{
printf("set RELAY ID %d to %s\n", n , set_stat ? "ON" : "OFF");
relays_setstat(n,set_stat);
printf("set RELAY ID %d to %s\n", n, set_stat ? "ON" : "OFF");
relays_setstat(n, set_stat);
}
else
{

View File

@ -70,32 +70,32 @@
#define CON_NBR 4
#define ESP8266_ACCESS_POINT_NBR_MAX 32
#define ESP8266_ACCESS_POINT_NBR_MAX 32
#define LESP_WAITING_OK_POLLING_MS 250
#define LESP_TIMEOUT_FLUSH_MS 100
#define LESP_TIMEOUT_MS 1000
#define LESP_TIMEOUT_MS_SEND 1000
#define LESP_TIMEOUT_MS_CONNECTION 30000
#define LESP_TIMEOUT_MS_LISP_AP 5000
#define LESP_WAITING_OK_POLLING_MS 250
#define LESP_TIMEOUT_FLUSH_MS 100
#define LESP_TIMEOUT_MS 1000
#define LESP_TIMEOUT_MS_SEND 1000
#define LESP_TIMEOUT_MS_CONNECTION 30000
#define LESP_TIMEOUT_MS_LISP_AP 5000
#define LESP_TIMEOUT_FLOODING_OFFSET_S 3
#define LESP_TIMEOUT_MS_RECV_S 60
#define LESP_TIMEOUT_MS_RECV_S 60
#define LESP_CON_USED_MASK(idx) (1<<(idx))
#define LESP_POLLING_TIME_MS 1000
#define LESP_CON_USED_MASK(idx) (1<<(idx))
#define LESP_POLLING_TIME_MS 1000
/* Must be a power of 2 */
#define SOCKET_FIFO_SIZE 2048
#define SOCKET_NBR 4
#define SOCKET_FIFO_SIZE 2048
#define SOCKET_NBR 4
#define FLAGS_SOCK_USED (1 << 0)
#define FLAGS_SOCK_CONNECTED (1 << 1)
#define FLAGS_SOCK_USED (1 << 0)
#define FLAGS_SOCK_CONNECTED (1 << 1)
#define FLAGS_SOCK_TYPE_MASK (3 << 2)
#define FLAGS_SOCK_TYPE_TCP (0 << 2)
#define FLAGS_SOCK_TYPE_UDP (1 << 2)
#define FLAGS_SOCK_TYPE_SSL (2 << 2) /* non standard but useful */
#define FLAGS_SOCK_TYPE_MASK (3 << 2)
#define FLAGS_SOCK_TYPE_TCP (0 << 2)
#define FLAGS_SOCK_TYPE_UDP (1 << 2)
#define FLAGS_SOCK_TYPE_SSL (2 << 2) /* non standard but useful */
/****************************************************************************
* Private Types
@ -744,8 +744,8 @@ int lesp_read_ans_ok(int timeout_ms)
{
ret = lesp_read(timeout_ms);
if ((ret < 0) || (g_lesp_state.and == LESP_ERR) || \
(time(NULL) > end))
if ((ret < 0) || (g_lesp_state.and == LESP_ERR) ||
(time(NULL) > end))
{
ret = -1;
break;
@ -1317,7 +1317,7 @@ static void *lesp_worker(void *args)
else
{
nerr("Worker and line is too long:%s\n",
worker->rxbuf);
worker->rxbuf);
}
}
@ -1741,7 +1741,7 @@ int lesp_get_net(lesp_mode_t mode, in_addr_t *ip,
if (ret >= 0)
{
ret = lesp_send_cmd("AT+CIP%s_CUR?\r\n",
(mode == LESP_MODE_STATION)?"STA":"AP");
(mode == LESP_MODE_STATION) ? "STA" : "AP");
}
if (ret >= 0)
@ -1839,7 +1839,7 @@ int lesp_set_net(lesp_mode_t mode, in_addr_t ip,
{
ret = lesp_ask_ans_ok(LESP_TIMEOUT_MS, "AT+CIP%s_CUR=\"%d.%d.%d.%d\","
"\"%d.%d.%d.%d\",\"%d.%d.%d.%d\"\r\n",
(mode == LESP_MODE_STATION)?"STA":"AP",
(mode == LESP_MODE_STATION) ? "STA" : "AP",
*((uint8_t *)&(ip)+0), *((uint8_t *)&(ip)+1),
*((uint8_t *)&(ip)+2), *((uint8_t *)&(ip)+3),
*((uint8_t *)&(gateway)+0),
@ -1888,7 +1888,7 @@ int lesp_set_dhcp(lesp_mode_t mode, bool enable)
if (ret >= 0)
{
ret = lesp_ask_ans_ok(LESP_TIMEOUT_MS, "AT+CWDHCP_CUR=%d,%c\r\n",
mode, (enable)?'1':'0');
mode, enable ? '1' : '0');
}
pthread_mutex_unlock(&g_lesp_state.mutex);
@ -2281,8 +2281,8 @@ int lesp_bind(int sockfd, FAR const struct sockaddr *addr, socklen_t addrlen)
*
****************************************************************************/
int lesp_connect(int sockfd,
FAR const struct sockaddr *addr, socklen_t addrlen)
int lesp_connect(int sockfd, FAR const struct sockaddr *addr,
socklen_t addrlen)
{
int ret = 0;
const char *proto_str;
@ -2339,8 +2339,8 @@ int lesp_connect(int sockfd,
{
ret = lesp_ask_ans_ok(LESP_TIMEOUT_MS, "AT+CIPSTART=%d,\"%s\","
"\"%d.%d.%d.%d\",%d\r\n", sockfd, proto_str,
*((uint8_t *)&(ip)+0), *((uint8_t *)&(ip)+1),
*((uint8_t *)&(ip)+2), *((uint8_t *)&(ip)+3),
*((uint8_t *)&ip + 0), *((uint8_t *)&ip +1),
*((uint8_t *)&ip + 2), *((uint8_t *)&ip + 3),
port);
if (ret < 0)
{
@ -2674,7 +2674,7 @@ int lesp_setsockopt(int sockfd, int level, int option,
if (value_len == sizeof(struct timeval))
{
sock->rcv_timeo.tv_sec = ((struct timeval *)
(value))->tv_sec;
(value))->tv_sec;
sock->rcv_timeo.tv_nsec = ((struct timeval *)
(value))->tv_usec;
sock->rcv_timeo.tv_nsec *= 1000; /* tv_usec to tv_nsec */