diff options
author | Christopher Faylor <me@cgf.cx> | 2008-09-11 08:34:24 +0400 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2008-09-11 08:34:24 +0400 |
commit | 7b9e380f0362aad5dfa3e06e60fd6d06549e2306 (patch) | |
tree | e54df714b5bf5dfd99693408998bafcf33d567ff /winsup/cygwin | |
parent | 0b840b0009b72fe7f4bb0eb8c185fdb779d560bd (diff) |
* cygheap.cc (creturn): Reorganize to avoid a new compiler warning/error.
* dtable.cc (handle_to_fn): Ditto.
* fhandler_console.cc (fhandler_console::read): Ditto.
(fhandler_console::scroll_screen): Ditto.
(dev_console::set_color): Ditto.
* fhandler_dsp.cc (fhandler_dev_dsp::write): Ditto.
(fhandler_dev_dsp::read): Ditto.
* fhandler_tape.cc (mtinfo_drive::get_status): Ditto.
* hookapi.cc (find_first_notloaded_dll): Ditto.
* mmap.cc (msync): Ditto.
* pipe.cc (pipesync::pipesync): Ditto.
* sec_acl.cc (getace): Ditto.
* sec_auth.cc (create_token): Ditto.
(lsaauth): Ditto.
* select.cc (peek_pipe): Ditto.
* spawn.cc (av::fixup): Ditto.
* syscalls.cc (popen): Ditto.
* tty.cc (tty::init_session): Ditto.
* uinfo.cc (pwdgrp::load): Ditto.
* fhandler.cc (fhandler_base::setup_overlapped): Ditto.
(fhandler_base::wait_overlapped): Rename second use of res variable to wres or
errors are not returned correctly.
* dcrt0.cc: Remove obsolete variable.
* dll_init.cc (release_upto): Fix typo involving incorrect use of '|'.
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Avoid a compiler
warning regarding coercing type-punned variables.
(fhandler_base::fstat_by_name): Ditto. fhandler_fifo.cc
(fhandler_fifo::open_nonserver): Fix = vs. == typo.
(fhandler_fifo::wait): Add all conditions to switch statement to avoid a
compiler warning.
* fhandler_process.cc: Avoid unneeded initialization of variables to zero.
(fhandler_socket::listen): Add braces around initializer.
* flock.cc (inode_t::get_all_locks_list): Reorganize to avoid a compiler
warning. Fix problem with EWOULDBLOCK error return.
* path.cc (GUID_shortcut): Use braces around struct initializer.
(cygwin_conv_path): Reorganize to avoid a compiler warning.
* random.cc (dummy): Mark variable as volatile to avoid a "used uninitialized"
warning.
* libc/getopt.c: Mark some variables as dllexport although gcc doesn't seem to
do the right thing with them.
* libc/minires-os-if.c (get_registry_dns_items): Coerce some function arguments
to avoid a compiler warning.
Diffstat (limited to 'winsup/cygwin')
29 files changed, 359 insertions, 302 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 72f6bbb6a..5876813f3 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,50 @@ +2008-09-11 Christopher Faylor <me+cygwin@cgf.cx> + + * cygheap.cc (creturn): Reorganize to avoid a new compiler + warning/error. + * dtable.cc (handle_to_fn): Ditto. + * fhandler_console.cc (fhandler_console::read): Ditto. + (fhandler_console::scroll_screen): Ditto. + (dev_console::set_color): Ditto. + * fhandler_dsp.cc (fhandler_dev_dsp::write): Ditto. + (fhandler_dev_dsp::read): Ditto. + * fhandler_tape.cc (mtinfo_drive::get_status): Ditto. + * hookapi.cc (find_first_notloaded_dll): Ditto. + * mmap.cc (msync): Ditto. + * pipe.cc (pipesync::pipesync): Ditto. + * sec_acl.cc (getace): Ditto. + * sec_auth.cc (create_token): Ditto. + (lsaauth): Ditto. + * select.cc (peek_pipe): Ditto. + * spawn.cc (av::fixup): Ditto. + * syscalls.cc (popen): Ditto. + * tty.cc (tty::init_session): Ditto. + * uinfo.cc (pwdgrp::load): Ditto. + * fhandler.cc (fhandler_base::setup_overlapped): Ditto. + (fhandler_base::wait_overlapped): Rename second use of res variable to + wres or errors are not returned correctly. + * dcrt0.cc: Remove obsolete variable. + * dll_init.cc (release_upto): Fix typo involving incorrect use of '|'. + * fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Avoid a + compiler warning regarding coercing type-punned variables. + (fhandler_base::fstat_by_name): Ditto. fhandler_fifo.cc + (fhandler_fifo::open_nonserver): Fix = vs. == typo. + (fhandler_fifo::wait): Add all conditions to switch statement to avoid + a compiler warning. + * fhandler_process.cc: Avoid unneeded initialization of variables to + zero. + (fhandler_socket::listen): Add braces around initializer. + * flock.cc (inode_t::get_all_locks_list): Reorganize to avoid a + compiler warning. Fix problem with EWOULDBLOCK error return. + * path.cc (GUID_shortcut): Use braces around struct initializer. + (cygwin_conv_path): Reorganize to avoid a compiler warning. + * random.cc (dummy): Mark variable as volatile to avoid a "used + uninitialized" warning. + * libc/getopt.c: Mark some variables as dllexport although gcc doesn't + seem to do the right thing with them. + * libc/minires-os-if.c (get_registry_dns_items): Coerce some function + arguments to avoid a compiler warning. + 2008-08-27 Christopher Faylor <me+cygwin@cgf.cx> * fhandler_tty.cc (close_maybe): Check for both types of invalid handle diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc index b3d8d6d0a..635480adc 100644 --- a/winsup/cygwin/cygheap.cc +++ b/winsup/cygwin/cygheap.cc @@ -244,14 +244,15 @@ _crealloc (void *ptr, unsigned size) inline static void * creturn (cygheap_types x, cygheap_entry * c, unsigned len, const char *fn = NULL) { - if (!c) - if (fn) - api_fatal ("%s would have returned NULL", fn); - else - { - set_errno (ENOMEM); - return NULL; - } + if (c) + /* nothing to do */; + else if (fn) + api_fatal ("%s would have returned NULL", fn); + else + { + set_errno (ENOMEM); + return NULL; + } c->type = x; char *cend = ((char *) c + sizeof (*c) + len); if (cygheap_max < cend) diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index dbdc61e2c..63d1bd2e5 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -104,9 +104,6 @@ extern "C" }; bool ignore_case_with_glob; int __declspec (dllexport) _check_for_executable = true; -#ifdef DEBUGGING - int pinger; -#endif }; int NO_COPY __api_fatal_exit_val = 1; diff --git a/winsup/cygwin/debug.h b/winsup/cygwin/debug.h index e09208cf0..b2333e6fd 100644 --- a/winsup/cygwin/debug.h +++ b/winsup/cygwin/debug.h @@ -79,7 +79,6 @@ void __stdcall modify_handle (const char *, int, HANDLE, const char *, bool) __attribute__ ((regparm (3))); void setclexec (HANDLE, HANDLE, bool); void debug_fixup_after_fork_exec (); -extern int pinger; struct handle_list { diff --git a/winsup/cygwin/dll_init.cc b/winsup/cygwin/dll_init.cc index 1a91e6687..acd767d2e 100644 --- a/winsup/cygwin/dll_init.cc +++ b/winsup/cygwin/dll_init.cc @@ -269,7 +269,7 @@ release_upto (const PWCHAR name, DWORD here) (((void *) start < cygheap->user_heap.base || (void *) start > cygheap->user_heap.top) && ((void *) start < (void *) cygheap - | (void *) start > (void *) ((char *) cygheap + CYGHEAPSIZE))))) + || (void *) start > (void *) ((char *) cygheap + CYGHEAPSIZE))))) continue; if (!VirtualFree ((void *) start, 0, MEM_RELEASE)) api_fatal ("couldn't release memory %p(%d) for '%W' alignment, %E\n", diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc index 7f997d479..cca215671 100644 --- a/winsup/cygwin/dtable.cc +++ b/winsup/cygwin/dtable.cc @@ -853,124 +853,117 @@ handle_to_fn (HANDLE h, char *posix_fn) NtQueryObject (h, ObjectNameInformation, &dummy_oni, sizeof (dummy_oni), &len); if (!len) + debug_printf ("NtQueryObject failed 1"); + else { - debug_printf ("NtQueryObject failed 1"); - goto unknown; - } - - OBJECT_NAME_INFORMATION *ntfn = (OBJECT_NAME_INFORMATION *) alloca (len + sizeof (WCHAR)); - NTSTATUS res = NtQueryObject (h, ObjectNameInformation, ntfn, len, NULL); + OBJECT_NAME_INFORMATION *ntfn = (OBJECT_NAME_INFORMATION *) alloca (len + sizeof (WCHAR)); + NTSTATUS res = NtQueryObject (h, ObjectNameInformation, ntfn, len, NULL); - if (!NT_SUCCESS (res)) - { - debug_printf ("NtQueryObject failed 2"); - goto unknown; - } + if (!NT_SUCCESS (res)) + debug_printf ("NtQueryObject failed 2"); + // NT seems to do this on an unopened file + else if (!ntfn->Name.Buffer) + debug_printf ("nt->Name.Buffer == NULL"); + else + { + WCHAR *w32 = ntfn->Name.Buffer; + size_t w32len = ntfn->Name.Length / sizeof (WCHAR); + w32[w32len] = L'\0'; - // NT seems to do this on an unopened file - if (!ntfn->Name.Buffer) - { - debug_printf ("nt->Name.Buffer == NULL"); - goto unknown; - } + if (wcscasecmp (w32, DEV_NULL) == 0) + { + strcpy (posix_fn, "/dev/null"); + return false; + } - WCHAR *w32 = ntfn->Name.Buffer; - size_t w32len = ntfn->Name.Length / sizeof (WCHAR); - w32[w32len] = L'\0'; + if (wcsncasecmp (w32, DEV_NAMED_PIPE, DEV_NAMED_PIPE_LEN) == 0) + { + w32 += DEV_NAMED_PIPE_LEN; + if (wcsncmp (w32, L"cygwin-", WCLEN (L"cygwin-")) != 0) + return false; + w32 += WCLEN (L"cygwin-"); + bool istty = wcsncmp (w32, L"tty", WCLEN (L"tty")) == 0; + if (istty) + decode_tty (posix_fn, w32 + WCLEN (L"tty")); + else if (wcsncmp (w32, L"pipe", WCLEN (L"pipe")) == 0) + strcpy (posix_fn, "/dev/pipe"); + return istty; + } - if (wcscasecmp (w32, DEV_NULL) == 0) - { - strcpy (posix_fn, "/dev/null"); - return false; - } - if (wcsncasecmp (w32, DEV_NAMED_PIPE, DEV_NAMED_PIPE_LEN) == 0) - { - w32 += DEV_NAMED_PIPE_LEN; - if (wcsncmp (w32, L"cygwin-", WCLEN (L"cygwin-")) != 0) - return false; - w32 += WCLEN (L"cygwin-"); - bool istty = wcsncmp (w32, L"tty", WCLEN (L"tty")) == 0; - if (istty) - decode_tty (posix_fn, w32 + WCLEN (L"tty")); - else if (wcsncmp (w32, L"pipe", WCLEN (L"pipe")) == 0) - strcpy (posix_fn, "/dev/pipe"); - return istty; - } + WCHAR fnbuf[64 * 1024]; + if (wcsncasecmp (w32, DEVICE_PREFIX, DEVICE_PREFIX_LEN) != 0 + || !QueryDosDeviceW (NULL, fnbuf, sizeof (fnbuf))) + { + sys_wcstombs (posix_fn, NT_MAX_PATH, w32, w32len); + return false; + } + for (WCHAR *s = fnbuf; *s; s = wcschr (s, '\0') + 1) + { + WCHAR device[NT_MAX_PATH]; + if (!QueryDosDeviceW (s, device, sizeof (device))) + continue; + if (wcschr (s, ':') == NULL) + continue; + WCHAR *q = wcsrchr (device, ';'); + if (q) + { + WCHAR *r = wcschr (q, '\\'); + if (r) + wcscpy (q, r + 1); + } + int devlen = wcslen (device); + if (device[devlen - 1] == L'\\') + device[--devlen] = L'\0'; + if (devlen < maxmatchlen) + continue; + if (wcsncmp (device, w32, devlen) != 0|| + (w32[devlen] != L'\0' && w32[devlen] != L'\\')) + continue; + maxmatchlen = devlen; + maxmatchdos = s; + debug_printf ("current match '%W' = '%W'\n", s, device); + } - WCHAR fnbuf[64 * 1024]; - if (wcsncasecmp (w32, DEVICE_PREFIX, DEVICE_PREFIX_LEN) != 0 - || !QueryDosDeviceW (NULL, fnbuf, sizeof (fnbuf))) - { - sys_wcstombs (posix_fn, NT_MAX_PATH, w32, w32len); - return false; - } + if (maxmatchlen) + { + WCHAR *p = wcschr (w32 + DEVICE_PREFIX_LEN, L'\\'); + size_t n = wcslen (maxmatchdos); + WCHAR ch; + if (!p) + ch = L'\0'; + else + { + if (maxmatchdos[n - 1] == L'\\') + n--; + w32 += maxmatchlen - n; + ch = L'\\'; + } + memcpy (w32, maxmatchdos, n * sizeof (WCHAR)); + w32[n] = ch; + } + else if (wcsncmp (w32, DEV_REMOTE, DEV_REMOTE_LEN) == 0) + { + w32 += DEV_REMOTE_LEN - 2; + *w32 = L'\\'; + debug_printf ("remote drive"); + } + else if (wcsncmp (w32, DEV_REMOTE1, DEV_REMOTE1_LEN) == 0) + { + w32 += DEV_REMOTE1_LEN - 2; + *w32 = L'\\'; + debug_printf ("remote drive"); + } - for (WCHAR *s = fnbuf; *s; s = wcschr (s, '\0') + 1) - { - WCHAR device[NT_MAX_PATH]; - if (!QueryDosDeviceW (s, device, sizeof (device))) - continue; - if (wcschr (s, ':') == NULL) - continue; - WCHAR *q = wcsrchr (device, ';'); - if (q) - { - WCHAR *r = wcschr (q, '\\'); - if (r) - wcscpy (q, r + 1); - } - int devlen = wcslen (device); - if (device[devlen - 1] == L'\\') - device[--devlen] = L'\0'; - if (devlen < maxmatchlen) - continue; - if (wcsncmp (device, w32, devlen) != 0|| - (w32[devlen] != L'\0' && w32[devlen] != L'\\')) - continue; - maxmatchlen = devlen; - maxmatchdos = s; - debug_printf ("current match '%W' = '%W'\n", s, device); - } + cygwin_conv_path (CCP_WIN_W_TO_POSIX | CCP_ABSOLUTE, w32, posix_fn, + NT_MAX_PATH); - if (maxmatchlen) - { - WCHAR *p = wcschr (w32 + DEVICE_PREFIX_LEN, L'\\'); - size_t n = wcslen (maxmatchdos); - WCHAR ch; - if (!p) - ch = L'\0'; - else - { - if (maxmatchdos[n - 1] == L'\\') - n--; - w32 += maxmatchlen - n; - ch = L'\\'; + debug_printf ("derived path '%W', posix '%s'", w32, posix_fn); + return false; } - memcpy (w32, maxmatchdos, n * sizeof (WCHAR)); - w32[n] = ch; - } - else if (wcsncmp (w32, DEV_REMOTE, DEV_REMOTE_LEN) == 0) - { - w32 += DEV_REMOTE_LEN - 2; - *w32 = L'\\'; - debug_printf ("remote drive"); } - else if (wcsncmp (w32, DEV_REMOTE1, DEV_REMOTE1_LEN) == 0) - { - w32 += DEV_REMOTE1_LEN - 2; - *w32 = L'\\'; - debug_printf ("remote drive"); - } - - cygwin_conv_path (CCP_WIN_W_TO_POSIX | CCP_ABSOLUTE, w32, posix_fn, - NT_MAX_PATH); - - debug_printf ("derived path '%W', posix '%s'", w32, posix_fn); - return false; -unknown: strcpy (posix_fn, unknown_file); return false; } diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index a6eec3f4a..d96b1971b 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -1665,7 +1665,7 @@ fhandler_base::setup_overlapped () { OVERLAPPED *ov = get_overlapped (); memset (ov, 0, sizeof (*ov)); - return ov->hEvent = CreateEvent (&sec_none_nih, true, false, NULL); + return (ov->hEvent = CreateEvent (&sec_none_nih, true, false, NULL)); } void @@ -1707,9 +1707,9 @@ fhandler_base::wait_overlapped (bool inres, bool writing, DWORD *bytes) if (&_my_tls == _main_tls) w4[n++] = signal_arrived; HANDLE h = writing ? get_output_handle () : get_handle (); - DWORD res = WaitForMultipleObjects (n, w4, false, INFINITE); + DWORD wres = WaitForMultipleObjects (n, w4, false, INFINITE); err = 0; - switch (res) + switch (wres) { case WAIT_OBJECT_0: debug_printf ("normal read"); diff --git a/winsup/cygwin/fhandler_console.cc b/winsup/cygwin/fhandler_console.cc index 076e2338c..11cf70639 100644 --- a/winsup/cygwin/fhandler_console.cc +++ b/winsup/cygwin/fhandler_console.cc @@ -261,7 +261,7 @@ fhandler_console::read (void *pv, size_t& buflen) /* allow manual switching to/from raw mode via ctrl-alt-scrolllock */ if (input_rec.Event.KeyEvent.bKeyDown && virtual_key_code == VK_SCROLL && - control_key_state & (LEFT_ALT_PRESSED | LEFT_CTRL_PRESSED) == LEFT_ALT_PRESSED | LEFT_CTRL_PRESSED + ((control_key_state & (LEFT_ALT_PRESSED | LEFT_CTRL_PRESSED)) == (LEFT_ALT_PRESSED | LEFT_CTRL_PRESSED)) ) { set_raw_win32_keyboard_mode (!dev_state->raw_win32_keyboard_mode); @@ -568,11 +568,12 @@ fhandler_console::scroll_screen (int x1, int y1, int x2, int y2, int xn, int yn) /* ScrollConsoleScreenBuffer on Windows 95 is buggy - when scroll distance * is more than half of screen, filling doesn't work as expected */ - if (sr1.Top != sr1.Bottom) - if (dest.Y <= sr1.Top) /* forward scroll */ - clear_screen (0, 1 + dest.Y + sr1.Bottom - sr1.Top, sr2.Right, sr2.Bottom); - else /* reverse scroll */ - clear_screen (0, sr1.Top, sr2.Right, dest.Y - 1); + if (sr1.Top == sr1.Bottom) + /* nothing to do */; + else if (dest.Y <= sr1.Top) /* forward scroll */ + clear_screen (0, 1 + dest.Y + sr1.Bottom - sr1.Top, sr2.Right, sr2.Bottom); + else /* reverse scroll */ + clear_screen (0, sr1.Top, sr2.Right, dest.Y - 1); } int @@ -895,12 +896,13 @@ dev_console::set_color (HANDLE h) win_bg |= BACKGROUND_INTENSITY; if (intensity == INTENSITY_INVISIBLE) win_fg = win_bg; - else if (intensity == INTENSITY_BOLD) + else if (intensity != INTENSITY_BOLD) + /* nothing to do */; /* apply foreground intensity only in non-reverse mode! */ - if (reverse) - win_bg |= BACKGROUND_INTENSITY; - else - win_fg |= FOREGROUND_INTENSITY; + else if (reverse) + win_bg |= BACKGROUND_INTENSITY; + else + win_fg |= FOREGROUND_INTENSITY; current_win32_attr = win_fg | win_bg; if (h) diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index cbfa36a48..aa945f588 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -350,11 +350,11 @@ fhandler_base::fstat_by_handle (struct __stat64 *buf) pc.file_attributes (fai_buf.fai.BasicInformation.FileAttributes); return fstat_helper (buf, fai_buf.fai.BasicInformation.ChangeTime.QuadPart - ? *(FILETIME *) &fai_buf.fai.BasicInformation.ChangeTime - : *(FILETIME *) &fai_buf.fai.BasicInformation.LastWriteTime, - *(FILETIME *) &fai_buf.fai.BasicInformation.LastAccessTime, - *(FILETIME *) &fai_buf.fai.BasicInformation.LastWriteTime, - *(FILETIME *) &fai_buf.fai.BasicInformation.CreationTime, + ? *(FILETIME *) (void *) &fai_buf.fai.BasicInformation.ChangeTime + : *(FILETIME *) (void *) &fai_buf.fai.BasicInformation.LastWriteTime, + *(FILETIME *) (void *) &fai_buf.fai.BasicInformation.LastAccessTime, + *(FILETIME *) (void *) &fai_buf.fai.BasicInformation.LastWriteTime, + *(FILETIME *) (void *) &fai_buf.fai.BasicInformation.CreationTime, get_dev (), fai_buf.fai.StandardInformation.EndOfFile.QuadPart, fai_buf.fai.StandardInformation.AllocationSize.QuadPart, @@ -417,11 +417,11 @@ fhandler_base::fstat_by_name (struct __stat64 *buf) pc.file_attributes (fdi_buf.fdi.FileAttributes); return fstat_helper (buf, fdi_buf.fdi.ChangeTime.QuadPart ? - *(FILETIME *) &fdi_buf.fdi.ChangeTime : - *(FILETIME *) &fdi_buf.fdi.LastWriteTime, - *(FILETIME *) &fdi_buf.fdi.LastAccessTime, - *(FILETIME *) &fdi_buf.fdi.LastWriteTime, - *(FILETIME *) &fdi_buf.fdi.CreationTime, + *(FILETIME *) (void *) &fdi_buf.fdi.ChangeTime : + *(FILETIME *) (void *) &fdi_buf.fdi.LastWriteTime, + *(FILETIME *) (void *) &fdi_buf.fdi.LastAccessTime, + *(FILETIME *) (void *) &fdi_buf.fdi.LastWriteTime, + *(FILETIME *) (void *) &fdi_buf.fdi.CreationTime, pc.fs_serial_number (), fdi_buf.fdi.EndOfFile.QuadPart, fdi_buf.fdi.AllocationSize.QuadPart, @@ -434,10 +434,10 @@ too_bad: /* Arbitrary value: 2006-12-01 */ RtlSecondsSince1970ToTime (1164931200L, &ft); return fstat_helper (buf, - *(FILETIME *) &ft, - *(FILETIME *) &ft, - *(FILETIME *) &ft, - *(FILETIME *) &ft, + *(FILETIME *) (void *) &ft, + *(FILETIME *) (void *) &ft, + *(FILETIME *) (void *) &ft, + *(FILETIME *) (void *) &ft, 0, 0ULL, -1LL, diff --git a/winsup/cygwin/fhandler_dsp.cc b/winsup/cygwin/fhandler_dsp.cc index ed5ddad8a..1927a9b28 100644 --- a/winsup/cygwin/fhandler_dsp.cc +++ b/winsup/cygwin/fhandler_dsp.cc @@ -1007,24 +1007,25 @@ fhandler_dev_dsp::write (const void *ptr, size_t len) int len_s = len; const char *ptr_s = static_cast <const char *> (ptr); - if (!audio_out_) - if (IS_WRITE ()) - { - debug_printf ("Allocating"); - if (!(audio_out_ = new Audio_out)) - return -1; + if (audio_out_) + /* nothing to do */; + else if (IS_WRITE ()) + { + debug_printf ("Allocating"); + if (!(audio_out_ = new Audio_out)) + return -1; - /* check for wave file & get parameters & skip header if possible. */ + /* check for wave file & get parameters & skip header if possible. */ - if (audio_out_->parsewav (ptr_s, len_s, - audiofreq_, audiobits_, audiochannels_)) - debug_printf ("=> ptr_s=%08x len_s=%d", ptr_s, len_s); - } - else - { - set_errno (EBADF); // device was opened for read? - return -1; - } + if (audio_out_->parsewav (ptr_s, len_s, + audiofreq_, audiobits_, audiochannels_)) + debug_printf ("=> ptr_s=%08x len_s=%d", ptr_s, len_s); + } + else + { + set_errno (EBADF); // device was opened for read? + return -1; + } /* Open audio device properly with callbacks. Private parameters were set in call to parsewav. @@ -1046,23 +1047,24 @@ fhandler_dev_dsp::read (void *ptr, size_t& len) if ((fhandler_dev_dsp *) archetype != this) return ((fhandler_dev_dsp *)archetype)->read(ptr, len); - if (!audio_in_) - if (IS_READ ()) - { - debug_printf ("Allocating"); - if (!(audio_in_ = new Audio_in)) - { - len = (size_t)-1; - return; - } - audio_in_->setconvert (audioformat_); - } - else - { - len = (size_t)-1; - set_errno (EBADF); // device was opened for write? - return; - } + if (audio_in_) + /* nothing to do */; + else if (IS_READ ()) + { + debug_printf ("Allocating"); + if (!(audio_in_ = new Audio_in)) + { + len = (size_t)-1; + return; + } + audio_in_->setconvert (audioformat_); + } + else + { + len = (size_t)-1; + set_errno (EBADF); // device was opened for write? + return; + } /* Open audio device properly with callbacks. This is a noop when there are successive reads in the same process */ diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc index a97d949ee..00b8f2a50 100644 --- a/winsup/cygwin/fhandler_fifo.cc +++ b/winsup/cygwin/fhandler_fifo.cc @@ -34,7 +34,7 @@ fhandler_fifo::open_nonserver (const char *npname, unsigned low_flags, DWORD mode = 0; if (low_flags == O_RDONLY) mode = GENERIC_READ; - else if (low_flags = O_WRONLY) + else if (low_flags == O_WRONLY) mode = GENERIC_WRITE; else mode = GENERIC_READ | GENERIC_WRITE; @@ -131,11 +131,16 @@ fhandler_fifo::wait (bool iswrite) switch (wait_state) { case fifo_wait_for_client: - bool res = ConnectNamedPipe (get_handle (), get_overlapped ()); - DWORD dummy_bytes; - if (res || GetLastError () == ERROR_PIPE_CONNECTED) - return true; - return wait_overlapped (res, iswrite, &dummy_bytes); + { + bool res = ConnectNamedPipe (get_handle (), get_overlapped ()); + DWORD dummy_bytes; + if (res || GetLastError () == ERROR_PIPE_CONNECTED) + return true; + return wait_overlapped (res, iswrite, &dummy_bytes); + } + case fifo_unknown: + case fifo_wait_for_server: + /* CGF FIXME SOON: test if these really need to be handled. */ default: break; } diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc index 0f0adc059..25dfbea80 100644 --- a/winsup/cygwin/fhandler_process.cc +++ b/winsup/cygwin/fhandler_process.cc @@ -931,7 +931,7 @@ get_mem_values (DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss, { ++*vmrss; unsigned flags = mwsl->WorkingSetList[i] & 0x0FFF; - if (flags & (WSLE_PAGE_EXECUTE | WSLE_PAGE_SHAREABLE) == (WSLE_PAGE_EXECUTE | WSLE_PAGE_SHAREABLE)) + if ((flags & (WSLE_PAGE_EXECUTE | WSLE_PAGE_SHAREABLE)) == (WSLE_PAGE_EXECUTE | WSLE_PAGE_SHAREABLE)) ++*vmlib; else if (flags & WSLE_PAGE_SHAREABLE) ++*vmshare; diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index 1ab5170ea..13770386d 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -408,9 +408,9 @@ fhandler_socket::af_local_set_secret (char *buf) #define LOCK_EVENTS WaitForSingleObject (wsock_mtx, INFINITE) #define UNLOCK_EVENTS ReleaseMutex (wsock_mtx) -static wsa_event wsa_events[NUM_SOCKS] __attribute__((section (".cygwin_dll_common"), shared)) = { 0 }; +static wsa_event wsa_events[NUM_SOCKS] __attribute__((section (".cygwin_dll_common"), shared)); -static LONG socket_serial_number __attribute__((section (".cygwin_dll_common"), shared)) = 0; +static LONG socket_serial_number __attribute__((section (".cygwin_dll_common"), shared)); static HANDLE wsa_slot_mtx; @@ -1091,7 +1091,7 @@ fhandler_socket::listen (int backlog) sin6_family: AF_INET6, sin6_port: 0, sin6_flowinfo: 0, - sin6_addr: IN6ADDR_ANY_INIT, + sin6_addr: {{IN6ADDR_ANY_INIT}}, sin6_scope_id: 0 }; if (!::bind (get_socket (), (struct sockaddr *) &sin6, sizeof sin6)) diff --git a/winsup/cygwin/fhandler_tape.cc b/winsup/cygwin/fhandler_tape.cc index 593d26cf0..57f918557 100644 --- a/winsup/cygwin/fhandler_tape.cc +++ b/winsup/cygwin/fhandler_tape.cc @@ -801,11 +801,12 @@ mtinfo_drive::get_status (HANDLE mt, struct mtget *get) get->mt_fileno = part (partition)->file; get->mt_blkno = part (partition)->fblock; - if (get->mt_blkno == 0) - if (get->mt_fileno == 0) - get->mt_gstat |= GMT_BOT (-1); - else - get->mt_gstat |= GMT_EOF (-1); + if (get->mt_blkno != 0) + /* nothing to do */; + else if (get->mt_fileno == 0) + get->mt_gstat |= GMT_BOT (-1); + else + get->mt_gstat |= GMT_EOF (-1); if (part (partition)->emark >= eod_hit) get->mt_gstat |= GMT_EOD (-1); if (part (partition)->emark >= eom_hit) diff --git a/winsup/cygwin/flock.cc b/winsup/cygwin/flock.cc index b2ca288d9..b69a30460 100644 --- a/winsup/cygwin/flock.cc +++ b/winsup/cygwin/flock.cc @@ -497,10 +497,10 @@ inode_t::get_all_locks_list () wc[LOCK_OBJ_NAME_LEN] = L'\0'; short flags = wcstol (wc, &endptr, 16); if ((flags & ~(F_FLOCK | F_POSIX)) != 0 - || (flags & (F_FLOCK | F_POSIX) == (F_FLOCK | F_POSIX))) + || ((flags & (F_FLOCK | F_POSIX)) == (F_FLOCK | F_POSIX))) continue; short type = wcstol (endptr + 1, &endptr, 16); - if (type != F_RDLCK && type != F_WRLCK || !endptr || *endptr != L'-') + if (type != (F_RDLCK && type != F_WRLCK) || !endptr || *endptr != L'-') continue; _off64_t start = (_off64_t) wcstoull (endptr + 1, &endptr, 16); if (start < 0 || !endptr || *endptr != L'-') @@ -1442,7 +1442,7 @@ flock (int fd, int operation) goto done; } res = cfd->lock (cmd, &fl); - if (res == -1 && (get_errno () == EAGAIN) || (get_errno () == EACCES)) + if ((res == -1) && ((get_errno () == EAGAIN) || (get_errno () == EACCES))) set_errno (EWOULDBLOCK); done: syscall_printf ("%d = flock (%d, %d)", res, fd, operation); diff --git a/winsup/cygwin/hookapi.cc b/winsup/cygwin/hookapi.cc index 07101982c..7a13ee047 100644 --- a/winsup/cygwin/hookapi.cc +++ b/winsup/cygwin/hookapi.cc @@ -191,29 +191,29 @@ find_first_notloaded_dll (path_conv& pc) PIMAGE_NT_HEADERS pExeNTHdr; pExeNTHdr = PEHeaderFromHModule (hm); - if (!pExeNTHdr) - goto out; - - DWORD importRVA; - importRVA = pExeNTHdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress; - if (!importRVA) - goto out; - - long delta = rvadelta (pExeNTHdr, importRVA); - - // Convert imports RVA to a usable pointer - PIMAGE_IMPORT_DESCRIPTOR pdfirst; - pdfirst = rva (PIMAGE_IMPORT_DESCRIPTOR, hm, importRVA - delta); - - // Iterate through each import descriptor, and redirect if appropriate - for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++) + if (pExeNTHdr) { - const char *lib = rva (PSTR, hm, pd->Name - delta); - if (!LoadLibraryEx (lib, NULL, DONT_RESOLVE_DLL_REFERENCES - | LOAD_LIBRARY_AS_DATAFILE)) + DWORD importRVA; + importRVA = pExeNTHdr->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress; + if (importRVA) { - static char buf[NT_MAX_PATH]; - res = strcpy (buf, lib); + long delta = rvadelta (pExeNTHdr, importRVA); + + // Convert imports RVA to a usable pointer + PIMAGE_IMPORT_DESCRIPTOR pdfirst; + pdfirst = rva (PIMAGE_IMPORT_DESCRIPTOR, hm, importRVA - delta); + + // Iterate through each import descriptor, and redirect if appropriate + for (PIMAGE_IMPORT_DESCRIPTOR pd = pdfirst; pd->FirstThunk; pd++) + { + const char *lib = rva (PSTR, hm, pd->Name - delta); + if (!LoadLibraryEx (lib, NULL, DONT_RESOLVE_DLL_REFERENCES + | LOAD_LIBRARY_AS_DATAFILE)) + { + static char buf[NT_MAX_PATH]; + res = strcpy (buf, lib); + } + } } } diff --git a/winsup/cygwin/libc/getopt.c b/winsup/cygwin/libc/getopt.c index bbd1f37dd..dc9bd8981 100644 --- a/winsup/cygwin/libc/getopt.c +++ b/winsup/cygwin/libc/getopt.c @@ -58,11 +58,11 @@ #define REPLACE_GETOPT /* use this getopt as the system getopt(3) */ #ifdef REPLACE_GETOPT -int opterr = 1; /* if error message should be printed */ -int optind = 1; /* index into parent argv vector */ -int optopt = '?'; /* character checked for validity */ -int optreset; /* reset getopt */ -char *optarg; /* argument associated with option */ +int __declspec(dllexport) opterr = 1; /* if error message should be printed */ +int __declspec(dllexport) optind = 1; /* index into parent argv vector */ +int __declspec(dllexport) optopt = '?';/* index into parent argv vector *//* character checked for validity */ +int __declspec(dllexport) optreset; /* reset getopt */ +char __declspec(dllexport) *optarg; /* argument associated with option */ #endif #define PRINT_ERROR ((opterr) && (*options != ':')) diff --git a/winsup/cygwin/libc/minires-os-if.c b/winsup/cygwin/libc/minires-os-if.c index 7e9009f91..1908ccf62 100644 --- a/winsup/cygwin/libc/minires-os-if.c +++ b/winsup/cygwin/libc/minires-os-if.c @@ -325,7 +325,7 @@ static void get_registry_dns_items(HKEY hKey, LPCTSTR KeyValue, *srch++ = 0; if (numAddresses < DIM(statp->nsaddr_list)) { DPRINTF(debug, "server \"%s\"\n", ap); - statp->nsaddr_list[numAddresses].sin_addr.s_addr = cygwin_inet_addr(ap); + statp->nsaddr_list[numAddresses].sin_addr.s_addr = cygwin_inet_addr((char *) ap); if ( statp->nsaddr_list[numAddresses].sin_addr.s_addr != 0 ) numAddresses++; } @@ -335,7 +335,7 @@ static void get_registry_dns_items(HKEY hKey, LPCTSTR KeyValue, statp->nscount = numAddresses; } else /* Parse the search line */ - minires_get_search(list, statp); + minires_get_search((char *) list, statp); } return; } diff --git a/winsup/cygwin/mmap.cc b/winsup/cygwin/mmap.cc index 9b0440425..4616410ec 100644 --- a/winsup/cygwin/mmap.cc +++ b/winsup/cygwin/mmap.cc @@ -1130,7 +1130,7 @@ msync (void *addr, size_t len, int flags) if (((uintptr_t) addr % getpagesize ()) || (flags & ~(MS_ASYNC | MS_SYNC | MS_INVALIDATE)) - || (flags & (MS_ASYNC | MS_SYNC) == (MS_ASYNC | MS_SYNC))) + || ((flags & (MS_ASYNC | MS_SYNC)) == (MS_ASYNC | MS_SYNC))) { set_errno (EINVAL); goto out; diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 8441ed4d0..b70e0a290 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -104,7 +104,7 @@ struct symlink_info muto NO_COPY cwdstuff::cwd_lock; static const GUID GUID_shortcut - = { 0x00021401L, 0, 0, 0xc0, 0, 0, 0, 0, 0, 0, 0x46 }; + = { 0x00021401L, 0, 0, {0xc0, 0, 0, 0, 0, 0, 0, 0x46}}; enum { WSH_FLAG_IDLIST = 0x01, /* Contains an ITEMIDLIST. */ @@ -2775,22 +2775,24 @@ cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to, switch (what) { case CCP_POSIX_TO_WIN_A: - p.check ((const char *) from, - PC_POSIX | PC_SYM_FOLLOW | PC_NO_ACCESS_CHECK | PC_NOWARN - | (relative ? PC_NOFULL : 0)); - if (p.error) - return_with_errno (p.error); - PUNICODE_STRING up = p.get_nt_native_path (); - buf = tp.c_get (); - sys_wcstombs (buf, NT_MAX_PATH, up->Buffer, up->Length / sizeof (WCHAR)); - /* Convert native path to standard DOS path. */ - if (!strncmp (buf, "\\??\\", 4)) - { - buf += 4; - if (buf[1] != ':') /* native UNC path */ - *(buf += 2) = '\\'; - } - lsiz = strlen (buf) + 1; + { + p.check ((const char *) from, + PC_POSIX | PC_SYM_FOLLOW | PC_NO_ACCESS_CHECK | PC_NOWARN + | (relative ? PC_NOFULL : 0)); + if (p.error) + return_with_errno (p.error); + PUNICODE_STRING up = p.get_nt_native_path (); + buf = tp.c_get (); + sys_wcstombs (buf, NT_MAX_PATH, up->Buffer, up->Length / sizeof (WCHAR)); + /* Convert native path to standard DOS path. */ + if (!strncmp (buf, "\\??\\", 4)) + { + buf += 4; + if (buf[1] != ':') /* native UNC path */ + *(buf += 2) = '\\'; + } + lsiz = strlen (buf) + 1; + } break; case CCP_POSIX_TO_WIN_W: p.check ((const char *) from, diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc index bcc3bcbd3..303f0616f 100644 --- a/winsup/cygwin/pipe.cc +++ b/winsup/cygwin/pipe.cc @@ -116,29 +116,29 @@ pipesync::pipesync (HANDLE f, DWORD is_reader): { ev = CreateEvent (&sec_none_nih, true, false, NULL); if (!ev) + system_printf ("couldn't create synchronization event for non-cygwin pipe, %E"); + else { - system_printf ("couldn't create synchronization event for non-cygwin pipe, %E"); - goto out; - } - debug_printf ("created thread synchronization event %p", ev); - non_cygwin_h = f; - reader = !!is_reader; - ret_handle = NULL; + debug_printf ("created thread synchronization event %p", ev); + non_cygwin_h = f; + reader = !!is_reader; + ret_handle = NULL; - DWORD tid; - HANDLE ht = CreateThread (&sec_none_nih, 0, pipe_handler, this, 0, &tid); + DWORD tid; + HANDLE ht = CreateThread (&sec_none_nih, 0, pipe_handler, this, 0, &tid); - if (!ht) - goto out; - CloseHandle (ht); + if (!ht) + goto out; + CloseHandle (ht); - switch (WaitForSingleObject (ev, INFINITE)) - { - case WAIT_OBJECT_0: - break; - default: - system_printf ("WFSO failed waiting for synchronization event for non-cygwin pipe, %E"); - break; + switch (WaitForSingleObject (ev, INFINITE)) + { + case WAIT_OBJECT_0: + break; + default: + system_printf ("WFSO failed waiting for synchronization event for non-cygwin pipe, %E"); + break; + } } out: diff --git a/winsup/cygwin/random.cc b/winsup/cygwin/random.cc index 037990880..fe1ac08fd 100644 --- a/winsup/cygwin/random.cc +++ b/winsup/cygwin/random.cc @@ -280,7 +280,7 @@ srandom(unsigned x) /* Avoid a compiler warning when we really want to get at the junk in an uninitialized variable. */ static unsigned long -dummy (unsigned long *x) +dummy (unsigned volatile long *x) { return *x; } diff --git a/winsup/cygwin/sec_acl.cc b/winsup/cygwin/sec_acl.cc index 318a34ff5..efee4e6e8 100644 --- a/winsup/cygwin/sec_acl.cc +++ b/winsup/cygwin/sec_acl.cc @@ -238,22 +238,28 @@ getace (__aclent32_t &acl, int type, int id, DWORD win_ace_mask, acl.a_id = id; if ((win_ace_mask & FILE_READ_BITS) && !(acl.a_perm & (S_IROTH | DENY_R))) - if (win_ace_type == ACCESS_ALLOWED_ACE_TYPE) - acl.a_perm |= S_IROTH; - else if (win_ace_type == ACCESS_DENIED_ACE_TYPE) - acl.a_perm |= DENY_R; + { + if (win_ace_type == ACCESS_ALLOWED_ACE_TYPE) + acl.a_perm |= S_IROTH; + else if (win_ace_type == ACCESS_DENIED_ACE_TYPE) + acl.a_perm |= DENY_R; + } if ((win_ace_mask & FILE_WRITE_BITS) && !(acl.a_perm & (S_IWOTH | DENY_W))) - if (win_ace_type == ACCESS_ALLOWED_ACE_TYPE) - acl.a_perm |= S_IWOTH; - else if (win_ace_type == ACCESS_DENIED_ACE_TYPE) - acl.a_perm |= DENY_W; + { + if (win_ace_type == ACCESS_ALLOWED_ACE_TYPE) + acl.a_perm |= S_IWOTH; + else if (win_ace_type == ACCESS_DENIED_ACE_TYPE) + acl.a_perm |= DENY_W; + } if ((win_ace_mask & FILE_EXEC_BITS) && !(acl.a_perm & (S_IXOTH | DENY_X))) - if (win_ace_type == ACCESS_ALLOWED_ACE_TYPE) - acl.a_perm |= S_IXOTH; - else if (win_ace_type == ACCESS_DENIED_ACE_TYPE) - acl.a_perm |= DENY_X; + { + if (win_ace_type == ACCESS_ALLOWED_ACE_TYPE) + acl.a_perm |= S_IXOTH; + else if (win_ace_type == ACCESS_DENIED_ACE_TYPE) + acl.a_perm |= DENY_X; + } } int diff --git a/winsup/cygwin/sec_auth.cc b/winsup/cygwin/sec_auth.cc index 504345573..3f7a082b2 100644 --- a/winsup/cygwin/sec_auth.cc +++ b/winsup/cygwin/sec_auth.cc @@ -798,13 +798,14 @@ create_token (cygsid &usersid, user_groups &new_groups, struct passwd *pw) { /* Switching user context to SYSTEM doesn't inherit the authentication id of the user account running current process. */ - if (usersid != well_known_system_sid) - if (!GetTokenInformation (hProcToken, TokenStatistics, - &stats, sizeof stats, &size)) - debug_printf - ("GetTokenInformation(hProcToken, TokenStatistics), %E"); - else - auth_luid = stats.AuthenticationId; + if (usersid == well_known_system_sid) + /* nothing to do */; + else if (!GetTokenInformation (hProcToken, TokenStatistics, + &stats, sizeof stats, &size)) + debug_printf + ("GetTokenInformation(hProcToken, TokenStatistics), %E"); + else + auth_luid = stats.AuthenticationId; /* Retrieving current processes group list to be able to inherit some important well known group sids. */ @@ -1103,8 +1104,10 @@ lsaauth (cygsid &usersid, user_groups &new_groups, struct passwd *pw) authinf->checksum = CYGWIN_VERSION_MAGIC (CYGWIN_VERSION_DLL_MAJOR, CYGWIN_VERSION_DLL_MINOR); - PDWORD csp = (PDWORD) &authinf->username; - PDWORD csp_end = (PDWORD) ((PBYTE) authinf + authinf_size); + PDWORD csp; + PDWORD csp_end; + csp = (PDWORD) &authinf->username; + csp_end = (PDWORD) ((PBYTE) authinf + authinf_size); while (csp < csp_end) authinf->checksum += *csp++; diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index 6be10ec27..48c6eeb3a 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -506,7 +506,7 @@ out: fh->get_name ()); else { -#if 1 +#if 0 /* FIXME: This code is not quite correct. There's no better solution so far but to make simple assumptions based on WriteQuotaAvailable. */ @@ -531,7 +531,7 @@ out: that. This means that a pipe could still block since you could be trying to write more to the pipe than is available in the buffer but that is the hazard of select(). */ - else if (fpli.WriteQuotaAvailable = (fpli.OutboundQuota - fpli.ReadDataAvailable)) + else if ((fpli.WriteQuotaAvailable = (fpli.OutboundQuota - fpli.ReadDataAvailable))) { select_printf ("%s, ready for write: size %lu, avail %lu", fh->get_name (), diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index f98ab6be9..b5edcaa2d 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -974,7 +974,7 @@ av::fixup (const char *prog_arg, path_conv& real_path, const char *ext) { const char *p; bool exeext = ascii_strcasematch (ext, ".exe"); - if (exeext && real_path.iscygexec () || ascii_strcasematch (ext, ".bat")) + if ((exeext && real_path.iscygexec ()) || ascii_strcasematch (ext, ".bat")) return 0; if (!*ext && ((p = ext - 4) > real_path.get_win32 ()) && (ascii_strcasematch (p, ".bat") || ascii_strcasematch (p, ".cmd") diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 7801ea2b3..1bbf570e3 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -3517,14 +3517,13 @@ popen (const char *command, const char *in_type) fcntl64 (stdwhat, F_SETFD, state); } - if (pid < 0) - goto err; - close (other_fd); - - fhandler_pipe *fh = (fhandler_pipe *) cygheap->fdtab[fd]; - fh->set_popen_pid (pid); - - return fp; + if (pid >= 0) + { + close (other_fd); + fhandler_pipe *fh = (fhandler_pipe *) cygheap->fdtab[fd]; + fh->set_popen_pid (pid); + return fp; + } err: int save_errno = get_errno (); diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc index 6021e3a9f..6341eb11c 100644 --- a/winsup/cygwin/tty.cc +++ b/winsup/cygwin/tty.cc @@ -81,11 +81,12 @@ tty::init_session () if (NOTSTATE (myself, PID_USETTY)) return; - if (myself->ctty == -1) - if (NOTSTATE (myself, PID_CYGPARENT)) - myself->ctty = cygwin_shared->tty.attach (myself->ctty); - else - return; + if (myself->ctty != -1) + /* nothing to do */; + else if (NOTSTATE (myself, PID_CYGPARENT)) + myself->ctty = cygwin_shared->tty.attach (myself->ctty); + else + return; if (myself->ctty == -1) termios_printf ("Can't attach to tty"); } diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 9d7a5cef0..f9ed1a686 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -577,8 +577,7 @@ pwdgrp::load (const wchar_t *rel_path) goto out; } buf[fsi.EndOfFile.LowPart] = '\0'; - char *eptr = buf; - while ((eptr = add_line (eptr))) + for (char *eptr = buf; (eptr = add_line (eptr)); ) continue; debug_printf ("%W curr_lines %d", rel_path, curr_lines); res = succeeded; |