Remove extraneous whitespace.

* pinfo.cc (commune_process): Use default argument to lock_process.
* sigproc.cc: Update copyright.
* select.cc: Ditto.
This commit is contained in:
Christopher Faylor 2007-02-20 00:16:18 +00:00
parent b440e09025
commit 510a85cbf9
18 changed files with 166 additions and 162 deletions

View File

@ -1,3 +1,10 @@
2007-02-19 Christopher Faylor <me@cgf.cx>
Remove extraneous whitespace.
* pinfo.cc (commune_process): Use default argument to lock_process.
* sigproc.cc: Update copyright.
* select.cc: Ditto.
2007-02-15 Corinna Vinschen <corinna@vinschen.de> 2007-02-15 Corinna Vinschen <corinna@vinschen.de>
* posix_ipc.cc (mq_open): Avoid compiler warning. Initialize mqhdr * posix_ipc.cc (mq_open): Avoid compiler warning. Initialize mqhdr

View File

@ -528,7 +528,7 @@ _cygtls::handle_exceptions (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT
case STATUS_ACCESS_VIOLATION: case STATUS_ACCESS_VIOLATION:
switch (mmap_is_attached_or_noreserve ((void *)e->ExceptionInformation[1], switch (mmap_is_attached_or_noreserve ((void *)e->ExceptionInformation[1],
1)) 1))
{ {
case MMAP_NORESERVE_COMMITED: case MMAP_NORESERVE_COMMITED:
return 0; return 0;
case MMAP_RAISE_SIGBUS: /* MAP_NORESERVE page, commit failed, or case MMAP_RAISE_SIGBUS: /* MAP_NORESERVE page, commit failed, or

View File

@ -690,7 +690,7 @@ fhandler_base::open (int flags, mode_t mode)
Per MSDN you have to create the file with the same attributes as Per MSDN you have to create the file with the same attributes as
already specified for the file. */ already specified for the file. */
if (has_attribute (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM)) if (has_attribute (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_SYSTEM))
file_attributes |= pc.file_attributes (); file_attributes |= pc.file_attributes ();
/* If the file should actually be created and ntsec is on, /* If the file should actually be created and ntsec is on,
set files attributes. */ set files attributes. */
@ -1292,7 +1292,7 @@ rootdir (const char *full_path, char *root_path)
} }
} }
while (--c > min_c && *c != '\\') while (--c > min_c && *c != '\\')
; ;
} }
return root_path; return root_path;
@ -1826,12 +1826,12 @@ fhandler_base::fpathconf (int v)
? LINK_MAX : 1; ? LINK_MAX : 1;
case _PC_MAX_CANON: case _PC_MAX_CANON:
if (is_tty ()) if (is_tty ())
return MAX_CANON; return MAX_CANON;
set_errno (EINVAL); set_errno (EINVAL);
break; break;
case _PC_MAX_INPUT: case _PC_MAX_INPUT:
if (is_tty ()) if (is_tty ())
return MAX_INPUT; return MAX_INPUT;
set_errno (EINVAL); set_errno (EINVAL);
break; break;
case _PC_NAME_MAX: case _PC_NAME_MAX:
@ -1844,7 +1844,7 @@ fhandler_base::fpathconf (int v)
if (pc.isdir () if (pc.isdir ()
|| get_device () == FH_FIFO || get_device () == FH_PIPE || get_device () == FH_FIFO || get_device () == FH_PIPE
|| get_device () == FH_PIPER || get_device () == FH_PIPEW) || get_device () == FH_PIPER || get_device () == FH_PIPEW)
return PIPE_BUF; return PIPE_BUF;
set_errno (EINVAL); set_errno (EINVAL);
break; break;
case _PC_CHOWN_RESTRICTED: case _PC_CHOWN_RESTRICTED:
@ -1853,7 +1853,7 @@ fhandler_base::fpathconf (int v)
return 1; return 1;
case _PC_VDISABLE: case _PC_VDISABLE:
if (is_tty ()) if (is_tty ())
return _POSIX_VDISABLE; return _POSIX_VDISABLE;
set_errno (EINVAL); set_errno (EINVAL);
break; break;
case _PC_ASYNC_IO: case _PC_ASYNC_IO:
@ -1870,7 +1870,7 @@ fhandler_base::fpathconf (int v)
case _PC_POSIX_PERMISSIONS: case _PC_POSIX_PERMISSIONS:
case _PC_POSIX_SECURITY: case _PC_POSIX_SECURITY:
if (get_device () == FH_FS) if (get_device () == FH_FS)
return check_posix_perm (get_win32_name (), v); return check_posix_perm (get_win32_name (), v);
set_errno (EINVAL); set_errno (EINVAL);
break; break;
default: default:

View File

@ -400,7 +400,7 @@ fhandler_console::read (void *pv, size_t& buflen)
toadd = tmp + 1; toadd = tmp + 1;
else if (dev_state->metabit) else if (dev_state->metabit)
{ {
tmp[1] |= 0x80; tmp[1] |= 0x80;
toadd = tmp + 1; toadd = tmp + 1;
} }
else else
@ -959,7 +959,7 @@ dev_console::set_color (HANDLE h)
win_fg = win_bg; win_fg = win_bg;
else if (intensity == INTENSITY_BOLD) else if (intensity == INTENSITY_BOLD)
/* apply foreground intensity only in non-reverse mode! */ /* apply foreground intensity only in non-reverse mode! */
if (reverse) if (reverse)
win_bg |= BACKGROUND_INTENSITY; win_bg |= BACKGROUND_INTENSITY;
else else
win_fg |= FOREGROUND_INTENSITY; win_fg |= FOREGROUND_INTENSITY;

View File

@ -809,7 +809,7 @@ fhandler_disk_file::fadvise (_off64_t offset, _off64_t length, int advice)
{ {
fmi.Mode &= ~FILE_SEQUENTIAL_ONLY; fmi.Mode &= ~FILE_SEQUENTIAL_ONLY;
if (advice == POSIX_FADV_SEQUENTIAL) if (advice == POSIX_FADV_SEQUENTIAL)
fmi.Mode |= FILE_SEQUENTIAL_ONLY; fmi.Mode |= FILE_SEQUENTIAL_ONLY;
status = NtSetInformationFile (get_handle (), &io, &fmi, sizeof fmi, status = NtSetInformationFile (get_handle (), &io, &fmi, sizeof fmi,
FileModeInformation); FileModeInformation);
if (NT_SUCCESS (status)) if (NT_SUCCESS (status))
@ -839,12 +839,12 @@ fhandler_disk_file::ftruncate (_off64_t length, bool allow_truncate)
actual_length += ((_off64_t) size_high) << 32; actual_length += ((_off64_t) size_high) << 32;
/* If called through posix_fallocate, silently succeed if length /* If called through posix_fallocate, silently succeed if length
is less than the file's actual length. */ is less than the file's actual length. */
if (!allow_truncate && length < actual_length) if (!allow_truncate && length < actual_length)
return 0; return 0;
if (wincap.is_winnt ()) if (wincap.is_winnt ())
{ {
NTSTATUS status; NTSTATUS status;
IO_STATUS_BLOCK io; IO_STATUS_BLOCK io;
FILE_END_OF_FILE_INFORMATION feofi; FILE_END_OF_FILE_INFORMATION feofi;
@ -872,7 +872,7 @@ fhandler_disk_file::ftruncate (_off64_t length, bool allow_truncate)
res = 0; res = 0;
} }
else else
{ {
_off64_t prev_loc = lseek (0, SEEK_CUR); _off64_t prev_loc = lseek (0, SEEK_CUR);
if (lseek (length, SEEK_SET) >= 0) if (lseek (length, SEEK_SET) >= 0)
{ {
@ -1468,7 +1468,7 @@ fhandler_disk_file::rmdir ()
{ {
rc = !(err = unlink_nt (pc, pc.has_attribute (FILE_ATTRIBUTE_READONLY))); rc = !(err = unlink_nt (pc, pc.has_attribute (FILE_ATTRIBUTE_READONLY)));
if (err) if (err)
SetLastError (err); SetLastError (err);
} }
else else
rc = RemoveDirectory (get_win32_name ()); rc = RemoveDirectory (get_win32_name ());
@ -1599,7 +1599,7 @@ fhandler_disk_file::opendir ()
SECURITY_ATTRIBUTES sa = sec_none; SECURITY_ATTRIBUTES sa = sec_none;
pc.get_nt_native_path (upath); pc.get_nt_native_path (upath);
InitializeObjectAttributes (&attr, &upath, InitializeObjectAttributes (&attr, &upath,
OBJ_CASE_INSENSITIVE | OBJ_INHERIT, OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
NULL, sa.lpSecurityDescriptor); NULL, sa.lpSecurityDescriptor);
status = NtOpenFile (&dir->__handle, status = NtOpenFile (&dir->__handle,
SYNCHRONIZE | FILE_LIST_DIRECTORY, SYNCHRONIZE | FILE_LIST_DIRECTORY,
@ -1793,7 +1793,7 @@ fhandler_disk_file::readdir (DIR *dir, dirent *de)
mode using FileBothDirectoryInformation. So, what we do here is mode using FileBothDirectoryInformation. So, what we do here is
to implement the solution suggested by Andrew Tridgell, we just to implement the solution suggested by Andrew Tridgell, we just
reread all entries up to dir->d_position using reread all entries up to dir->d_position using
FileBothDirectoryInformation. FileBothDirectoryInformation.
However, We do *not* mark this server as broken and fall back to However, We do *not* mark this server as broken and fall back to
using FileBothDirectoryInformation further on. This would slow using FileBothDirectoryInformation further on. This would slow
down every access to such a server, even for directories under down every access to such a server, even for directories under
@ -1804,7 +1804,7 @@ fhandler_disk_file::readdir (DIR *dir, dirent *de)
{ {
d_cachepos (dir) = 0; d_cachepos (dir) = 0;
for (int cnt = 0; cnt < dir->__d_position; ++cnt) for (int cnt = 0; cnt < dir->__d_position; ++cnt)
{ {
if (d_cachepos (dir) == 0) if (d_cachepos (dir) == 0)
{ {
status = NtQueryDirectoryFile (dir->__handle, NULL, NULL, status = NtQueryDirectoryFile (dir->__handle, NULL, NULL,
@ -1812,10 +1812,10 @@ fhandler_disk_file::readdir (DIR *dir, dirent *de)
FileBothDirectoryInformation, FileBothDirectoryInformation,
FALSE, NULL, cnt == 0); FALSE, NULL, cnt == 0);
if (!NT_SUCCESS (status)) if (!NT_SUCCESS (status))
goto go_ahead; goto go_ahead;
} }
buf = (PFILE_ID_BOTH_DIR_INFORMATION) (d_cache (dir) buf = (PFILE_ID_BOTH_DIR_INFORMATION) (d_cache (dir)
+ d_cachepos (dir)); + d_cachepos (dir));
if (buf->NextEntryOffset == 0) if (buf->NextEntryOffset == 0)
d_cachepos (dir) = 0; d_cachepos (dir) = 0;
else else
@ -1982,7 +1982,7 @@ fhandler_disk_file::rewinddir (DIR *dir)
{ {
d_cachepos (dir) = 0; d_cachepos (dir) = 0;
if (wincap.has_buggy_restart_scan () && isremote ()) if (wincap.has_buggy_restart_scan () && isremote ())
{ {
/* This works around a W2K bug. The RestartScan parameter in calls /* This works around a W2K bug. The RestartScan parameter in calls
to NtQueryDirectoryFile on remote shares is ignored, thus to NtQueryDirectoryFile on remote shares is ignored, thus
resulting in not being able to rewind on remote shares. By resulting in not being able to rewind on remote shares. By

View File

@ -187,7 +187,7 @@ out:
void void
fhandler_registry::set_name (path_conv &in_pc) fhandler_registry::set_name (path_conv &in_pc)
{ {
if (strncasematch (in_pc.normalized_path, "/proc/registry32", 16)) if (strncasematch (in_pc.normalized_path, "/proc/registry32", 16))
{ {
wow64 = KEY_WOW64_32KEY; wow64 = KEY_WOW64_32KEY;
@ -287,7 +287,7 @@ fhandler_registry::fstat (struct __stat64 *buf)
RegCloseKey (hKey); RegCloseKey (hKey);
} }
else else
{ {
/* Here's the problem: If we can't open the key, we don't know /* Here's the problem: If we can't open the key, we don't know
nothing at all about the key/value. It's only clear that nothing at all about the key/value. It's only clear that
the current user has no read access. At this point it's the current user has no read access. At this point it's

View File

@ -423,12 +423,12 @@ search_wsa_event_slot (LONG new_serial_number)
HANDLE searchmtx = OpenMutex (STANDARD_RIGHTS_READ, FALSE, HANDLE searchmtx = OpenMutex (STANDARD_RIGHTS_READ, FALSE,
shared_name (searchname, "sock", wsa_events[slot].serial_number)); shared_name (searchname, "sock", wsa_events[slot].serial_number));
if (!searchmtx) if (!searchmtx)
break; break;
/* Mutex still exists, attached socket is active, try next slot. */ /* Mutex still exists, attached socket is active, try next slot. */
CloseHandle (searchmtx); CloseHandle (searchmtx);
slot = (slot + 1) % NUM_SOCKS; slot = (slot + 1) % NUM_SOCKS;
if (slot == (new_serial_number % NUM_SOCKS)) if (slot == (new_serial_number % NUM_SOCKS))
{ {
/* Did the whole array once. Too bad. */ /* Did the whole array once. Too bad. */
debug_printf ("No free socket slot"); debug_printf ("No free socket slot");
ReleaseMutex (wsa_slot_mtx); ReleaseMutex (wsa_slot_mtx);
@ -463,7 +463,7 @@ fhandler_socket::init_events ()
} }
err = GetLastError (); err = GetLastError ();
if (err == ERROR_ALREADY_EXISTS) if (err == ERROR_ALREADY_EXISTS)
CloseHandle (wsock_mtx); CloseHandle (wsock_mtx);
} }
while (err == ERROR_ALREADY_EXISTS); while (err == ERROR_ALREADY_EXISTS);
if ((wsock_evt = CreateEvent (&sec_all, TRUE, FALSE, NULL)) if ((wsock_evt = CreateEvent (&sec_all, TRUE, FALSE, NULL))
@ -500,7 +500,7 @@ fhandler_socket::evaluate_events (const long event_mask, long &events,
if (!(WSAEnumNetworkEvents (get_socket (), wsock_evt, &evts))) if (!(WSAEnumNetworkEvents (get_socket (), wsock_evt, &evts)))
{ {
if (evts.lNetworkEvents) if (evts.lNetworkEvents)
{ {
LOCK_EVENTS; LOCK_EVENTS;
wsock_events->events |= evts.lNetworkEvents; wsock_events->events |= evts.lNetworkEvents;
events_now = (wsock_events->events & event_mask); events_now = (wsock_events->events & event_mask);
@ -947,7 +947,7 @@ fhandler_socket::listen (int backlog)
fails with WSAEINVAL when it's called on an unbound socket. fails with WSAEINVAL when it's called on an unbound socket.
So we have to bind manually here to have POSIX semantics. */ So we have to bind manually here to have POSIX semantics. */
if (get_addr_family () == AF_INET) if (get_addr_family () == AF_INET)
{ {
struct sockaddr_in sin; struct sockaddr_in sin;
sin.sin_family = AF_INET; sin.sin_family = AF_INET;
sin.sin_port = 0; sin.sin_port = 0;
@ -956,8 +956,8 @@ fhandler_socket::listen (int backlog)
res = ::listen (get_socket (), backlog); res = ::listen (get_socket (), backlog);
} }
else if (get_addr_family () == AF_INET6) else if (get_addr_family () == AF_INET6)
{ {
struct sockaddr_in6 sin6 = struct sockaddr_in6 sin6 =
{ {
sin6_family: AF_INET6, sin6_family: AF_INET6,
sin6_port: 0, sin6_port: 0,
@ -1085,7 +1085,7 @@ fhandler_socket::getsockname (struct sockaddr *name, int *namelen)
{ {
res = ::getsockname (get_socket (), name, namelen); res = ::getsockname (get_socket (), name, namelen);
if (res) if (res)
{ {
if (WSAGetLastError () == WSAEINVAL) if (WSAGetLastError () == WSAEINVAL)
{ {
/* Winsock returns WSAEINVAL if the socket is locally /* Winsock returns WSAEINVAL if the socket is locally
@ -1093,7 +1093,7 @@ fhandler_socket::getsockname (struct sockaddr *name, int *namelen)
We're faking a valid return value here by creating the We're faking a valid return value here by creating the
same content in the sockaddr structure as on Linux. */ same content in the sockaddr structure as on Linux. */
switch (get_addr_family ()) switch (get_addr_family ())
{ {
case AF_INET: case AF_INET:
res = 0; res = 0;
*namelen = sizeof (struct sockaddr_in); *namelen = sizeof (struct sockaddr_in);
@ -1107,7 +1107,7 @@ fhandler_socket::getsockname (struct sockaddr *name, int *namelen)
break; break;
} }
if (!res) if (!res)
{ {
memset (name, 0, *namelen); memset (name, 0, *namelen);
name->sa_family = get_addr_family (); name->sa_family = get_addr_family ();
} }
@ -1262,7 +1262,7 @@ fhandler_socket::send_internal (struct _WSABUF *wsabuf, DWORD wsacnt, int flags,
if ((res = WSASendTo (get_socket (), wsabuf, wsacnt, &ret, if ((res = WSASendTo (get_socket (), wsabuf, wsacnt, &ret,
flags & MSG_WINMASK, to, tolen, NULL, NULL)) flags & MSG_WINMASK, to, tolen, NULL, NULL))
&& (err = WSAGetLastError ()) == WSAEWOULDBLOCK) && (err = WSAGetLastError ()) == WSAEWOULDBLOCK)
{ {
LOCK_EVENTS; LOCK_EVENTS;
wsock_events->events &= ~FD_WRITE; wsock_events->events &= ~FD_WRITE;
UNLOCK_EVENTS; UNLOCK_EVENTS;
@ -1303,7 +1303,7 @@ fhandler_socket::sendto (const void *ptr, size_t len, int flags,
WSABUF wsabuf = { len, (char *) ptr }; WSABUF wsabuf = { len, (char *) ptr };
return send_internal (&wsabuf, 1, flags, return send_internal (&wsabuf, 1, flags,
(to ? (const struct sockaddr *) &sst : NULL), tolen); (to ? (const struct sockaddr *) &sst : NULL), tolen);
} }
int int
@ -1328,7 +1328,7 @@ fhandler_socket::sendmsg (const struct msghdr *msg, int flags)
} }
return send_internal (wsabuf, msg->msg_iovlen, flags, return send_internal (wsabuf, msg->msg_iovlen, flags,
(struct sockaddr *) msg->msg_name, msg->msg_namelen); (struct sockaddr *) msg->msg_name, msg->msg_namelen);
} }
int int
@ -1441,11 +1441,11 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ) if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
{ {
ifc.ifc_len = ifcp->ifc_len / sizeof (struct __old_ifreq) ifc.ifc_len = ifcp->ifc_len / sizeof (struct __old_ifreq)
* sizeof (struct ifreq); * sizeof (struct ifreq);
ifc.ifc_buf = (caddr_t) alloca (ifc.ifc_len); ifc.ifc_buf = (caddr_t) alloca (ifc.ifc_len);
} }
else else
{ {
ifc.ifc_len = ifcp->ifc_len; ifc.ifc_len = ifcp->ifc_len;
ifc.ifc_buf = ifcp->ifc_buf; ifc.ifc_buf = ifcp->ifc_buf;
} }
@ -1453,7 +1453,7 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
if (res) if (res)
debug_printf ("error in get_ifconf"); debug_printf ("error in get_ifconf");
if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ) if (CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ)
{ {
struct __old_ifreq *ifr = (struct __old_ifreq *) ifcp->ifc_buf; struct __old_ifreq *ifr = (struct __old_ifreq *) ifcp->ifc_buf;
for (ifrp = ifc.ifc_req; for (ifrp = ifc.ifc_req;
(caddr_t) ifrp < ifc.ifc_buf + ifc.ifc_len; (caddr_t) ifrp < ifc.ifc_buf + ifc.ifc_len;
@ -1467,7 +1467,7 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
* sizeof (struct __old_ifreq); * sizeof (struct __old_ifreq);
} }
else else
ifcp->ifc_len = ifc.ifc_len; ifcp->ifc_len = ifc.ifc_len;
break; break;
case OLD_SIOCGIFFLAGS: case OLD_SIOCGIFFLAGS:
case OLD_SIOCGIFADDR: case OLD_SIOCGIFADDR:
@ -1507,7 +1507,7 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
if (cmd == SIOCGIFFRNDLYNAM) if (cmd == SIOCGIFFRNDLYNAM)
{ {
struct ifreq_frndlyname *iff = (struct ifreq_frndlyname *) struct ifreq_frndlyname *iff = (struct ifreq_frndlyname *)
alloca (64 * sizeof (struct ifreq_frndlyname)); alloca (64 * sizeof (struct ifreq_frndlyname));
for (int i = 0; i < 64; ++i) for (int i = 0; i < 64; ++i)
ifc.ifc_req[i].ifr_frndlyname = &iff[i]; ifc.ifc_req[i].ifr_frndlyname = &iff[i];
} }
@ -1573,7 +1573,7 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
async_io (*(int *) p != 0); async_io (*(int *) p != 0);
/* If async_io is switched off, revert the event handling. */ /* If async_io is switched off, revert the event handling. */
if (*(int *) p == 0) if (*(int *) p == 0)
WSAEventSelect (get_socket (), wsock_evt, EVENT_MASK); WSAEventSelect (get_socket (), wsock_evt, EVENT_MASK);
break; break;
case FIONREAD: case FIONREAD:
res = ioctlsocket (get_socket (), FIONREAD, (unsigned long *) p); res = ioctlsocket (get_socket (), FIONREAD, (unsigned long *) p);
@ -1582,14 +1582,14 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
break; break;
default: default:
/* Sockets are always non-blocking internally. So we just note the /* Sockets are always non-blocking internally. So we just note the
state here. */ state here. */
if (cmd == FIONBIO) if (cmd == FIONBIO)
{ {
syscall_printf ("socket is now %sblocking", syscall_printf ("socket is now %sblocking",
*(int *) p ? "non" : ""); *(int *) p ? "non" : "");
set_nonblocking (*(int *) p); set_nonblocking (*(int *) p);
res = 0; res = 0;
} }
else else
res = ioctlsocket (get_socket (), cmd, (unsigned long *) p); res = ioctlsocket (get_socket (), cmd, (unsigned long *) p);
break; break;

View File

@ -176,7 +176,7 @@ static int glob1(Char *, glob_t *, size_t *);
static int glob2(Char *, Char *, Char *, Char *, glob_t *, size_t *); static int glob2(Char *, Char *, Char *, Char *, glob_t *, size_t *);
static int glob3(Char *, Char *, Char *, Char *, Char *, glob_t *, size_t *); static int glob3(Char *, Char *, Char *, Char *, Char *, glob_t *, size_t *);
static int globextend(const Char *, glob_t *, size_t *); static int globextend(const Char *, glob_t *, size_t *);
static const Char * static const Char *
globtilde(const Char *, Char *, size_t, glob_t *); globtilde(const Char *, Char *, size_t, glob_t *);
static int globexp1(const Char *, glob_t *, size_t *); static int globexp1(const Char *, glob_t *, size_t *);
static int globexp2(const Char *, const Char *, glob_t *, int *, size_t *); static int globexp2(const Char *, const Char *, glob_t *, int *, size_t *);
@ -397,8 +397,8 @@ globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE)) if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
return pattern; return pattern;
/* /*
* Copy up to the end of the string or / * Copy up to the end of the string or /
*/ */
eb = &patbuf[patbuf_len - 1]; eb = &patbuf[patbuf_len - 1];
for (p = pattern + 1, h = (char *) patbuf; for (p = pattern + 1, h = (char *) patbuf;

View File

@ -329,7 +329,7 @@ MapView9x (HANDLE h, void *addr, size_t len, DWORD openflags,
/* Try mapping using the given address first, even if it's NULL. /* Try mapping using the given address first, even if it's NULL.
If it failed, and addr was not NULL and flags is not MAP_FIXED, If it failed, and addr was not NULL and flags is not MAP_FIXED,
try again with NULL address. try again with NULL address.
Note: Retrying the mapping might be unnecessary, now that mmap64 checks Note: Retrying the mapping might be unnecessary, now that mmap64 checks
for a valid memory area first. */ for a valid memory area first. */
if (!addr) if (!addr)
@ -361,7 +361,7 @@ MapViewNT (HANDLE h, void *addr, size_t len, DWORD openflags,
/* Try mapping using the given address first, even if it's NULL. /* Try mapping using the given address first, even if it's NULL.
If it failed, and addr was not NULL and flags is not MAP_FIXED, If it failed, and addr was not NULL and flags is not MAP_FIXED,
try again with NULL address. try again with NULL address.
Note: Retrying the mapping might be unnecessary, now that mmap64 checks Note: Retrying the mapping might be unnecessary, now that mmap64 checks
for a valid memory area first. */ for a valid memory area first. */
ret = NtMapViewOfSection (h, GetCurrentProcess (), &base, 0, commitsize, ret = NtMapViewOfSection (h, GetCurrentProcess (), &base, 0, commitsize,
@ -914,7 +914,7 @@ map::del_list (unsigned i)
a system call indicates that the application buffer passed had an a system call indicates that the application buffer passed had an
invalid virtual address to avoid any performance impact in non-noreserve invalid virtual address to avoid any performance impact in non-noreserve
cases. cases.
Check if the address range is all within noreserve mmap regions. If so, Check if the address range is all within noreserve mmap regions. If so,
call VirtualAlloc to commit the pages and return MMAP_NORESERVE_COMMITED call VirtualAlloc to commit the pages and return MMAP_NORESERVE_COMMITED
on success. If the page has __PROT_ATTACH (SUSv3 memory protection on success. If the page has __PROT_ATTACH (SUSv3 memory protection
@ -938,7 +938,7 @@ mmap_is_attached_or_noreserve (void *addr, size_t len)
if (map_list == NULL) if (map_list == NULL)
return MMAP_NONE; return MMAP_NONE;
while (len > 0) while (len > 0)
{ {
caddr_t u_addr; caddr_t u_addr;
DWORD u_len; DWORD u_len;
@ -1037,7 +1037,7 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
to enable remapping of formerly mapped pages. If no matching to enable remapping of formerly mapped pages. If no matching
free pages exist, check addr again, this time for the real alignment. */ free pages exist, check addr again, this time for the real alignment. */
checkpagesize = wincap.has_mmap_alignment_bug () ? checkpagesize = wincap.has_mmap_alignment_bug () ?
getsystempagesize () : pagesize; getsystempagesize () : pagesize;
if (fixed (flags) && ((uintptr_t) addr % checkpagesize)) if (fixed (flags) && ((uintptr_t) addr % checkpagesize))
{ {
set_errno (EINVAL); set_errno (EINVAL);
@ -1129,7 +1129,7 @@ mmap64 (void *addr, size_t len, int prot, int flags, int fd, _off64_t off)
} }
if (fh->fstat (&st)) if (fh->fstat (&st))
{ {
__seterrno (); __seterrno ();
goto out; goto out;
} }
@ -1235,7 +1235,7 @@ go_ahead:
PVOID newaddr = VirtualAlloc (addr, orig_len, MEM_TOP_DOWN | MEM_RESERVE, PVOID newaddr = VirtualAlloc (addr, orig_len, MEM_TOP_DOWN | MEM_RESERVE,
PAGE_READWRITE); PAGE_READWRITE);
if (!newaddr) if (!newaddr)
{ {
/* If addr is not NULL, but MAP_FIXED isn't given, allow the OS /* If addr is not NULL, but MAP_FIXED isn't given, allow the OS
to choose. */ to choose. */
if (addr && !fixed (flags)) if (addr && !fixed (flags))
@ -1248,7 +1248,7 @@ go_ahead:
} }
} }
if (!VirtualFree (newaddr, 0, MEM_RELEASE)) if (!VirtualFree (newaddr, 0, MEM_RELEASE))
{ {
__seterrno (); __seterrno ();
goto out; goto out;
} }
@ -1739,7 +1739,7 @@ fhandler_dev_zero::mmap (caddr_t *addr, size_t len, int prot,
*/ */
DWORD protect = gen_protect (prot, flags); DWORD protect = gen_protect (prot, flags);
DWORD alloc_type = MEM_TOP_DOWN | MEM_RESERVE DWORD alloc_type = MEM_TOP_DOWN | MEM_RESERVE
| (noreserve (flags) ? 0 : MEM_COMMIT); | (noreserve (flags) ? 0 : MEM_COMMIT);
base = VirtualAlloc (*addr, len, alloc_type, protect); base = VirtualAlloc (*addr, len, alloc_type, protect);
if (!base && addr && !fixed (flags)) if (!base && addr && !fixed (flags))
base = VirtualAlloc (NULL, len, alloc_type, protect); base = VirtualAlloc (NULL, len, alloc_type, protect);

View File

@ -553,7 +553,7 @@ cygwin_socket (int af, int type, int protocol)
debug_printf ("socket (%d, %d, %d)", af, type, protocol); debug_printf ("socket (%d, %d, %d)", af, type, protocol);
soc = socket (af == AF_LOCAL ? AF_INET : af, type, soc = socket (af == AF_LOCAL ? AF_INET : af, type,
af == AF_LOCAL ? 0 : protocol); af == AF_LOCAL ? 0 : protocol);
if (soc == INVALID_SOCKET) if (soc == INVALID_SOCKET)
{ {
@ -1128,11 +1128,11 @@ getdomainname (char *domain, size_t len)
/* Vista/Longhorn: unicast address has additional OnLinkPrefixLength member. */ /* Vista/Longhorn: unicast address has additional OnLinkPrefixLength member. */
typedef struct _IP_ADAPTER_UNICAST_ADDRESS_LH { typedef struct _IP_ADAPTER_UNICAST_ADDRESS_LH {
_ANONYMOUS_UNION union { _ANONYMOUS_UNION union {
ULONGLONG Alignment; ULONGLONG Alignment;
_ANONYMOUS_UNION struct { _ANONYMOUS_UNION struct {
ULONG Length; ULONG Length;
DWORD Flags; DWORD Flags;
} DUMMYSTRUCTNAME; } DUMMYSTRUCTNAME;
} DUMMYUNIONNAME; } DUMMYUNIONNAME;
struct _IP_ADAPTER_UNICAST_ADDRESS_VISTA *Next; struct _IP_ADAPTER_UNICAST_ADDRESS_VISTA *Next;
SOCKET_ADDRESS Address; SOCKET_ADDRESS Address;
@ -1231,7 +1231,7 @@ ip_addr_prefix (PIP_ADAPTER_UNICAST_ADDRESS pua, PIP_ADAPTER_PREFIX pap)
/* Prior to Vista, the loopback prefix is not available. */ /* Prior to Vista, the loopback prefix is not available. */
if (IN_LOOPBACK (((struct sockaddr_in *) if (IN_LOOPBACK (((struct sockaddr_in *)
pua->Address.lpSockaddr)->sin_addr.s_addr)) pua->Address.lpSockaddr)->sin_addr.s_addr))
return 8; return 8;
for ( ; pap; pap = pap->Next) for ( ; pap; pap = pap->Next)
if (in_are_prefix_equal ( if (in_are_prefix_equal (
&((struct sockaddr_in *) pua->Address.lpSockaddr)->sin_addr, &((struct sockaddr_in *) pua->Address.lpSockaddr)->sin_addr,
@ -1285,7 +1285,7 @@ get_adapters_addresses (PIP_ADAPTER_ADDRESSES *pa_ret, ULONG family)
if (ret != ERROR_SUCCESS) if (ret != ERROR_SUCCESS)
{ {
if (pa0) if (pa0)
free (pa0); free (pa0);
*pa_ret = NULL; *pa_ret = NULL;
return false; return false;
} }
@ -1303,7 +1303,7 @@ static inline short
convert_ifr_flags (u_long ws_flags) convert_ifr_flags (u_long ws_flags)
{ {
return (ws_flags & (WS_IFF_UP | WS_IFF_BROADCAST)) return (ws_flags & (WS_IFF_UP | WS_IFF_BROADCAST))
| ((ws_flags & (WS_IFF_LOOPBACK | WS_IFF_POINTTOPOINT)) << 1) | ((ws_flags & (WS_IFF_LOOPBACK | WS_IFF_POINTTOPOINT)) << 1)
| ((ws_flags & WS_IFF_MULTICAST) << 8); | ((ws_flags & WS_IFF_MULTICAST) << 8);
} }
@ -1323,7 +1323,7 @@ get_xp_ifconf (SOCKET s, struct ifconf *ifc, int what)
if (!get_adapters_addresses (&pa0, AF_INET)) if (!get_adapters_addresses (&pa0, AF_INET))
goto done; goto done;
for (pap = pa0; pap; pap = pap->Next) for (pap = pa0; pap; pap = pap->Next)
for (pua = pap->FirstUnicastAddress; pua; pua = pua->Next) for (pua = pap->FirstUnicastAddress; pua; pua = pua->Next)
++cnt; ++cnt;
@ -1332,19 +1332,19 @@ get_xp_ifconf (SOCKET s, struct ifconf *ifc, int what)
space for one more INTERFACE_INFO structure here. */ space for one more INTERFACE_INFO structure here. */
iie = (LPINTERFACE_INFO) alloca ((cnt + 1) * sizeof (INTERFACE_INFO)); iie = (LPINTERFACE_INFO) alloca ((cnt + 1) * sizeof (INTERFACE_INFO));
if (WSAIoctl (s, SIO_GET_INTERFACE_LIST, NULL, 0, iie, if (WSAIoctl (s, SIO_GET_INTERFACE_LIST, NULL, 0, iie,
(cnt + 1) * sizeof (INTERFACE_INFO), &size, NULL, NULL)) (cnt + 1) * sizeof (INTERFACE_INFO), &size, NULL, NULL))
{ {
set_winsock_errno (); set_winsock_errno ();
cnt = 0; cnt = 0;
goto done; goto done;
} }
struct ifreq *ifr = ifc->ifc_req; struct ifreq *ifr = ifc->ifc_req;
for (pap = pa0; pap; pap = pap->Next) for (pap = pa0; pap; pap = pap->Next)
{ {
int idx = 0; int idx = 0;
for (pua = pap->FirstUnicastAddress; pua; pua = pua->Next) for (pua = pap->FirstUnicastAddress; pua; pua = pua->Next)
{ {
int iinf_idx; int iinf_idx;
for (iinf_idx = 0; iinf_idx < cnt; ++iinf_idx) for (iinf_idx = 0; iinf_idx < cnt; ++iinf_idx)
if (iie[iinf_idx].iiAddress.AddressIn.sin_addr.s_addr if (iie[iinf_idx].iiAddress.AddressIn.sin_addr.s_addr
@ -1401,7 +1401,7 @@ get_xp_ifconf (SOCKET s, struct ifconf *ifc, int what)
break; break;
case SIOCGIFMETRIC: case SIOCGIFMETRIC:
if (wincap.has_gaa_on_link_prefix ()) if (wincap.has_gaa_on_link_prefix ())
ifr->ifr_metric = ((PIP_ADAPTER_ADDRESSES_LH) pap)->Ipv4Metric; ifr->ifr_metric = ((PIP_ADAPTER_ADDRESSES_LH) pap)->Ipv4Metric;
else else
ifr->ifr_metric = 1; ifr->ifr_metric = 1;
break; break;
@ -1566,7 +1566,7 @@ get_2k_ifconf (struct ifconf *ifc, int what)
if (ifrow->dwOperStatus >= MIB_IF_OPER_STATUS_CONNECTED) if (ifrow->dwOperStatus >= MIB_IF_OPER_STATUS_CONNECTED)
ifr->ifr_flags |= IFF_RUNNING; ifr->ifr_flags |= IFF_RUNNING;
} }
break; break;
case SIOCGIFCONF: case SIOCGIFCONF:
case SIOCGIFADDR: case SIOCGIFADDR:
sa = (struct sockaddr_in *) &ifr->ifr_addr; sa = (struct sockaddr_in *) &ifr->ifr_addr;
@ -2132,7 +2132,7 @@ if_indextoname (unsigned ifindex, char *ifname)
&& get_adapters_addresses (&pa0, AF_UNSPEC)) && get_adapters_addresses (&pa0, AF_UNSPEC))
{ {
for (pap = pa0; pap; pap = pap->Next) for (pap = pa0; pap; pap = pap->Next)
if (ifindex == pap->IfIndex) if (ifindex == pap->IfIndex)
{ {
name = strcpy (ifname, pap->AdapterName); name = strcpy (ifname, pap->AdapterName);
break; break;
@ -2160,19 +2160,19 @@ if_nameindex (void)
{ {
int cnt = 0; int cnt = 0;
for (pap = pa0; pap; pap = pap->Next) for (pap = pa0; pap; pap = pap->Next)
++cnt; ++cnt;
iflist = (struct if_nameindex *) iflist = (struct if_nameindex *)
malloc ((cnt + 1) * sizeof (struct if_nameindex) malloc ((cnt + 1) * sizeof (struct if_nameindex)
+ cnt * IF_NAMESIZE); + cnt * IF_NAMESIZE);
if (!iflist) if (!iflist)
set_errno (ENOBUFS); set_errno (ENOBUFS);
else else
{ {
ifnamelist = (char (*)[IF_NAMESIZE]) (iflist + cnt + 1); ifnamelist = (char (*)[IF_NAMESIZE]) (iflist + cnt + 1);
for (pap = pa0, cnt = 0; pap; pap = pap->Next) for (pap = pa0, cnt = 0; pap; pap = pap->Next)
{ {
for (int i = 0; i < cnt; ++i) for (int i = 0; i < cnt; ++i)
if (iflist[i].if_index == (pap->IfIndex ?: pap->Ipv6IfIndex)) if (iflist[i].if_index == (pap->IfIndex ?: pap->Ipv6IfIndex))
goto outer_loop; goto outer_loop;
iflist[cnt].if_index = pap->IfIndex ?: pap->Ipv6IfIndex; iflist[cnt].if_index = pap->IfIndex ?: pap->Ipv6IfIndex;
strcpy (iflist[cnt].if_name = ifnamelist[cnt], pap->AdapterName); strcpy (iflist[cnt].if_name = ifnamelist[cnt], pap->AdapterName);
@ -2255,7 +2255,7 @@ cygwin_bindresvport_sa (int fd, struct sockaddr *sa)
{ {
ret = fh->bind (sa, salen); ret = fh->bind (sa, salen);
if (!ret || (get_errno () != EADDRINUSE && get_errno () != EINVAL)) if (!ret || (get_errno () != EADDRINUSE && get_errno () != EINVAL))
return ret; return ret;
} }
LONG myport; LONG myport;
@ -2584,7 +2584,7 @@ inet_pton4 (const char *src, u_char *dst)
const char *pch; const char *pch;
if ((pch = strchr(digits, ch)) != NULL) if ((pch = strchr(digits, ch)) != NULL)
{ {
u_int ret = *tp * 10 + (pch - digits); u_int ret = *tp * 10 + (pch - digits);
if (ret > 255) if (ret > 255)
@ -2598,7 +2598,7 @@ inet_pton4 (const char *src, u_char *dst)
} }
} }
else if (ch == '.' && saw_digit) else if (ch == '.' && saw_digit)
{ {
if (octets == 4) if (octets == 4)
return (0); return (0);
*++tp = 0; *++tp = 0;
@ -2654,7 +2654,7 @@ inet_pton6 (const char *src, u_char *dst)
if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
pch = strchr((xdigits = xdigits_u), ch); pch = strchr((xdigits = xdigits_u), ch);
if (pch != NULL) if (pch != NULL)
{ {
val <<= 4; val <<= 4;
val |= (pch - xdigits); val |= (pch - xdigits);
if (val > 0xffff) if (val > 0xffff)
@ -2663,7 +2663,7 @@ inet_pton6 (const char *src, u_char *dst)
continue; continue;
} }
if (ch == ':') if (ch == ':')
{ {
curtok = src; curtok = src;
if (!saw_xdigit) if (!saw_xdigit)
{ {
@ -2681,7 +2681,7 @@ inet_pton6 (const char *src, u_char *dst)
continue; continue;
} }
if (ch == '.' && ((tp + INADDRSZ) <= endp) && inet_pton4(curtok, tp) > 0) if (ch == '.' && ((tp + INADDRSZ) <= endp) && inet_pton4(curtok, tp) > 0)
{ {
tp += INADDRSZ; tp += INADDRSZ;
saw_xdigit = 0; saw_xdigit = 0;
break; /* '\0' was seen by inet_pton4(). */ break; /* '\0' was seen by inet_pton4(). */
@ -2705,7 +2705,7 @@ inet_pton6 (const char *src, u_char *dst)
int i; int i;
for (i = 1; i <= n; i++) for (i = 1; i <= n; i++)
{ {
endp[- i] = colonp[n - i]; endp[- i] = colonp[n - i];
colonp[n - i] = 0; colonp[n - i] = 0;
} }
@ -2806,14 +2806,14 @@ inet_ntop6 (const u_char *src, char *dst, size_t size)
for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++) for (i = 0; i < (IN6ADDRSZ / INT16SZ); i++)
{ {
if (words[i] == 0) if (words[i] == 0)
{ {
if (cur.base == -1) if (cur.base == -1)
cur.base = i, cur.len = 1; cur.base = i, cur.len = 1;
else else
cur.len++; cur.len++;
} }
else else
{ {
if (cur.base != -1) if (cur.base != -1)
{ {
if (best.base == -1 || cur.len > best.len) if (best.base == -1 || cur.len > best.len)
@ -2838,7 +2838,7 @@ inet_ntop6 (const u_char *src, char *dst, size_t size)
{ {
/* Are we inside the best run of 0x00's? */ /* Are we inside the best run of 0x00's? */
if (best.base != -1 && i >= best.base && i < (best.base + best.len)) if (best.base != -1 && i >= best.base && i < (best.base + best.len))
{ {
if (i == best.base) if (i == best.base)
*tp++ = ':'; *tp++ = ':';
continue; continue;
@ -3040,11 +3040,11 @@ ga_dup (struct addrinfo *ai, bool v4mapped)
} }
nai->ai_addrlen = v4mapped ? sizeof (struct sockaddr_in6) : ai->ai_addrlen; nai->ai_addrlen = v4mapped ? sizeof (struct sockaddr_in6) : ai->ai_addrlen;
if ((nai->ai_addr = (struct sockaddr *) malloc (v4mapped if ((nai->ai_addr = (struct sockaddr *) malloc (v4mapped
? sizeof (struct sockaddr_in6) ? sizeof (struct sockaddr_in6)
: ai->ai_addrlen)) == NULL) : ai->ai_addrlen)) == NULL)
{ {
if (nai->ai_canonname) if (nai->ai_canonname)
free (nai->ai_canonname); free (nai->ai_canonname);
free (nai); free (nai);
return NULL; return NULL;
} }
@ -3088,11 +3088,11 @@ ga_duplist (struct addrinfo *ai, bool v4mapped)
for (; ai; ai = ai->ai_next, nai = tmp) for (; ai; ai = ai->ai_next, nai = tmp)
{ {
if (!(tmp = ga_dup (ai, v4mapped))) if (!(tmp = ga_dup (ai, v4mapped)))
goto bad; goto bad;
if (!nai0) if (!nai0)
nai0 = tmp; nai0 = tmp;
if (nai) if (nai)
nai->ai_next = tmp; nai->ai_next = tmp;
} }
return nai0; return nai0;
@ -3899,14 +3899,14 @@ load_ipv6_funcs ()
len = strlen (lib_name); len = strlen (lib_name);
strcpy (lib_name + len, "\\ws2_32.dll"); strcpy (lib_name + len, "\\ws2_32.dll");
if ((lib = LoadLibrary (lib_name))) if ((lib = LoadLibrary (lib_name)))
{ {
if (get_ipv6_funcs (lib)) if (get_ipv6_funcs (lib))
goto out; goto out;
FreeLibrary (lib); FreeLibrary (lib);
} }
strcpy (lib_name + len, "\\wship6.dll"); strcpy (lib_name + len, "\\wship6.dll");
if ((lib = LoadLibrary (lib_name))) if ((lib = LoadLibrary (lib_name)))
{ {
if (get_ipv6_funcs (lib)) if (get_ipv6_funcs (lib))
goto out; goto out;
FreeLibrary (lib); FreeLibrary (lib);
@ -3940,7 +3940,7 @@ cygwin_getaddrinfo (const char *hostname, const char *servname,
in ai_flags slip through and just ignore unknowen values. So we have in ai_flags slip through and just ignore unknowen values. So we have
to check manually here. */ to check manually here. */
if (hints && (hints->ai_flags if (hints && (hints->ai_flags
& ~(AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_ALL & ~(AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_ALL
| AI_NUMERICSERV | AI_ADDRCONFIG | AI_V4MAPPED))) | AI_NUMERICSERV | AI_ADDRCONFIG | AI_V4MAPPED)))
return EAI_BADFLAGS; return EAI_BADFLAGS;
/* AI_NUMERICSERV is not supported in our replacement getaddrinfo, nor /* AI_NUMERICSERV is not supported in our replacement getaddrinfo, nor
@ -3964,7 +3964,7 @@ cygwin_getaddrinfo (const char *hostname, const char *servname,
behaviour, the AI_ALL flag has to be set. */ behaviour, the AI_ALL flag has to be set. */
if (wincap.supports_all_posix_ai_flags () if (wincap.supports_all_posix_ai_flags ()
&& hints && hints->ai_family == PF_UNSPEC) && hints && hints->ai_family == PF_UNSPEC)
{ {
nhints = *hints; nhints = *hints;
hints = &nhints; hints = &nhints;
nhints.ai_flags |= AI_ALL; nhints.ai_flags |= AI_ALL;
@ -3972,7 +3972,7 @@ cygwin_getaddrinfo (const char *hostname, const char *servname,
int ret = w32_to_gai_err (getaddrinfo (hostname, servname, hints, res)); int ret = w32_to_gai_err (getaddrinfo (hostname, servname, hints, res));
/* Always copy over to self-allocated memory. */ /* Always copy over to self-allocated memory. */
if (!ret) if (!ret)
{ {
dupres = ga_duplist (*res, false); dupres = ga_duplist (*res, false);
freeaddrinfo (*res); freeaddrinfo (*res);
*res = dupres; *res = dupres;
@ -3980,7 +3980,7 @@ cygwin_getaddrinfo (const char *hostname, const char *servname,
return EAI_MEMORY; return EAI_MEMORY;
} }
/* AI_V4MAPPED and AI_ALL are not supported prior to Vista. So, what /* AI_V4MAPPED and AI_ALL are not supported prior to Vista. So, what
we do here is to emulate AI_V4MAPPED. If no IPv6 addresses are we do here is to emulate AI_V4MAPPED. If no IPv6 addresses are
returned, or the AI_ALL flag is set, we try with AF_INET again, and returned, or the AI_ALL flag is set, we try with AF_INET again, and
convert the returned IPv4 addresses into v4-in-v6 entries. This convert the returned IPv4 addresses into v4-in-v6 entries. This
is done in ga_dup if the v4mapped flag is set. */ is done in ga_dup if the v4mapped flag is set. */
@ -4006,7 +4006,7 @@ cygwin_getaddrinfo (const char *hostname, const char *servname,
return EAI_MEMORY; return EAI_MEMORY;
} }
/* If a list of v6 addresses exists, append the v4-in-v6 address /* If a list of v6 addresses exists, append the v4-in-v6 address
list. Otherwise just return the v4-in-v6 address list. */ list. Otherwise just return the v4-in-v6 address list. */
if (!ret) if (!ret)
{ {
struct addrinfo *ptr; struct addrinfo *ptr;
@ -4040,7 +4040,7 @@ cygwin_getnameinfo (const struct sockaddr *sa, socklen_t salen,
To avoid this strange behaviour, we check manually, if the port number To avoid this strange behaviour, we check manually, if the port number
is 0. If so, set the NI_NUMERICSERV flag to avoid this problem. */ is 0. If so, set the NI_NUMERICSERV flag to avoid this problem. */
switch (sa->sa_family) switch (sa->sa_family)
{ {
case AF_INET: case AF_INET:
if (((struct sockaddr_in *) sa)->sin_port == 0) if (((struct sockaddr_in *) sa)->sin_port == 0)
flags |= NI_NUMERICSERV; flags |= NI_NUMERICSERV;
@ -4053,7 +4053,7 @@ cygwin_getnameinfo (const struct sockaddr *sa, socklen_t salen,
int ret = w32_to_gai_err (getnameinfo (sa, salen, host, hostlen, serv, int ret = w32_to_gai_err (getnameinfo (sa, salen, host, hostlen, serv,
servlen, flags)); servlen, flags));
if (ret) if (ret)
set_winsock_errno (); set_winsock_errno ();
return ret; return ret;
} }
return ipv4_getnameinfo (sa, salen, host, hostlen, serv, servlen, flags); return ipv4_getnameinfo (sa, salen, host, hostlen, serv, servlen, flags);
@ -4129,7 +4129,7 @@ in6_are_prefix_equal (struct in6_addr *p1, struct in6_addr *p2, int len)
/* sanity check */ /* sanity check */
if (0 > len || len > 128) if (0 > len || len > 128)
return 0; return 0;
bytelen = len / 8; bytelen = len / 8;
bitlen = len % 8; bitlen = len % 8;

View File

@ -67,12 +67,12 @@ read_ea (HANDLE hdl, const char *file, const char *attrname, char *attrbuf,
== INVALID_HANDLE_VALUE) == INVALID_HANDLE_VALUE)
{ {
debug_printf ("Opening %s for querying EA %s failed, %E", debug_printf ("Opening %s for querying EA %s failed, %E",
file, attrname); file, attrname);
goto out; goto out;
} }
status = NtQueryEaFile (h, &io, fea, flen, FALSE, gea, glen, NULL, TRUE); status = NtQueryEaFile (h, &io, fea, flen, FALSE, gea, glen, NULL, TRUE);
if (NT_SUCCESS (status) || !hdl) if (NT_SUCCESS (status) || !hdl)
break; break;
debug_printf ("1. chance, %x = NtQueryEaFile (%s, %s), Win32 error %d", debug_printf ("1. chance, %x = NtQueryEaFile (%s, %s), Win32 error %d",
status, file, attrname, RtlNtStatusToDosError (status)); status, file, attrname, RtlNtStatusToDosError (status));
hdl = NULL; hdl = NULL;
@ -96,7 +96,7 @@ read_ea (HANDLE hdl, const char *file, const char *attrname, char *attrbuf,
out: out:
debug_printf ("%d = read_ea (%x, %s, %s, %x, %d)", ret, hdl, file, attrname, debug_printf ("%d = read_ea (%x, %s, %s, %x, %d)", ret, hdl, file, attrname,
attrbuf, len); attrbuf, len);
return ret; return ret;
} }
@ -147,12 +147,12 @@ write_ea (HANDLE hdl, const char *file, const char *attrname,
== INVALID_HANDLE_VALUE) == INVALID_HANDLE_VALUE)
{ {
debug_printf ("Opening %s for setting EA %s failed, %E", debug_printf ("Opening %s for setting EA %s failed, %E",
file, attrname); file, attrname);
goto out; goto out;
} }
status = NtSetEaFile (h, &io, fea, flen); status = NtSetEaFile (h, &io, fea, flen);
if (NT_SUCCESS (status) || !hdl) if (NT_SUCCESS (status) || !hdl)
break; break;
debug_printf ("1. chance, %x = NtQueryEaFile (%s, %s), Win32 error %d", debug_printf ("1. chance, %x = NtQueryEaFile (%s, %s), Win32 error %d",
status, file, attrname, RtlNtStatusToDosError (status)); status, file, attrname, RtlNtStatusToDosError (status));
hdl = NULL; hdl = NULL;
@ -167,6 +167,6 @@ write_ea (HANDLE hdl, const char *file, const char *attrname,
out: out:
debug_printf ("%d = write_ea (%x, %s, %s, %x, %d)", ret, hdl, file, attrname, debug_printf ("%d = write_ea (%x, %s, %s, %x, %d)", ret, hdl, file, attrname,
attrbuf, len); attrbuf, len);
return ret; return ret;
} }

View File

@ -3118,7 +3118,7 @@ symlink_info::check_reparse_point (const char *path, HANDLE h)
char srcbuf[CYG_MAX_PATH + 6]; char srcbuf[CYG_MAX_PATH + 6];
if (!DeviceIoControl (h, FSCTL_GET_REPARSE_POINT, NULL, 0, (LPVOID) rp, if (!DeviceIoControl (h, FSCTL_GET_REPARSE_POINT, NULL, 0, (LPVOID) rp,
MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &size, NULL)) MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &size, NULL))
{ {
debug_printf ("DeviceIoControl(FSCTL_GET_REPARSE_POINT) failed, %E"); debug_printf ("DeviceIoControl(FSCTL_GET_REPARSE_POINT) failed, %E");
set_error (EIO); set_error (EIO);
@ -3143,13 +3143,13 @@ symlink_info::check_reparse_point (const char *path, HANDLE h)
else if (rp->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) else if (rp->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT)
{ {
if (rp->SymbolicLinkReparseBuffer.PrintNameLength == 0) if (rp->SymbolicLinkReparseBuffer.PrintNameLength == 0)
{ {
/* Likely a volume mount point. Not treated as symlink. */ /* Likely a volume mount point. Not treated as symlink. */
goto close_it; goto close_it;
} }
if (rp->MountPointReparseBuffer.SubstituteNameLength if (rp->MountPointReparseBuffer.SubstituteNameLength
> 2 * (CYG_MAX_PATH + 6)) > 2 * (CYG_MAX_PATH + 6))
{ {
debug_printf ("Symlink name too long"); debug_printf ("Symlink name too long");
set_error (EIO); set_error (EIO);
goto close_it; goto close_it;
@ -3207,7 +3207,7 @@ symlink_info::posixify (char *srcbuf)
if (srcbuf[1] == '\\') /* UNC path */ if (srcbuf[1] == '\\') /* UNC path */
slashify (srcbuf, contents, 0); slashify (srcbuf, contents, 0);
else /* Paths starting with \ are current drive relative. */ else /* Paths starting with \ are current drive relative. */
{ {
char cvtbuf[CYG_MAX_PATH + 6]; char cvtbuf[CYG_MAX_PATH + 6];
strncpy (cvtbuf, cygheap->cwd.win32, 2); strncpy (cvtbuf, cygheap->cwd.win32, 2);
@ -3470,7 +3470,7 @@ symlink_info::check (char *path, const suffix_info *suffixes, unsigned opt)
/* Reparse points are potentially symlinks. */ /* Reparse points are potentially symlinks. */
if (fileattr & FILE_ATTRIBUTE_REPARSE_POINT) if (fileattr & FILE_ATTRIBUTE_REPARSE_POINT)
sym_check = 3; sym_check = 3;
/* This is the old Cygwin method creating symlinks: */ /* This is the old Cygwin method creating symlinks: */
/* A symlink will have the `system' file attribute. */ /* A symlink will have the `system' file attribute. */
@ -4235,15 +4235,15 @@ cwdstuff::set (const char *win32_cwd, const char *posix_cwd, bool doit)
{ {
cwd_lock.acquire (); cwd_lock.acquire ();
if (doit) if (doit)
{ {
if (keep_in_sync ()) if (keep_in_sync ())
{ {
/* If a Cygwin application called cygwin_internal(CW_SYNC_WINENV), /* If a Cygwin application called cygwin_internal(CW_SYNC_WINENV),
then it's about to call native Windows functions. This also then it's about to call native Windows functions. This also
sets the keep_in_sync flag so that we actually chdir into the sets the keep_in_sync flag so that we actually chdir into the
native directory on 9x to avoid confusion. */ native directory on 9x to avoid confusion. */
if (!SetCurrentDirectory (win32_cwd)) if (!SetCurrentDirectory (win32_cwd))
{ {
__seterrno (); __seterrno ();
goto out; goto out;
} }
@ -4283,7 +4283,7 @@ cwdstuff::set (const char *win32_cwd, const char *posix_cwd, bool doit)
if (wincap.can_open_directories ()) if (wincap.can_open_directories ())
{ {
HANDLE h = CreateFile (win32_cwd, FILE_TRAVERSE, HANDLE h = CreateFile (win32_cwd, FILE_TRAVERSE,
wincap.shared (), NULL, OPEN_EXISTING, wincap.shared (), NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS, NULL); FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (h == INVALID_HANDLE_VALUE) if (h == INVALID_HANDLE_VALUE)
{ {
@ -4310,7 +4310,7 @@ cwdstuff::set (const char *win32_cwd, const char *posix_cwd, bool doit)
CloseHandle (h); CloseHandle (h);
} }
} }
} }
} }
/* If there is no win32 path or it has the form c:xxx, get the value */ /* If there is no win32 path or it has the form c:xxx, get the value */
if (!win32_cwd || (isdrive (win32_cwd) && win32_cwd[2] != '\\')) if (!win32_cwd || (isdrive (win32_cwd) && win32_cwd[2] != '\\'))

View File

@ -399,7 +399,7 @@ commune_process (void *arg)
if (process_sync) // FIXME: this test shouldn't be necessary if (process_sync) // FIXME: this test shouldn't be necessary
ProtectHandle (process_sync); ProtectHandle (process_sync);
lock_process now (false); lock_process now ();
if (si._si_commune._si_code & PICOM_EXTRASTR) if (si._si_commune._si_code & PICOM_EXTRASTR)
si._si_commune._si_str = (char *) (&si + 1); si._si_commune._si_str = (char *) (&si + 1);

View File

@ -200,13 +200,13 @@ cygsidlist::free_sids ()
BOOL BOOL
cygsidlist::add (const PSID nsi, bool well_known) cygsidlist::add (const PSID nsi, bool well_known)
{ {
if (contains (nsi)) if (contains (nsi))
return TRUE; return TRUE;
if (cnt >= maxcnt) if (cnt >= maxcnt)
{ {
cygsid *tmp = new cygsid [2 * maxcnt]; cygsid *tmp = new cygsid [2 * maxcnt];
if (!tmp) if (!tmp)
return FALSE; return FALSE;
maxcnt *= 2; maxcnt *= 2;
for (int i = 0; i < cnt; ++i) for (int i = 0; i < cnt; ++i)
@ -214,12 +214,12 @@ cygsidlist::add (const PSID nsi, bool well_known)
delete [] sids; delete [] sids;
sids = tmp; sids = tmp;
} }
if (well_known) if (well_known)
sids[cnt++] *= nsi; sids[cnt++] *= nsi;
else else
sids[cnt++] = nsi; sids[cnt++] = nsi;
return TRUE; return TRUE;
} }
bool bool
get_sids_info (cygpsid owner_sid, cygpsid group_sid, __uid32_t * uidret, __gid32_t * gidret) get_sids_info (cygpsid owner_sid, cygpsid group_sid, __uid32_t * uidret, __gid32_t * gidret)
@ -274,7 +274,7 @@ PSECURITY_DESCRIPTOR
security_descriptor::realloc (size_t nsize) security_descriptor::realloc (size_t nsize)
{ {
PSECURITY_DESCRIPTOR tmp; PSECURITY_DESCRIPTOR tmp;
if (!(tmp = (PSECURITY_DESCRIPTOR) ::realloc (psd, nsize))) if (!(tmp = (PSECURITY_DESCRIPTOR) ::realloc (psd, nsize)))
return NULL; return NULL;
sd_size = nsize; sd_size = nsize;

View File

@ -232,7 +232,7 @@ get_logon_server (const char *domain, char *server, WCHAR *wserver,
/* NT4 w/o DSClient */ /* NT4 w/o DSClient */
sys_mbstowcs (wdomain, domain, INTERNET_MAX_HOST_NAME_LENGTH + 1); sys_mbstowcs (wdomain, domain, INTERNET_MAX_HOST_NAME_LENGTH + 1);
if (rediscovery) if (rediscovery)
dret = NetGetAnyDCName (NULL, wdomain, (LPBYTE *) &buf); dret = NetGetAnyDCName (NULL, wdomain, (LPBYTE *) &buf);
else else
dret = NetGetDCName (NULL, wdomain, (LPBYTE *) &buf); dret = NetGetDCName (NULL, wdomain, (LPBYTE *) &buf);
if (dret == NERR_Success) if (dret == NERR_Success)
@ -605,7 +605,7 @@ get_system_priv_list (cygsidlist &grp_list, size_t &size)
{ {
const LUID *priv; const LUID *priv;
size = sizeof (ULONG) size = sizeof (ULONG)
+ SYSTEM_PRIVILEGES_COUNT * sizeof (LUID_AND_ATTRIBUTES); + SYSTEM_PRIVILEGES_COUNT * sizeof (LUID_AND_ATTRIBUTES);
PTOKEN_PRIVILEGES privs = (PTOKEN_PRIVILEGES) malloc (size); PTOKEN_PRIVILEGES privs = (PTOKEN_PRIVILEGES) malloc (size);
if (!privs) if (!privs)
{ {
@ -657,7 +657,7 @@ get_priv_list (LSA_HANDLE lsa, cygsid &usersid, cygsidlist &grp_list,
DWORD tmp_count; DWORD tmp_count;
sys_wcstombs (buf, sizeof (buf), sys_wcstombs (buf, sizeof (buf),
privstrs[i].Buffer, privstrs[i].Length / 2); privstrs[i].Buffer, privstrs[i].Length / 2);
if (!(priv = privilege_luid_by_name (buf))) if (!(priv = privilege_luid_by_name (buf)))
continue; continue;
@ -1097,7 +1097,7 @@ lsaauth (cygsid &usersid, user_groups &new_groups, struct passwd *pw)
for (int i = 0; i < non_well_known_cnt; ++i) for (int i = 0; i < non_well_known_cnt; ++i)
{ {
if ((tmpidx = tmp_gsids.next_non_well_known_sid (tmpidx)) < 0) if ((tmpidx = tmp_gsids.next_non_well_known_sid (tmpidx)) < 0)
break; break;
gsids->Groups[i].Sid = sids_offset; gsids->Groups[i].Sid = sids_offset;
gsids->Groups[i].Attributes = SE_GROUP_MANDATORY gsids->Groups[i].Attributes = SE_GROUP_MANDATORY
| SE_GROUP_ENABLED_BY_DEFAULT | SE_GROUP_ENABLED_BY_DEFAULT
@ -1105,7 +1105,7 @@ lsaauth (cygsid &usersid, user_groups &new_groups, struct passwd *pw)
/* Mark logon SID as logon SID :) */ /* Mark logon SID as logon SID :) */
if (wincap.needs_logon_sid_in_sid_list () if (wincap.needs_logon_sid_in_sid_list ()
&& tmp_gsids.sids[tmpidx] == fake_logon_sid) && tmp_gsids.sids[tmpidx] == fake_logon_sid)
gsids->Groups[i].Attributes += SE_GROUP_LOGON_ID; gsids->Groups[i].Attributes += SE_GROUP_LOGON_ID;
CopySid (GetLengthSid (tmp_gsids.sids[tmpidx]), CopySid (GetLengthSid (tmp_gsids.sids[tmpidx]),
(PSID) ((PBYTE) &authinf->inf + sids_offset), (PSID) ((PBYTE) &authinf->inf + sids_offset),
tmp_gsids.sids[tmpidx]); tmp_gsids.sids[tmpidx]);
@ -1433,26 +1433,26 @@ get_reg_security (HANDLE handle, security_descriptor &sd_ret)
DWORD len = 0; DWORD len = 0;
ret = RegGetKeySecurity ((HKEY) handle, ret = RegGetKeySecurity ((HKEY) handle,
DACL_SECURITY_INFORMATION DACL_SECURITY_INFORMATION
| GROUP_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
| OWNER_SECURITY_INFORMATION, | OWNER_SECURITY_INFORMATION,
sd_ret, &len); sd_ret, &len);
if (ret == ERROR_INSUFFICIENT_BUFFER) if (ret == ERROR_INSUFFICIENT_BUFFER)
{ {
if (!sd_ret.malloc (len)) if (!sd_ret.malloc (len))
set_errno (ENOMEM); set_errno (ENOMEM);
else else
ret = RegGetKeySecurity ((HKEY) handle, ret = RegGetKeySecurity ((HKEY) handle,
DACL_SECURITY_INFORMATION DACL_SECURITY_INFORMATION
| GROUP_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
| OWNER_SECURITY_INFORMATION, | OWNER_SECURITY_INFORMATION,
sd_ret, &len); sd_ret, &len);
} }
if (ret != ERROR_SUCCESS) if (ret != ERROR_SUCCESS)
{ {
__seterrno (); __seterrno ();
return -1; return -1;
} }
return 0; return 0;
} }
@ -1462,7 +1462,7 @@ get_nt_object_security (HANDLE handle, SE_OBJECT_TYPE object_type,
{ {
NTSTATUS ret; NTSTATUS ret;
ULONG len = 0; ULONG len = 0;
/* Do not try to use GetSecurityInfo (again), unless we drop NT4 support. /* Do not try to use GetSecurityInfo (again), unless we drop NT4 support.
GetSecurityInfo returns the wrong user information when running in GetSecurityInfo returns the wrong user information when running in
a user session using a token created with NtCreateToken under NT4. a user session using a token created with NtCreateToken under NT4.
@ -1476,25 +1476,25 @@ get_nt_object_security (HANDLE handle, SE_OBJECT_TYPE object_type,
convert pseudo HKEY values to real handles. */ convert pseudo HKEY values to real handles. */
if (object_type == SE_REGISTRY_KEY) if (object_type == SE_REGISTRY_KEY)
return get_reg_security (handle, sd_ret); return get_reg_security (handle, sd_ret);
ret = NtQuerySecurityObject (handle, ret = NtQuerySecurityObject (handle,
DACL_SECURITY_INFORMATION DACL_SECURITY_INFORMATION
| GROUP_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
| OWNER_SECURITY_INFORMATION, | OWNER_SECURITY_INFORMATION,
sd_ret, len, &len); sd_ret, len, &len);
if (ret == STATUS_BUFFER_TOO_SMALL) if (ret == STATUS_BUFFER_TOO_SMALL)
{ {
if (!sd_ret.malloc (len)) if (!sd_ret.malloc (len))
set_errno (ENOMEM); set_errno (ENOMEM);
else else
ret = NtQuerySecurityObject (handle, ret = NtQuerySecurityObject (handle,
DACL_SECURITY_INFORMATION DACL_SECURITY_INFORMATION
| GROUP_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION
| OWNER_SECURITY_INFORMATION, | OWNER_SECURITY_INFORMATION,
sd_ret, len, &len); sd_ret, len, &len);
} }
if (ret != STATUS_SUCCESS) if (ret != STATUS_SUCCESS)
{ {
__seterrno_from_nt_status (ret); __seterrno_from_nt_status (ret);
return -1; return -1;
} }

View File

@ -3,9 +3,6 @@
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2005, 2006 Red Hat, Inc. 2005, 2006 Red Hat, Inc.
Written by Christopher Faylor of Cygnus Solutions
cgf@cygnus.com
This file is part of Cygwin. This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the This software is a copyrighted work licensed under the terms of the
@ -1316,7 +1313,7 @@ thread_socket (void *arg)
goto out; goto out;
case WAIT_OBJECT_0: case WAIT_OBJECT_0:
if (!i) /* Socket event set. */ if (!i) /* Socket event set. */
goto out; goto out;
break; break;
case WAIT_TIMEOUT: case WAIT_TIMEOUT:
default: default:
@ -1405,9 +1402,9 @@ socket_cleanup (select_record *, select_stuff *stuff)
ResetEvent (si->w4[0]); ResetEvent (si->w4[0]);
stuff->device_specific_socket = NULL; stuff->device_specific_socket = NULL;
if (si->ser_num) if (si->ser_num)
free (si->ser_num); free (si->ser_num);
if (si->w4) if (si->w4)
free (si->w4); free (si->w4);
delete si; delete si;
} }
select_printf ("returning"); select_printf ("returning");

View File

@ -1,7 +1,7 @@
/* sigproc.cc: inter/intra signal and sub process handler /* sigproc.cc: inter/intra signal and sub process handler
Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, Copyright 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006 Red Hat, Inc. 2006, 2007 Red Hat, Inc.
Written by Christopher Faylor Written by Christopher Faylor

View File

@ -253,10 +253,10 @@ unlink_nt (path_conv &win32_name, bool setattrs)
is opened "delete on close", the rename operation in try_to_bin fails is opened "delete on close", the rename operation in try_to_bin fails
with STATUS_ACCESS_DENIED. So directories must be deleted using with STATUS_ACCESS_DENIED. So directories must be deleted using
NtSetInformationFile, class FileDispositionInformation, which works fine. NtSetInformationFile, class FileDispositionInformation, which works fine.
Correction, moving a directory opened with delete-on-close fails ONLY Correction, moving a directory opened with delete-on-close fails ONLY
on XP. Note to myself: Never take anything for granted on Windows! on XP. Note to myself: Never take anything for granted on Windows!
Don't try "delete on close" if the file is on a remote share. If two Don't try "delete on close" if the file is on a remote share. If two
processes have open handles on a file and one of them calls unlink, then processes have open handles on a file and one of them calls unlink, then
it happens that the file is removed from the remote share even though the it happens that the file is removed from the remote share even though the