From ff866b95272c7ad39e34658b16495567c4befff4 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Wed, 30 Sep 2020 12:11:56 -0700 Subject: [PATCH] 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 e6763b4d0..b809dd733 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);