public inbox for cygwin-cvs@sourceware.org help / color / mirror / Atom feed
From: Ken Brown <kbrown@sourceware.org> To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: pipes: remove unnecessary NULL checks for hdl_cnt_mtx Date: Mon, 20 Sep 2021 19:10:44 +0000 (GMT) [thread overview] Message-ID: <20210920191044.87F9D3858439@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=643db9ec9e13724ff9cb7254bbfdc292463627a5 commit 643db9ec9e13724ff9cb7254bbfdc292463627a5 Author: Ken Brown <kbrown@cornell.edu> Date: Sat Sep 18 09:25:20 2021 -0400 Cygwin: pipes: remove unnecessary NULL checks for hdl_cnt_mtx In view of the previous changes to open_setup, we can always assume that hdl_cnt_mtx is non-NULL. Diff: --- winsup/cygwin/fhandler_pipe.cc | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/winsup/cygwin/fhandler_pipe.cc b/winsup/cygwin/fhandler_pipe.cc index 449e268ab..6b41a755f 100644 --- a/winsup/cygwin/fhandler_pipe.cc +++ b/winsup/cygwin/fhandler_pipe.cc @@ -415,12 +415,10 @@ fhandler_pipe::reader_closed () { if (!query_hdl) return false; - if (hdl_cnt_mtx) - WaitForSingleObject (hdl_cnt_mtx, INFINITE); + WaitForSingleObject (hdl_cnt_mtx, INFINITE); int n_reader = get_obj_handle_count (query_hdl); int n_writer = get_obj_handle_count (get_handle ()); - if (hdl_cnt_mtx) - ReleaseMutex (hdl_cnt_mtx); + ReleaseMutex (hdl_cnt_mtx); return n_reader == n_writer; } @@ -583,18 +581,14 @@ fhandler_pipe::set_close_on_exec (bool val) set_no_inheritance (select_sem, val); if (query_hdl) set_no_inheritance (query_hdl, val); - if (hdl_cnt_mtx) - set_no_inheritance (hdl_cnt_mtx, val); + set_no_inheritance (hdl_cnt_mtx, val); } void fhandler_pipe::fixup_after_fork (HANDLE parent) { - if (hdl_cnt_mtx) - { - fork_fixup (parent, hdl_cnt_mtx, "hdl_cnt_mtx"); - WaitForSingleObject (hdl_cnt_mtx, INFINITE); - } + fork_fixup (parent, hdl_cnt_mtx, "hdl_cnt_mtx"); + WaitForSingleObject (hdl_cnt_mtx, INFINITE); if (read_mtx) fork_fixup (parent, read_mtx, "read_mtx"); if (select_sem) @@ -603,8 +597,7 @@ fhandler_pipe::fixup_after_fork (HANDLE parent) fork_fixup (parent, query_hdl, "query_hdl"); fhandler_base::fixup_after_fork (parent); - if (hdl_cnt_mtx) - ReleaseMutex (hdl_cnt_mtx); + ReleaseMutex (hdl_cnt_mtx); } int @@ -614,8 +607,7 @@ fhandler_pipe::dup (fhandler_base *child, int flags) ftp->set_popen_pid (0); int res = 0; - if (hdl_cnt_mtx) - WaitForSingleObject (hdl_cnt_mtx, INFINITE); + WaitForSingleObject (hdl_cnt_mtx, INFINITE); if (fhandler_base::dup (child, flags)) res = -1; else if (read_mtx && @@ -645,8 +637,7 @@ fhandler_pipe::dup (fhandler_base *child, int flags) ftp->close (); res = -1; } - else if (hdl_cnt_mtx && - !DuplicateHandle (GetCurrentProcess (), hdl_cnt_mtx, + else if (!DuplicateHandle (GetCurrentProcess (), hdl_cnt_mtx, GetCurrentProcess (), &ftp->hdl_cnt_mtx, 0, !(flags & O_CLOEXEC), DUPLICATE_SAME_ACCESS)) { @@ -654,8 +645,7 @@ fhandler_pipe::dup (fhandler_base *child, int flags) ftp->close (); res = -1; } - if (hdl_cnt_mtx) - ReleaseMutex (hdl_cnt_mtx); + ReleaseMutex (hdl_cnt_mtx); debug_printf ("res %d", res); return res; @@ -671,16 +661,12 @@ fhandler_pipe::close () } if (read_mtx) CloseHandle (read_mtx); - if (hdl_cnt_mtx) - WaitForSingleObject (hdl_cnt_mtx, INFINITE); + WaitForSingleObject (hdl_cnt_mtx, INFINITE); if (query_hdl) CloseHandle (query_hdl); int ret = fhandler_base::close (); - if (hdl_cnt_mtx) - { - ReleaseMutex (hdl_cnt_mtx); - CloseHandle (hdl_cnt_mtx); - } + ReleaseMutex (hdl_cnt_mtx); + CloseHandle (hdl_cnt_mtx); return ret; }
reply other threads:[~2021-09-20 19:10 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210920191044.87F9D3858439@sourceware.org \ --to=kbrown@sourceware.org \ --cc=cygwin-cvs@sourceware.org \ /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: linkBe 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 read-only IMAP folder(s) and NNTP newsgroup(s).