summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/dtable.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2008-09-11 04:34:24 +0000
committerChristopher Faylor <me@cgf.cx>2008-09-11 04:34:24 +0000
commit7b9e380f0362aad5dfa3e06e60fd6d06549e2306 (patch)
treee54df714b5bf5dfd99693408998bafcf33d567ff /winsup/cygwin/dtable.cc
parent0b840b0009b72fe7f4bb0eb8c185fdb779d560bd (diff)
downloadcygnal-7b9e380f0362aad5dfa3e06e60fd6d06549e2306.tar.gz
cygnal-7b9e380f0362aad5dfa3e06e60fd6d06549e2306.tar.bz2
cygnal-7b9e380f0362aad5dfa3e06e60fd6d06549e2306.zip
* 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/dtable.cc')
-rw-r--r--winsup/cygwin/dtable.cc203
1 files changed, 98 insertions, 105 deletions
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;
}