You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/09/01 06:58:15 UTC

[incubator-nuttx-apps] 01/06: examples/usrsocktest: correct return value check of dup2()

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git

commit a8d2924c55f349bb733c6b43ec4559665680e27e
Author: chao an <an...@xiaomi.com>
AuthorDate: Wed Aug 31 22:48:45 2022 +0800

    examples/usrsocktest: correct return value check of dup2()
    
    DUP(2) Linux Programmer's Manual
    
    NAME
           dup, dup2, dup3 - duplicate a file descriptor
    ...
    RETURN VALUE
           On success, these system calls return the new file descriptor.
           On error, -1 is returned, and errno is set appropriately.
    
    Signed-off-by: chao an <an...@xiaomi.com>
---
 examples/usrsocktest/usrsocktest_basic_daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/usrsocktest/usrsocktest_basic_daemon.c b/examples/usrsocktest/usrsocktest_basic_daemon.c
index 80021ba40..6387f7722 100644
--- a/examples/usrsocktest/usrsocktest_basic_daemon.c
+++ b/examples/usrsocktest/usrsocktest_basic_daemon.c
@@ -333,7 +333,7 @@ static void basic_daemon_dup2(FAR struct usrsocktest_daemon_conf_s *dconf)
   TEST_ASSERT_EQUAL(2, usrsocktest_daemon_get_num_active_sockets());
 
   ret = dup2(sd2, sd);
-  TEST_ASSERT_EQUAL(0, ret);
+  TEST_ASSERT_EQUAL(sd, ret);
   TEST_ASSERT_EQUAL(1, usrsocktest_daemon_get_num_active_sockets());
 
   ret = close(sd2);