This is the mail archive of the
cygwin-cvs@cygwin.com
mailing list for the Cygwin project.
[newlib-cygwin] Cygwin: AF_UNIX: drop try/except block in bind method
- From: Corinna Vinschen <corinna at sourceware dot org>
- To: cygwin-cvs at sourceware dot org
- Date: 5 Mar 2018 14:19:54 -0000
- Subject: [newlib-cygwin] Cygwin: AF_UNIX: drop try/except block in bind method
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=df14d97fff68fc9597b5769a3a077c73e38859d7
commit df14d97fff68fc9597b5769a3a077c73e38859d7
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Fri Mar 2 23:40:36 2018 +0100
Cygwin: AF_UNIX: drop try/except block in bind method
The caller already does it anyway.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diff:
---
winsup/cygwin/fhandler_socket_unix.cc | 48 +++++++++++++++--------------------
1 file changed, 21 insertions(+), 27 deletions(-)
diff --git a/winsup/cygwin/fhandler_socket_unix.cc b/winsup/cygwin/fhandler_socket_unix.cc
index 2a43900..36a3cb3 100644
--- a/winsup/cygwin/fhandler_socket_unix.cc
+++ b/winsup/cygwin/fhandler_socket_unix.cc
@@ -604,35 +604,29 @@ fhandler_socket_unix::socketpair (int af, int type, int protocol, int flags,
int
fhandler_socket_unix::bind (const struct sockaddr *name, int namelen)
{
- __try
- {
- sun_name_t sun (name, namelen);
- bool unnamed = (sun.un_len == sizeof sun.un.sun_family);
- HANDLE pipe = NULL;
+ sun_name_t sun (name, namelen);
+ bool unnamed = (sun.un_len == sizeof sun.un.sun_family);
+ HANDLE pipe = NULL;
- if (get_handle ())
- {
- set_errno (EINVAL);
- __leave;
- }
- gen_pipe_name ();
- pipe = create_pipe ();
- if (pipe)
- {
- file = unnamed ? autobind (&sun) : create_file (&sun);
- if (!file)
- {
- NtClose (pipe);
- __leave;
- }
- set_io_handle (pipe);
- set_sun_path (&sun);
- return 0;
- }
+ /* If we have a handle, we're already bound. */
+ if (get_handle () || sun.un.sun_family != AF_UNIX)
+ {
+ set_errno (EINVAL);
+ return -1;
}
- __except (EFAULT) {}
- __endtry
- return -1;
+ gen_pipe_name ();
+ pipe = create_pipe ();
+ if (!pipe)
+ return -1;
+ file = unnamed ? autobind (&sun) : create_file (&sun);
+ if (!file)
+ {
+ NtClose (pipe);
+ return -1;
+ }
+ set_io_handle (pipe);
+ set_sun_path (&sun);
+ return 0;
}
int