lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-devel] [bug #35928] BSD sockets functions must set errno for P


From: Mason
Subject: Re: [lwip-devel] [bug #35928] BSD sockets functions must set errno for POSIX-compliance
Date: Tue, 27 Mar 2012 16:31:52 +0200
User-agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20120312 Firefox/11.0 SeaMonkey/2.8

Mason wrote:

> Could you please comment on the last patch? (where I propose
> renaming ERRNO to LWIP_SOCKET_SET_ERRNO, and documenting the
> macro in src/include/lwip/opt.h)
> 
> https://savannah.nongnu.org/bugs/download.php?file_id=25430

For reference, I'm talking about doing the following.
(The comment in opt.h would provide some documentation,
and would prevent people from stumbling on the same
problem I had.)

diff --git a/src/api/sockets.c b/src/api/sockets.c
--- a/src/api/sockets.c
+++ b/src/api/sockets.c
@@ -158,13 +158,13 @@ static const int err_to_errno_table[] = {
   ((unsigned)(-(err)) < ERR_TO_ERRNO_TABLE_SIZE ? \
     err_to_errno_table[-(err)] : EIO)
 
-#ifdef ERRNO
+#if LWIP_SOCKET_SET_ERRNO
 #ifndef set_errno
 #define set_errno(err) errno = (err)
 #endif
-#else /* ERRNO */
+#else /* LWIP_SOCKET_SET_ERRNO */
 #define set_errno(err)
-#endif /* ERRNO */
+#endif /* LWIP_SOCKET_SET_ERRNO */
 
 #define sock_set_errno(sk, e) do { \
   sk->err = (e); \

diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h
--- a/src/include/lwip/opt.h
+++ b/src/include/lwip/opt.h
@@ -1427,6 +1427,15 @@
 #endif
 
 /**
+ * LWIP_SOCKET_SET_ERRNO==1: Set errno when socket functions cannot complete
+ * successfully, as required by POSIX. Default is not POSIX-compliant.
+ * (only used if you use sockets.c)
+ */
+#ifndef LWIP_SOCKET_SET_ERRNO
+#define LWIP_SOCKET_SET_ERRNO           0
+#endif
+
+/**
  * LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names.
  * (only used if you use sockets.c)
  */

-- 
Regards.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]