[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-users] errno is not set in sockets.c
From: |
Mason |
Subject: |
[lwip-users] errno is not set in sockets.c |
Date: |
Tue, 20 Mar 2012 10:53:54 +0100 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:10.0.2) Gecko/20120216 Firefox/10.0.2 SeaMonkey/2.7.2 |
Hello,
I am porting libcurl on top of lwip on a POSIX platform.
(libcurl uses the BSD sockets API, and non-blocking sockets.)
Calling connect on a non-blocking socket is supposed to
return EINPROGRESS in errno, but in my port, errno is
not set.
Looking at sockets.c, the relevant code is:
#ifdef ERRNO
#ifndef set_errno
#define set_errno(err) errno = (err)
#endif
#else /* ERRNO */
#define set_errno(err)
#endif /* ERRNO */
#define sock_set_errno(sk, e) do { \
sk->err = (e); \
set_errno(sk->err); \
} while (0)
If ERRNO is undefined, set_errno is a NOP, thus errno is never set.
What is the semantics / meaning of the ERRNO macro?
It is only checked in sockets.c
(and it is not set in my platform's system headers)
$ grep -rn "[^_]ERRNO" src
src/api/sockets.c:161:#ifdef ERRNO
src/api/sockets.c:165:#else /* ERRNO */
src/api/sockets.c:167:#endif /* ERRNO */
The unix port leaves ERRNO undefined, which means errno is never
set in the unix port (?!)
I'm familiar with the LWIP_PROVIDE_ERRNO macro, which I did NOT
define because I've included my platform's errno.h in cc.h
I propose deleting this ERRNO stuff:
--- sockets.c.orig 2012-02-23 10:57:12.796875000 +0100
+++ sockets.c 2012-03-20 10:50:40.375000000 +0100
@@ -158,13 +158,9 @@
((unsigned)(-(err)) < ERR_TO_ERRNO_TABLE_SIZE ? \
err_to_errno_table[-(err)] : EIO)
-#ifdef ERRNO
#ifndef set_errno
#define set_errno(err) errno = (err)
#endif
-#else /* ERRNO */
-#define set_errno(err)
-#endif /* ERRNO */
#define sock_set_errno(sk, e) do { \
sk->err = (e); \
(If someone wants his port to leave errno intact, they should
define set_errno to a NOP in his port's cc.h)
Did I miss something obvious, or something not so obvious?
--
Regards.
- [lwip-users] errno is not set in sockets.c,
Mason <=