From: Markus Elfring <elfr...@users.sourceforge.net>
Date: Tue, 7 Nov 2017 10:05:20 +0100

Add a jump target so that a bit of exception handling can be better reused
at the end of this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfr...@users.sourceforge.net>
---

v1 - Request for comments:
I can offer another bit of information for a software development discussion. ๐Ÿ’ญ

The affected source file can be compiled for the processor architecture โ€œx86_64โ€
by a tool like โ€œGCC 6.4.1+r251631-1.3โ€ from the software distribution
โ€œopenSUSE Tumbleweedโ€ with the following command example.

my_cc=/usr/bin/gcc-6 \
&& my_module=net/9p/trans_fd.o \
&& for XYZ in 0 s 3; do echo "   _____ $XYZ _____" \
&& my_extra="-O$XYZ" \
&& git checkout next-20171102 \
&& make -j4 CC="${my_cc}" HOSTCC="${my_cc}" EXTRA_CFLAGS="${my_extra}" 
allmodconfig "${my_module}" \
&& size "${my_module}" \
&& git checkout ':/^9p/trans_fd: Use common error handling code in 
p9_fd_create_tcp' \
&& make -j4 CC="${my_cc}" HOSTCC="${my_cc}" EXTRA_CFLAGS="${my_extra}" 
allmodconfig "${my_module}" \
&& size "${my_module}"; done


๐Ÿ”ฎ Do you find the following differences worth for further clarification?

โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•คโ•โ•โ•โ•โ•โ•โ•—
โ•‘ setting โ”‚ text โ•‘
โ• โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•ชโ•โ•โ•โ•โ•โ•โ•ฃ
โ•‘   O0    โ”‚ -14  โ•‘
โ•‘   Os    โ”‚ +13  โ•‘
โ•‘   O3    โ”‚  0   โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•งโ•โ•โ•โ•โ•โ•โ•


 net/9p/trans_fd.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
index 903a190319b9..161c2249ca2a 100644
--- a/net/9p/trans_fd.c
+++ b/net/9p/trans_fd.c
@@ -974,8 +974,7 @@ p9_fd_create_tcp(struct p9_client *client, const char 
*addr, char *args)
                if (err < 0) {
                        pr_err("%s (%d): problem binding to privport\n",
                               __func__, task_pid_nr(current));
-                       sock_release(csocket);
-                       return err;
+                       goto release_socket;
                }
        }
 
@@ -985,11 +984,14 @@ p9_fd_create_tcp(struct p9_client *client, const char 
*addr, char *args)
        if (err < 0) {
                pr_err("%s (%d): problem connecting socket to %s\n",
                       __func__, task_pid_nr(current), addr);
-               sock_release(csocket);
-               return err;
+               goto release_socket;
        }
 
        return p9_socket_open(client, csocket);
+
+release_socket:
+       sock_release(csocket);
+       return err;
 }
 
 static int
-- 
2.15.0

Reply via email to