You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/09/30 20:09:31 UTC
[incubator-nuttx-apps] 03/03: fsutils:ipcfg Fix fd propagation as
return value in bin mode
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit ff866b95272c7ad39e34658b16495567c4befff4
Author: David Sidrane <Da...@NscDg.com>
AuthorDate: Wed Sep 30 12:11:56 2020 -0700
fsutils:ipcfg Fix fd propagation as return value in bin mode
With CONFIG_IPCFG_BINARY lit. ipcfg_open needs to return
the fd or an -errno. It was returning OK not the fd.
---
fsutils/ipcfg/ipcfg.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/fsutils/ipcfg/ipcfg.c b/fsutils/ipcfg/ipcfg.c
index e6763b4..b809dd7 100644
--- a/fsutils/ipcfg/ipcfg.c
+++ b/fsutils/ipcfg/ipcfg.c
@@ -201,8 +201,6 @@ static int ipcfg_open(FAR const char *netdev, int oflags, mode_t mode)
/* Now open the file */
fd = open(path, oflags, mode);
- ret = OK;
-
if (fd < 0)
{
ret = -errno;
@@ -220,11 +218,14 @@ static int ipcfg_open(FAR const char *netdev, int oflags, mode_t mode)
if (ret < 0)
{
ret = -errno;
+ close(fd);
fprintf(stderr, "ERROR: Failed to seek to $ld: %d\n",
(long)CONFIG_IPCFG_OFFSET, ret);
- close(fd);
+ goto errout_with_path;
}
+
#endif
+ ret = fd;
errout_with_path:
free(path);