diff options
-rw-r--r-- | apps/netutils/ftpc/ftpc_connect.c | 16 | ||||
-rw-r--r-- | nuttx/lib/stdio/lib_fgets.c | 5 |
2 files changed, 14 insertions, 7 deletions
diff --git a/apps/netutils/ftpc/ftpc_connect.c b/apps/netutils/ftpc/ftpc_connect.c index 3c9c460aa..3af6ef65f 100644 --- a/apps/netutils/ftpc/ftpc_connect.c +++ b/apps/netutils/ftpc/ftpc_connect.c @@ -95,21 +95,23 @@ SESSION ftpc_connect(FAR struct ftpc_connect_s *server) goto errout; } - /* Initialize the session structure */ + /* Initialize the session structure with all non-zero and variable values */ - ftpc_reset(session); - session->addr.s_addr = server->addr.s_addr; - session->pid = getpid(); + session->addr.s_addr = server->addr.s_addr; + session->flags = FTPC_FLAGS_INIT; + session->replytimeo = CONFIG_FTP_DEFTIMEO * CLOCKS_PER_SEC; + session->conntimeo = CONFIG_FTP_DEFTIMEO * CLOCKS_PER_SEC; + session->pid = getpid(); /* Use the default port if the user specified port number zero */ if (!server->port) { - session->port = HTONS(CONFIG_FTP_DEFPORT); + session->port = HTONS(CONFIG_FTP_DEFPORT); } else { - session->port = htons(server->port); + session->port = htons(server->port); } /* Create up a timer to prevent hangs */ @@ -124,6 +126,7 @@ SESSION ftpc_connect(FAR struct ftpc_connect_s *server) ndbg("ftpc_reconnect() failed: %d\n", errno); goto errout_with_alloc; } + return (SESSION)session; errout_with_alloc: @@ -182,6 +185,7 @@ int ftpc_reconnect(FAR struct ftpc_session_s *session) addr.sin_family = AF_INET; addr.sin_port = session->port; addr.sin_addr.s_addr = session->addr.s_addr; + ret = ftpc_sockconnect(&session->cmd, &addr); if (ret != OK) { diff --git a/nuttx/lib/stdio/lib_fgets.c b/nuttx/lib/stdio/lib_fgets.c index 3f72f0000..ce2aa9476 100644 --- a/nuttx/lib/stdio/lib_fgets.c +++ b/nuttx/lib/stdio/lib_fgets.c @@ -97,7 +97,10 @@ static const char g_erasetoeol[] = "\033[K"; static inline int _lib_rawgetc(int fd) { char buffer; - if (read(fd, &buffer, 1) < 1) + ssize_t nread; + + nread = read(fd, &buffer, 1); + if (nread < 1) { /* Return EOF if the end of file (0) or error (-1) occurs */ |