netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: akpm@osdl.org
To: davem@davemloft.net
Cc: jgarzik@pobox.com, netdev@oss.sgi.com, akpm@osdl.org,
	lcapitulino@conectiva.com.br
Subject: [patch 10/13] net/socket.c::sys_bind() cleanup.
Date: Sun, 21 Nov 2004 22:43:56 -0800	[thread overview]
Message-ID: <200411220644.iAM6i8900672@mail.osdl.org> (raw)


From: "Luiz Fernando N. Capitulino" <lcapitulino@conectiva.com.br>

net/socket.c::sys_bind() is a bit complex function, the patch below makes
it more clear.

Signed-off-by: Luiz Capitulino <lcapitulino@conectiva.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/net/socket.c |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)

diff -puN net/socket.c~net-socketcsys_bind-cleanup net/socket.c
--- 25/net/socket.c~net-socketcsys_bind-cleanup	2004-11-21 22:42:53.618530984 -0800
+++ 25-akpm/net/socket.c	2004-11-21 22:43:00.586471696 -0800
@@ -1286,18 +1286,23 @@ asmlinkage long sys_bind(int fd, struct 
 	char address[MAX_SOCK_ADDR];
 	int err;
 
-	if((sock = sockfd_lookup(fd,&err))!=NULL)
-	{
-		if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) {
-			err = security_socket_bind(sock, (struct sockaddr *)address, addrlen);
-			if (err) {
-				sockfd_put(sock);
-				return err;
-			}
-			err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
-		}
-		sockfd_put(sock);
-	}			
+	sock = sockfd_lookup(fd, &err);
+	if (!sock)
+		goto out;
+
+	err = move_addr_to_kernel(umyaddr, addrlen, address);
+	if (err)
+		goto out_put;
+
+	err = security_socket_bind(sock, (struct sockaddr *)address, addrlen);
+	if (err)
+		goto out_put;
+
+	err = sock->ops->bind(sock, (struct sockaddr *)address, addrlen);
+
+ out_put:
+	sockfd_put(sock);
+ out:
 	return err;
 }
 
_

             reply	other threads:[~2004-11-22  6:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-22  6:43 akpm [this message]
2004-11-24  8:27 ` [patch 10/13] net/socket.c::sys_bind() cleanup David S. Miller
2004-11-24 10:55   ` Luiz Fernando Capitulino
2004-11-24 22:03     ` David Stevens
2004-11-25 10:19       ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200411220644.iAM6i8900672@mail.osdl.org \
    --to=akpm@osdl.org \
    --cc=davem@davemloft.net \
    --cc=jgarzik@pobox.com \
    --cc=lcapitulino@conectiva.com.br \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).