[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha7-1699-gf9d00fb

Volker Lendecke vlendec at samba.org
Tue May 19 21:35:51 GMT 2009


The branch, master has been updated
       via  f9d00fb58e8e9fed24751ad26dbdbc394f30290e (commit)
      from  cf9636ea99bb5063a8c7d771c1e29f684b4b753a (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit f9d00fb58e8e9fed24751ad26dbdbc394f30290e
Author: Volker Lendecke <vl at samba.org>
Date:   Tue May 19 23:31:55 2009 +0200

    Simplify the logic of tsocket_bsd_pending
    
    Remove two indentation levels by returning early on error.
    
    Metze, please check!

-----------------------------------------------------------------------

Summary of changes:
 lib/tsocket/tsocket_bsd.c |   50 +++++++++++++++++++++++---------------------
 1 files changed, 26 insertions(+), 24 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c
index 0ec47f8..054bb3d 100644
--- a/lib/tsocket/tsocket_bsd.c
+++ b/lib/tsocket/tsocket_bsd.c
@@ -149,40 +149,42 @@ static int tsocket_bsd_common_prepare_fd(int fd, bool high_fd)
 
 static ssize_t tsocket_bsd_pending(int fd)
 {
-	int ret;
+	int ret, error;
 	int value = 0;
+	socklen_t len;
 
 	ret = ioctl(fd, FIONREAD, &value);
 	if (ret == -1) {
 		return ret;
 	}
 
-	if (ret == 0) {
-		if (value == 0) {
-			int error=0;
-			socklen_t len = sizeof(error);
-			/*
-			 * if no data is available check if the socket
-			 * is in error state. For dgram sockets
-			 * it's the way to return ICMP error messages
-			 * of connected sockets to the caller.
-			 */
-			ret = getsockopt(fd, SOL_SOCKET, SO_ERROR,
-					 &error, &len);
-			if (ret == -1) {
-				return ret;
-			}
-			if (error != 0) {
-				errno = error;
-				return -1;
-			}
-		}
+	if (ret != 0) {
+		/* this should not be reached */
+		errno = EIO;
+		return -1;
+	}
+
+	if (value != 0) {
 		return value;
 	}
 
-	/* this should not be reached */
-	errno = EIO;
-	return -1;
+	error = 0;
+	len = sizeof(error);
+
+	/*
+	 * if no data is available check if the socket is in error state. For
+	 * dgram sockets it's the way to return ICMP error messages of
+	 * connected sockets to the caller.
+	 */
+	ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len);
+	if (ret == -1) {
+		return ret;
+	}
+	if (error != 0) {
+		errno = error;
+		return -1;
+	}
+	return 0;
 }
 
 static const struct tsocket_address_ops tsocket_address_bsd_ops;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list