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

Jasper St. Pierre jstpierre at mecheye.net
Tue Jan 7 21:39:47 PST 2014


Reviewed-by: Jasper St. Pierre <jstpierre at mecheye.net>


On Tue, Jan 7, 2014 at 7:02 PM, Alan Coopersmith <
alan.coopersmith at oracle.com> wrote:

> 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
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
>



-- 
  Jasper
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg-devel/attachments/20140108/6d185970/attachment.html>


More information about the xorg-devel mailing list