* [PATCH 1/2] - net/socket.c::sys_bind() cleanup.
@ 2004-11-16 20:55 Luiz Fernando N. Capitulino
2004-11-17 0:52 ` Jesper Juhl
0 siblings, 1 reply; 4+ messages in thread
From: Luiz Fernando N. Capitulino @ 2004-11-16 20:55 UTC (permalink / raw)
To: linux-kernel; +Cc: akpm, davem
Hi,
net/socket.c::sys_bind() is a bit complex function, the patch
bellow makes it more clear.
Note that the code does the same thing, it only makes difference
for the programmer.
Agains't 2.6.10-rc2.
Signed-off-by: Luiz Capitulino <lcapitulino@conectiva.com.br>
net/socket.c | 29 +++++++++++++++++------------
1 files changed, 17 insertions(+), 12 deletions(-)
diff -X /home/lcapitulino/kernels/2.6/dontdiff -Nparu a/net/socket.c a~/net/socket.c
--- a/net/socket.c 2004-10-31 18:44:25.000000000 -0200
+++ a~/net/socket.c 2004-10-31 18:52:01.000000000 -0200
@@ -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;
}
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] - net/socket.c::sys_bind() cleanup.
2004-11-16 20:55 [PATCH 1/2] - net/socket.c::sys_bind() cleanup Luiz Fernando N. Capitulino
@ 2004-11-17 0:52 ` Jesper Juhl
2004-11-17 4:16 ` James Morris
0 siblings, 1 reply; 4+ messages in thread
From: Jesper Juhl @ 2004-11-17 0:52 UTC (permalink / raw)
To: Luiz Fernando N. Capitulino; +Cc: linux-kernel, akpm, davem
On Tue, 16 Nov 2004, Luiz Fernando N. Capitulino wrote:
>
> Hi,
>
> net/socket.c::sys_bind() is a bit complex function, the patch
> bellow makes it more clear.
>
> Note that the code does the same thing, it only makes difference
> for the programmer.
>
Not exactely :
> - if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) {
> + err = move_addr_to_kernel(umyaddr, addrlen, address);
> + if (err)
> + goto out_put;
The original tests for err >= 0, your replacement tests if err is != 0
--
Jesper Juhl
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] - net/socket.c::sys_bind() cleanup.
2004-11-17 0:52 ` Jesper Juhl
@ 2004-11-17 4:16 ` James Morris
2004-11-17 9:55 ` Jesper Juhl
0 siblings, 1 reply; 4+ messages in thread
From: James Morris @ 2004-11-17 4:16 UTC (permalink / raw)
To: Jesper Juhl; +Cc: Luiz Fernando N. Capitulino, linux-kernel, akpm, davem
On Wed, 17 Nov 2004, Jesper Juhl wrote:
> Not exactely :
>
>
> > - if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) {
>
> > + err = move_addr_to_kernel(umyaddr, addrlen, address);
> > + if (err)
> > + goto out_put;
>
>
> The original tests for err >= 0, your replacement tests if err is != 0
Look at move_addr_to_kernel(), it only returns 0 or -error.
The patch looks good to me.
- James
--
James Morris
<jmorris@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 1/2] - net/socket.c::sys_bind() cleanup.
2004-11-17 4:16 ` James Morris
@ 2004-11-17 9:55 ` Jesper Juhl
0 siblings, 0 replies; 4+ messages in thread
From: Jesper Juhl @ 2004-11-17 9:55 UTC (permalink / raw)
To: James Morris; +Cc: Luiz Fernando N. Capitulino, linux-kernel, akpm, davem
James Morris wrote:
> On Wed, 17 Nov 2004, Jesper Juhl wrote:
>
>
>>Not exactely :
>>
>>
>>
>>>- if((err=move_addr_to_kernel(umyaddr,addrlen,address))>=0) {
>>
>>>+ err = move_addr_to_kernel(umyaddr, addrlen, address);
>>>+ if (err)
>>>+ goto out_put;
>>
>>
>>The original tests for err >= 0, your replacement tests if err is != 0
>
>
> Look at move_addr_to_kernel(), it only returns 0 or -error.
>
> The patch looks good to me.
>
Right, I had not looked at it in detail. I just reacted to the claim
that "it does exactely the same" but I could see in the posted patch
that it didn't do exactely the same and there was no explanation of why
it was ok to have that difference.
After reading move_addr_to_kernel(), I agree that the patch looks fine.
--
Jesper Juhl
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-11-17 9:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-16 20:55 [PATCH 1/2] - net/socket.c::sys_bind() cleanup Luiz Fernando N. Capitulino
2004-11-17 0:52 ` Jesper Juhl
2004-11-17 4:16 ` James Morris
2004-11-17 9:55 ` Jesper Juhl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox