Fix the nxstyle warning

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2023-03-06 00:40:05 +08:00 committed by Petro Karashchenko
parent 575582ca85
commit f95d60366a
9 changed files with 108 additions and 66 deletions

View File

@ -316,8 +316,8 @@ int main(int argc, FAR char *argv[])
curs_set(0);
noecho();
/* Refresh stdscr so that reading from it will not cause it to overwrite the
* other windows that are being created.
/* Refresh stdscr so that reading from it will not cause it to overwrite
* the other windows that are being created.
*/
refresh();
@ -335,7 +335,7 @@ int main(int argc, FAR char *argv[])
return 1;
}
for (;;)
for (; ; )
{
init_pair(1, COLOR_WHITE, COLOR_BLUE);
wbkgd(win, COLOR_PAIR(1));

View File

@ -134,7 +134,8 @@ int main(int argc, FAR char *argv[])
ret = pthread_create(&tid2, NULL, select_listener, NULL);
if (ret != 0)
{
printf("poll_main: Failed to create select_listener thread: %d\n", ret);
printf("poll_main: Failed to create select_listener thread: %d\n",
ret);
exitcode = 6;
goto errout;
}

View File

@ -52,6 +52,7 @@ static inline void fill_buffer(unsigned char *buf, int offset)
{
j = 1;
}
buf[j] = ch;
}
}

View File

@ -53,9 +53,11 @@ static inline int check_buffer(unsigned char *buf)
{
j = 1;
}
if (buf[j] != ch)
{
printf("server: Buffer content error for offset=%d, index=%d\n", offset, j);
printf("server: Buffer content error for offset=%d, index=%d\n",
offset, j);
ret = 0;
}
}
@ -100,7 +102,7 @@ int main(int argc, FAR char *argv[])
addrlen += sizeof(sa_family_t) + 1;
if (bind(sockfd, (struct sockaddr*)&server, addrlen) < 0)
if (bind(sockfd, (struct sockaddr *)&server, addrlen) < 0)
{
printf("server: ERROR bind failure: %d\n", errno);
return 1;
@ -113,7 +115,7 @@ int main(int argc, FAR char *argv[])
printf("server: %d. Receiving up 1024 bytes\n", offset);
recvlen = addrlen;
nbytes = recvfrom(sockfd, inbuf, 1024, 0,
(struct sockaddr*)&client, &recvlen);
(struct sockaddr *)&client, &recvlen);
if (nbytes < 0)
{
@ -122,10 +124,11 @@ int main(int argc, FAR char *argv[])
return 1;
}
if (recvlen < sizeof(sa_family_t) || recvlen > sizeof(struct sockaddr_un))
if (recvlen < sizeof(sa_family_t) ||
recvlen > sizeof(struct sockaddr_un))
{
printf("server: %d. ERROR Received %d bytes from client with invalid length %d\n",
offset, nbytes, recvlen);
printf("server: %d. ERROR Received %d bytes from client with "
"invalid length %d\n", offset, nbytes, recvlen);
}
else if (recvlen == sizeof(sa_family_t))
{
@ -142,8 +145,8 @@ int main(int argc, FAR char *argv[])
printf("server: ERROR path not NUL terminated\n");
}
}
else /* if (recvlen > sizeof(sa_family_t)+1 &&
recvlen <= sizeof(struct sockaddr_un)) */
else /* if (recvlen > sizeof(sa_family_t) + 1 &&
* recvlen <= sizeof(struct sockaddr_un)) */
{
int pathlen = recvlen - sizeof(sa_family_t) - 1;

View File

@ -41,14 +41,14 @@
* Public Functions
****************************************************************************/
int main(int argc, FAR char *argv[])
int main(int argc, char *argv[])
{
#ifdef CONFIG_EXAMPLES_USTREAM_USE_POLL
struct pollfd pfd;
#endif
struct sockaddr_un myaddr;
socklen_t addrlen;
FAR char *buffer;
char *buffer;
int listensd;
int acceptsd;
int nbytesread;
@ -60,7 +60,7 @@ int main(int argc, FAR char *argv[])
/* Allocate a BIG buffer */
buffer = (char*)malloc(2*SENDSIZE);
buffer = (char *)malloc(2 * SENDSIZE);
if (!buffer)
{
printf("server: failed to allocate buffer\n");
@ -89,7 +89,7 @@ int main(int argc, FAR char *argv[])
myaddr.sun_path[addrlen] = '\0';
addrlen += sizeof(sa_family_t) + 1;
ret = bind(listensd, (struct sockaddr*)&myaddr, addrlen);
ret = bind(listensd, (struct sockaddr *)&myaddr, addrlen);
if (ret < 0)
{
printf("server: bind failure: %d\n", errno);
@ -98,7 +98,8 @@ int main(int argc, FAR char *argv[])
/* Listen for connections on the bound socket */
printf("server: Accepting connections on %s ...\n", CONFIG_EXAMPLES_USTREAM_ADDR);
printf("server: Accepting connections on %s ...\n",
CONFIG_EXAMPLES_USTREAM_ADDR);
if (listen(listensd, 5) < 0)
{
@ -131,7 +132,7 @@ int main(int argc, FAR char *argv[])
}
#endif
acceptsd = accept(listensd, (struct sockaddr*)&myaddr, &addrlen);
acceptsd = accept(listensd, (struct sockaddr *)&myaddr, &addrlen);
if (acceptsd < 0)
{
printf("server: accept failure: %d\n", errno);
@ -169,7 +170,8 @@ int main(int argc, FAR char *argv[])
#endif
printf("server: Reading...\n");
nbytesread = recv(acceptsd, &buffer[totalbytesread], 2*SENDSIZE - totalbytesread, 0);
nbytesread = recv(acceptsd, &buffer[totalbytesread],
2 * SENDSIZE - totalbytesread, 0);
if (nbytesread < 0)
{
printf("server: recv failed: %d\n", errno);
@ -189,7 +191,8 @@ int main(int argc, FAR char *argv[])
if (totalbytesread != SENDSIZE)
{
printf("server: Received %d / Expected %d bytes\n", totalbytesread, SENDSIZE);
printf("server: Received %d / Expected %d bytes\n",
totalbytesread, SENDSIZE);
goto errout_with_acceptsd;
}
@ -198,7 +201,8 @@ int main(int argc, FAR char *argv[])
{
if (buffer[i] != ch)
{
printf("server: Byte %d is %02x / Expected %02x\n", i, buffer[i], ch);
printf("server: Byte %d is %02x / Expected %02x\n",
i, buffer[i], ch);
goto errout_with_acceptsd;
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/graphics/pdcurses/pdc_panel.c
* apps/graphics/pdcurs34/pdcurses/pdc_panel.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@ -149,9 +149,12 @@
****************************************************************************/
#ifndef CONFIG_PDCURSES_MULTITHREAD
PANEL *_bottom_panel = (PANEL *) 0;
PANEL *_top_panel = (PANEL *) 0;
PANEL _stdscr_pseudo_panel = { (WINDOW *) 0 };
PANEL *_bottom_panel = (PANEL *)0;
PANEL *_top_panel = (PANEL *)0;
PANEL _stdscr_pseudo_panel =
{
(WINDOW *)0
};
#else
typedef struct panel_ctx_s
{
@ -177,7 +180,8 @@ static void dpanel(char *text, PANEL *pan)
{
PDC_LOG(("%s id=%s b=%s a=%s y=%d x=%d", text, pan->user,
pan->below ? pan->below->user : "--",
pan->above ? pan->above->user : "--", pan->wstarty, pan->wstartx));
pan->above ? pan->above->user : "--",
pan->wstarty, pan->wstartx));
}
static void dstack(char *fmt, int num, PANEL *pan)
@ -686,7 +690,8 @@ WINDOW *panel_window(const PANEL *pan)
int replace_panel(PANEL *pan, WINDOW *win)
{
int maxy, maxx;
int maxy;
int maxx;
if (!pan)
{

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/examples/screenshot/screenshot_main.c
* apps/graphics/screenshot/screenshot_main.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@ -69,7 +69,8 @@
* Private Functions
****************************************************************************/
static void replace_extension(FAR const char *filename, FAR const char *newext,
static void replace_extension(FAR const char *filename,
FAR const char *newext,
FAR char *dest, size_t size)
{
FAR char *p = strrchr(filename, '.');
@ -104,8 +105,15 @@ static void replace_extension(FAR const char *filename, FAR const char *newext,
int save_screenshot(FAR const char *filename)
{
struct tiff_info_s info;
struct nx_callback_s cb = {};
struct nxgl_size_s size = {CONFIG_SCREENSHOT_WIDTH, CONFIG_SCREENSHOT_HEIGHT};
struct nx_callback_s cb =
{
};
struct nxgl_size_s size =
{
CONFIG_SCREENSHOT_WIDTH, CONFIG_SCREENSHOT_HEIGHT
};
#ifdef CONFIG_VNCSERVER
struct boardioc_vncstart_s vnc;
#endif
@ -130,18 +138,18 @@ int save_screenshot(FAR const char *filename)
}
#ifdef CONFIG_VNCSERVER
/* Setup the VNC server to support keyboard/mouse inputs */
/* Setup the VNC server to support keyboard/mouse inputs */
vnc.display = 0;
vnc.handle = server;
vnc.display = 0;
vnc.handle = server;
ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
if (ret < 0)
{
printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
nx_disconnect(server);
return 1;
}
ret = boardctl(BOARDIOC_VNC_START, (uintptr_t)&vnc);
if (ret < 0)
{
printf("boardctl(BOARDIOC_VNC_START) failed: %d\n", ret);
nx_disconnect(server);
return 1;
}
#endif
/* Wait for "connected" event */
@ -157,11 +165,11 @@ int save_screenshot(FAR const char *filename)
window = nx_openwindow(server, 0, &cb, NULL);
if (!window)
{
perror("nx_openwindow");
nx_disconnect(server);
return 1;
}
{
perror("nx_openwindow");
nx_disconnect(server);
return 1;
}
nx_setsize(window, &size);
@ -192,17 +200,26 @@ int save_screenshot(FAR const char *filename)
strip = malloc(size.w * 3);
for (row = 0; row < size.h; row++)
{
struct nxgl_rect_s rect = {{0, row}, {size.w - 1, row}};
nx_getrectangle(window, &rect, 0, strip, 0);
ret = tiff_addstrip(&info, strip);
if (ret < 0)
{
struct nxgl_rect_s rect =
{
printf("tiff_addstrip() #%d failed: %d\n", row, ret);
break;
}
}
{
0, row
},
{
size.w - 1, row
}
};
nx_getrectangle(window, &rect, 0, strip, 0);
ret = tiff_addstrip(&info, strip);
if (ret < 0)
{
printf("tiff_addstrip() #%d failed: %d\n", row, ret);
break;
}
}
free(strip);

View File

@ -67,7 +67,8 @@ struct Xref
{
struct Pc line;
struct LineNumber *next;
} *lines;
}
*lines;
struct Xref *l;
struct Xref *r;
};
@ -175,8 +176,8 @@ static void Xref_print(struct Xref *root,
static int cmpLine(const void *a, const void *b)
{
const register struct Pc *pcA = (const struct Pc *)a, *pcB =
(const struct Pc *)b;
const register struct Pc *pcA = (const struct Pc *)a;
const register struct Pc *pcB = (const struct Pc *)b;
return pcA->line - pcB->line;
}
@ -192,7 +193,8 @@ static void printLine(const void *k, struct Program *p, int chn)
static int cmpName(const void *a, const void *b)
{
const register char *funcA = (const char *)a, *funcB = (const char *)b;
const register char *funcA = (const char *)a;
const register char *funcB = (const char *)b;
return strcmp(funcA, funcB);
}
@ -317,7 +319,9 @@ void Program_store(struct Program *this, struct Token *line, long int where)
void Program_delete(struct Program *this, const struct Pc *from,
const struct Pc *to)
{
int i, first, last;
int i;
int first;
int last;
this->runnable = 0;
this->unsaved = 1;
@ -696,13 +700,16 @@ struct Value *Program_merge(struct Program *this, int dev,
int Program_lineNumberWidth(struct Program *this)
{
int i, w = 0;
int i;
int w = 0;
for (i = 0; i < this->size; ++i)
{
if (this->code[i]->type == T_INTEGER)
{
int nw, ln;
int nw;
int ln;
for (ln = this->code[i]->u.integer, nw = 1; ln /= 10; ++nw);
if (nw > w)
{
@ -718,7 +725,8 @@ struct Value *Program_list(struct Program *this, int dev, int watchIntr,
struct Pc *from, struct Pc *to,
struct Value *value)
{
int i, w;
int i;
int w;
int indent = 0;
struct String s;
@ -940,7 +948,10 @@ int Program_setname(struct Program *this, const char *filename)
void Program_xref(struct Program *this, int chn)
{
struct Pc pc;
struct Xref *func, *var, *gosub, *goto_;
struct Xref *func;
struct Xref *var;
struct Xref *gosub;
struct Xref *goto_;
int nl = 0;
assert(this->runnable);

View File

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