Include debug.h for xerr/xinfo/xwarn caller

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-05-24 15:31:54 +08:00 • committed by Masayuki Ishikawa
parent 98de0d6a68
commit 82ed7bf5b1
2 changed files with 36 additions and 32 deletions

View file

@ -43,6 +43,7 @@
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <debug.h>
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
@ -72,7 +73,7 @@ struct chat_app
/* Private fields */
int argc; /* number of command-line arguments */
FAR char** argv; /* command-line arguments */
FAR char **argv; /* command-line arguments */
char tty[CHAT_TTYNAME_SIZE]; /* modem TTY device node */
FAR const char *script; /* raw chat script - input to the parser */
bool script_dynalloc; /* true if the script should be freed */
@ -156,8 +157,8 @@ static int chat_script_preset(FAR struct chat_app *priv, int script_number)
return ret;
}
static int chat_script_read(FAR struct chat_app* priv,
FAR const char* filepath)
static int chat_script_read(FAR struct chat_app *priv,
FAR const char *filepath)
{
FAR char *scriptp;
size_t spare_size = CONFIG_EXAMPLES_CHAT_SIZE - 1;
@ -217,7 +218,7 @@ static int chat_script_read(FAR struct chat_app* priv,
return ret;
}
static int chat_parse_args(FAR struct chat_app* priv)
static int chat_parse_args(FAR struct chat_app *priv)
{
/* -d TTY device node (non-Linux feature)
* -e echo to stderr
@ -251,11 +252,12 @@ static int chat_parse_args(FAR struct chat_app* priv)
switch (priv->argv[i][1])
{
case 'd':
/* set the TTY device node */
strncpy(priv->tty,
(FAR char*) priv->argv[i] + 2,
CHAT_TTYNAME_SIZE-1);
(FAR char *)priv->argv[i] + 2,
CHAT_TTYNAME_SIZE - 1);
break;
case 'e':
@ -264,11 +266,11 @@ static int chat_parse_args(FAR struct chat_app* priv)
case 'f':
ret = chat_script_read(priv,
(FAR char*) priv->argv[i] + 2);
(FAR char *)priv->argv[i] + 2);
break;
case 'p':
numarg = strtol((FAR char*) priv->argv[i] + 2,
numarg = strtol((FAR char *)priv->argv[i] + 2,
NULL, 10);
if (errno < 0)
{
@ -280,7 +282,7 @@ static int chat_parse_args(FAR struct chat_app* priv)
break;
case 't':
numarg = strtol((FAR char*) priv->argv[i] + 2,
numarg = strtol((FAR char *)priv->argv[i] + 2,
NULL, 10);
if (errno < 0 || numarg < 0)
@ -320,7 +322,7 @@ static int chat_parse_args(FAR struct chat_app* priv)
*
****************************************************************************/
int main(int argc, FAR char** argv)
int main(int argc, FAR char **argv)
{
struct chat_app priv;
int ret;
@ -333,10 +335,10 @@ int main(int argc, FAR char** argv)
priv.ctl.timeout = CONFIG_EXAMPLES_CHAT_TIMEOUT_SECONDS;
priv.script = NULL;
priv.script_dynalloc = false;
strncpy(priv.tty, CONFIG_EXAMPLES_CHAT_TTY_DEVNODE, CHAT_TTYNAME_SIZE-1);
strncpy(priv.tty, CONFIG_EXAMPLES_CHAT_TTY_DEVNODE, CHAT_TTYNAME_SIZE - 1);
_info("parsing the arguments\n");
ret = chat_parse_args((FAR struct chat_app*) &priv);
ret = chat_parse_args((FAR struct chat_app *)&priv);
if (ret < 0)
{
_info("Command line parsing failed: code %d, errno %d\n", ret, errno);
@ -370,7 +372,7 @@ int main(int argc, FAR char** argv)
goto with_tty_dev;
}
ret = chat((FAR struct chat_ctl*) &priv.ctl, priv.script);
ret = chat((FAR struct chat_ctl *)&priv.ctl, priv.script);
with_tty_dev:
close(priv.ctl.fd);