[PATCH:libFS 1/7] If EAGAIN == EWOULDBLOCK, only need to check errno for one of them

Alan Coopersmith alan.coopersmith at oracle.com
Tue Jan 7 16:02:21 PST 2014


Solaris <sys/errno.h> has:
 #define EWOULDBLOCK       EAGAIN
so checking (errno == EAGAIN || errno == EWOULDBLOCK) is overkill.

This leads cppcheck 1.62 to complain:
[FSlibInt.c:153] -> [FSlibInt.c:153]: (style) Same expression on both sides of '||'.
[FSlibInt.c:301] -> [FSlibInt.c:301]: (style) Same expression on both sides of '||'.
[FSlibInt.c:379] -> [FSlibInt.c:379]: (style) Same expression on both sides of '||'.
[FSlibInt.c:472] -> [FSlibInt.c:472]: (style) Same expression on both sides of '||'.

This quiets it, and reduces the number of calls Solaris Studio cc
generates to the __errno() function to get the thread-specific errno value.

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 src/FSlibInt.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/FSlibInt.c b/src/FSlibInt.c
index 0fabc96..cb53e44 100644
--- a/src/FSlibInt.c
+++ b/src/FSlibInt.c
@@ -66,11 +66,14 @@ static const char * _SysErrorMsg ( int n );
 
 /* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
  * systems are broken and return EWOULDBLOCK when they should return EAGAIN
+ *
+ * Solaris defines EWOULDBLOCK to be EAGAIN, so don't need to check twice
+ * for it.
  */
 #ifdef WIN32
 #define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK)
 #else
-#if defined(EAGAIN) && defined(EWOULDBLOCK)
+#if defined(EAGAIN) && defined(EWOULDBLOCK) && (EAGAIN != EWOULDBLOCK)
 #define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK)
 #else
 #ifdef EAGAIN
-- 
1.7.9.2



More information about the xorg-devel mailing list