* fhandler.cc (fhandler_base::dup): Don't set handle on failure. Caller has

already taken care of that.
* fhandler_console.cc (fhandler_console::open): Initialize handles to NULL.
(fhandler_console::close): Ditto.  GNUify non-GNU formatted functions calls
throughout.
This commit is contained in:
Christopher Faylor 2002-09-22 03:38:57 +00:00
parent 228f6b6e07
commit c90e1cf179
43 changed files with 250 additions and 235 deletions

View File

@ -1,3 +1,15 @@
2002-09-21 Christopher Faylor <cgf@redhat.com>
* fhandler.cc (fhandler_base::dup): Don't set handle on failure.
Caller has already taken care of that.
* fhandler_console.cc (fhandler_console::open): Initialize handles to
NULL.
(fhandler_console::close): Ditto.
2002-09-21 Christopher Faylor <cgf@redhat.com>
GNUify non-GNU formatted functions calls throughout.
2002-09-21 Conrad Scott <conrad.scott@dsl.pipex.com> 2002-09-21 Conrad Scott <conrad.scott@dsl.pipex.com>
* cygwin_ipc.h: Move to "include/cygwin/ipc.h". * cygwin_ipc.h: Move to "include/cygwin/ipc.h".

View File

@ -673,7 +673,7 @@ strerror (int errnum)
break; break;
default: default:
#ifdef _MT_SAFE #ifdef _MT_SAFE
char *buf= _reent_winsup()->_strerror_buf; char *buf= _reent_winsup ()->_strerror_buf;
#else #else
static NO_COPY char buf[20]; static NO_COPY char buf[20];
#endif #endif

View File

@ -736,9 +736,9 @@ signal_fixup_after_exec (bool isspawn)
/* Set up child's signal handlers */ /* Set up child's signal handlers */
for (int i = 0; i < NSIG; i++) for (int i = 0; i < NSIG; i++)
{ {
myself->getsig(i).sa_mask = 0; myself->getsig (i).sa_mask = 0;
if (myself->getsig(i).sa_handler != SIG_IGN || isspawn) if (myself->getsig (i).sa_handler != SIG_IGN || isspawn)
myself->getsig(i).sa_handler = SIG_DFL; myself->getsig (i).sa_handler = SIG_DFL;
} }
} }

View File

@ -103,7 +103,7 @@ fhandler_base::set_readahead_valid (int val, int ch)
if (!val) if (!val)
ralen = raixget = raixput = 0; ralen = raixget = raixput = 0;
if (ch != -1) if (ch != -1)
put_readahead(ch); put_readahead (ch);
} }
int int
@ -160,7 +160,7 @@ fhandler_base::set_name (const char *unix_path, const char *win32_path, int unit
else else
{ {
const char *fmt = get_native_name (); const char *fmt = get_native_name ();
char *w = (char *) cmalloc (HEAP_STR, strlen(fmt) + 16); char *w = (char *) cmalloc (HEAP_STR, strlen (fmt) + 16);
__small_sprintf (w, fmt, unit); __small_sprintf (w, fmt, unit);
win32_path_name = w; win32_path_name = w;
} }
@ -254,7 +254,7 @@ fhandler_base::raw_read (void *ptr, size_t ulen)
{ {
DWORD bytes_read; DWORD bytes_read;
if (!ReadFile (get_handle(), ptr, ulen, &bytes_read, 0)) if (!ReadFile (get_handle (), ptr, ulen, &bytes_read, 0))
{ {
int errcode; int errcode;
@ -299,7 +299,7 @@ fhandler_base::raw_write (const void *ptr, size_t len)
{ {
DWORD bytes_written; DWORD bytes_written;
if (!WriteFile (get_handle(), ptr, len, &bytes_written, 0)) if (!WriteFile (get_handle (), ptr, len, &bytes_written, 0))
{ {
if (GetLastError () == ERROR_DISK_FULL && bytes_written > 0) if (GetLastError () == ERROR_DISK_FULL && bytes_written > 0)
return bytes_written; return bytes_written;
@ -394,7 +394,7 @@ fhandler_base::open (path_conv *pc, int flags, mode_t mode)
creation_distribution = CREATE_NEW; creation_distribution = CREATE_NEW;
if (flags & O_APPEND) if (flags & O_APPEND)
set_append_p(); set_append_p ();
/* These flags are host dependent. */ /* These flags are host dependent. */
shared = wincap.shared (); shared = wincap.shared ();
@ -601,7 +601,7 @@ fhandler_base::write (const void *ptr, size_t len)
int res; int res;
if (get_append_p ()) if (get_append_p ())
SetFilePointer (get_handle(), 0, 0, FILE_END); SetFilePointer (get_handle (), 0, 0, FILE_END);
else if (wincap.has_lseek_bug () && get_check_win95_lseek_bug ()) else if (wincap.has_lseek_bug () && get_check_win95_lseek_bug ())
{ {
/* Note: this bug doesn't happen on NT4, even though the documentation /* Note: this bug doesn't happen on NT4, even though the documentation
@ -855,7 +855,7 @@ fhandler_base::lseek (__off64_t offset, int whence)
} }
debug_printf ("setting file pointer to %u (high), %u (low)", off_high, off_low); debug_printf ("setting file pointer to %u (high), %u (low)", off_high, off_low);
res = SetFilePointer (get_handle(), off_low, poff_high, win32_whence); res = SetFilePointer (get_handle (), off_low, poff_high, win32_whence);
if (res == INVALID_SET_FILE_POINTER && GetLastError ()) if (res == INVALID_SET_FILE_POINTER && GetLastError ())
{ {
__seterrno (); __seterrno ();
@ -881,12 +881,12 @@ fhandler_base::close ()
{ {
int res = -1; int res = -1;
syscall_printf ("closing '%s' handle %p", get_name (), get_handle()); syscall_printf ("closing '%s' handle %p", get_name (), get_handle ());
if (get_nohandle () || CloseHandle (get_handle())) if (get_nohandle () || CloseHandle (get_handle ()))
res = 0; res = 0;
else else
{ {
paranoid_printf ("CloseHandle (%d <%s>) failed", get_handle(), paranoid_printf ("CloseHandle (%d <%s>) failed", get_handle (),
get_name ()); get_name ());
__seterrno (); __seterrno ();
@ -914,7 +914,7 @@ fhandler_base::lock (int, struct flock *)
} }
extern "C" char * __stdcall extern "C" char * __stdcall
rootdir(char *full_path) rootdir (char *full_path)
{ {
/* Possible choices: /* Possible choices:
* d:... -> d:/ * d:... -> d:/
@ -1006,18 +1006,19 @@ fhandler_base::dup (fhandler_base *child)
debug_printf ("in fhandler_base dup"); debug_printf ("in fhandler_base dup");
HANDLE nh; HANDLE nh;
if (get_nohandle ()) if (!get_nohandle ())
nh = INVALID_HANDLE_VALUE;
else if (!DuplicateHandle (hMainProc, get_handle(), hMainProc, &nh, 0, TRUE,
DUPLICATE_SAME_ACCESS))
{ {
system_printf ("dup(%s) failed, handle %x, %E", if (!DuplicateHandle (hMainProc, get_handle (), hMainProc, &nh, 0, TRUE,
get_name (), get_handle()); DUPLICATE_SAME_ACCESS))
__seterrno (); {
return -1; system_printf ("dup(%s) failed, handle %x, %E",
} get_name (), get_handle ());
__seterrno ();
return -1;
}
child->set_io_handle (nh); child->set_io_handle (nh);
}
return 0; return 0;
} }

View File

@ -541,8 +541,8 @@ fhandler_console::open (path_conv *, int flags, mode_t)
tcinit (get_tty_stuff (flags)); tcinit (get_tty_stuff (flags));
set_io_handle (INVALID_HANDLE_VALUE); set_io_handle (NULL);
set_output_handle (INVALID_HANDLE_VALUE); set_output_handle (NULL);
set_flags ((flags & ~O_TEXT) | O_BINARY); set_flags ((flags & ~O_TEXT) | O_BINARY);
@ -595,8 +595,8 @@ fhandler_console::close (void)
{ {
CloseHandle (get_io_handle ()); CloseHandle (get_io_handle ());
CloseHandle (get_output_handle ()); CloseHandle (get_output_handle ());
set_io_handle (INVALID_HANDLE_VALUE); set_io_handle (NULL);
set_output_handle (INVALID_HANDLE_VALUE); set_output_handle (NULL);
return 0; return 0;
} }

View File

@ -307,10 +307,10 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc,
/* First retrieve current position, set to beginning /* First retrieve current position, set to beginning
of file if not already there. */ of file if not already there. */
cur = SetFilePointer (get_handle(), 0, NULL, FILE_CURRENT); cur = SetFilePointer (get_handle (), 0, NULL, FILE_CURRENT);
if (cur != INVALID_SET_FILE_POINTER && if (cur != INVALID_SET_FILE_POINTER &&
(!cur || (!cur ||
SetFilePointer (get_handle(), 0, NULL, FILE_BEGIN) SetFilePointer (get_handle (), 0, NULL, FILE_BEGIN)
!= INVALID_SET_FILE_POINTER)) != INVALID_SET_FILE_POINTER))
{ {
/* FIXME should we use /etc/magic ? */ /* FIXME should we use /etc/magic ? */
@ -321,7 +321,7 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc,
set_execable_p (); set_execable_p ();
pc->set_exec (); pc->set_exec ();
} }
SetFilePointer (get_handle(), cur, NULL, FILE_BEGIN); SetFilePointer (get_handle (), cur, NULL, FILE_BEGIN);
} }
} }
if (pc->exec_state () == is_executable) if (pc->exec_state () == is_executable)
@ -453,7 +453,7 @@ fhandler_disk_file::lock (int cmd, struct flock *fl)
case SEEK_END: case SEEK_END:
{ {
BY_HANDLE_FILE_INFORMATION finfo; BY_HANDLE_FILE_INFORMATION finfo;
if (GetFileInformationByHandle (get_handle(), &finfo) == 0) if (GetFileInformationByHandle (get_handle (), &finfo) == 0)
{ {
__seterrno (); __seterrno ();
return -1; return -1;

View File

@ -93,7 +93,7 @@ fhandler_dev_floppy::lseek (__off64_t offset, int whence)
PARTITION_INFORMATION pi; PARTITION_INFORMATION pi;
DWORD bytes_read; DWORD bytes_read;
if (!DeviceIoControl (get_handle(), if (!DeviceIoControl (get_handle (),
IOCTL_DISK_GET_DRIVE_GEOMETRY, IOCTL_DISK_GET_DRIVE_GEOMETRY,
NULL, 0, NULL, 0,
&di, sizeof (di), &di, sizeof (di),

View File

@ -93,9 +93,9 @@ fhandler_dev_mem::open (path_conv *, int flags, mode_t)
RtlInitUnicodeString (&memstr, L"\\device\\physicalmemory"); RtlInitUnicodeString (&memstr, L"\\device\\physicalmemory");
OBJECT_ATTRIBUTES attr; OBJECT_ATTRIBUTES attr;
InitializeObjectAttributes(&attr, &memstr, InitializeObjectAttributes (&attr, &memstr,
OBJ_CASE_INSENSITIVE | OBJ_INHERIT, OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
NULL, NULL); NULL, NULL);
ACCESS_MASK section_access; ACCESS_MASK section_access;
if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDONLY) if ((flags & (O_RDONLY | O_WRONLY | O_RDWR)) == O_RDONLY)
@ -279,9 +279,9 @@ fhandler_dev_mem::mmap (caddr_t *addr, size_t len, DWORD access,
RtlInitUnicodeString (&memstr, L"\\device\\physicalmemory"); RtlInitUnicodeString (&memstr, L"\\device\\physicalmemory");
OBJECT_ATTRIBUTES attr; OBJECT_ATTRIBUTES attr;
InitializeObjectAttributes(&attr, &memstr, InitializeObjectAttributes (&attr, &memstr,
OBJ_CASE_INSENSITIVE | OBJ_INHERIT, OBJ_CASE_INSENSITIVE | OBJ_INHERIT,
NULL, NULL); NULL, NULL);
ACCESS_MASK section_access; ACCESS_MASK section_access;
ULONG protect; ULONG protect;
@ -432,5 +432,5 @@ fhandler_dev_mem::dup (fhandler_base *child)
void void
fhandler_dev_mem::dump () fhandler_dev_mem::dump ()
{ {
paranoid_printf("here, fhandler_dev_mem"); paranoid_printf ("here, fhandler_dev_mem");
} }

View File

@ -50,7 +50,7 @@ static const char *proc_listing[] = {
NULL NULL
}; };
static const int PROC_LINK_COUNT = (sizeof(proc_listing) / sizeof(const char *)) - 1; static const int PROC_LINK_COUNT = (sizeof (proc_listing) / sizeof (const char *)) - 1;
/* FH_PROC in the table below means the file/directory is handles by /* FH_PROC in the table below means the file/directory is handles by
* fhandler_proc. * fhandler_proc.
@ -412,7 +412,7 @@ format_proc_uptime (char *destbuf, size_t maxsize)
NTSTATUS ret = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) &spt, NTSTATUS ret = NtQuerySystemInformation (SystemProcessorTimes, (PVOID) &spt,
sizeof spt, NULL); sizeof spt, NULL);
if (!ret && GetLastError () == ERROR_PROC_NOT_FOUND) if (!ret && GetLastError () == ERROR_PROC_NOT_FOUND)
uptime = GetTickCount() / 10; uptime = GetTickCount () / 10;
else if (ret != STATUS_SUCCESS) else if (ret != STATUS_SUCCESS)
{ {
__seterrno_from_win_error (RtlNtStatusToDosError (ret)); __seterrno_from_win_error (RtlNtStatusToDosError (ret));

View File

@ -68,10 +68,10 @@ static off_t format_process_stat (_pinfo *p, char *destbuf, size_t maxsize);
static off_t format_process_status (_pinfo *p, char *destbuf, size_t maxsize); static off_t format_process_status (_pinfo *p, char *destbuf, size_t maxsize);
static off_t format_process_statm (_pinfo *p, char *destbuf, size_t maxsize); static off_t format_process_statm (_pinfo *p, char *destbuf, size_t maxsize);
static int get_process_state (DWORD dwProcessId); static int get_process_state (DWORD dwProcessId);
static bool get_mem_values(DWORD dwProcessId, unsigned long *vmsize, static bool get_mem_values (DWORD dwProcessId, unsigned long *vmsize,
unsigned long *vmrss, unsigned long *vmtext, unsigned long *vmrss, unsigned long *vmtext,
unsigned long *vmdata, unsigned long *vmlib, unsigned long *vmdata, unsigned long *vmlib,
unsigned long *vmshare); unsigned long *vmshare);
/* Returns 0 if path doesn't exist, >0 if path is a directory, /* Returns 0 if path doesn't exist, >0 if path is a directory,
* <0 if path is a file. * <0 if path is a file.
@ -126,7 +126,7 @@ fhandler_process::fstat (struct __stat64 *buf, path_conv *pc)
case 2: case 2:
buf->st_ctime = buf->st_mtime = p->start_time; buf->st_ctime = buf->st_mtime = p->start_time;
buf->st_ctim.tv_nsec = buf->st_mtim.tv_nsec = 0; buf->st_ctim.tv_nsec = buf->st_mtim.tv_nsec = 0;
time_as_timestruc_t(&buf->st_atim); time_as_timestruc_t (&buf->st_atim);
buf->st_uid = p->uid; buf->st_uid = p->uid;
buf->st_gid = p->gid; buf->st_gid = p->gid;
buf->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH; buf->st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;
@ -373,7 +373,7 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
strcpy (cmd, "<defunct>"); strcpy (cmd, "<defunct>");
else else
{ {
strcpy(cmd, p->progname); strcpy (cmd, p->progname);
char *last_slash = strrchr (cmd, '\\'); char *last_slash = strrchr (cmd, '\\');
if (last_slash != NULL) if (last_slash != NULL)
strcpy (cmd, last_slash + 1); strcpy (cmd, last_slash + 1);
@ -434,7 +434,7 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
{ {
DWORD error = GetLastError (); DWORD error = GetLastError ();
__seterrno_from_win_error (error); __seterrno_from_win_error (error);
debug_printf("OpenProcess: ret = %d", debug_printf ("OpenProcess: ret = %d",
error); error);
return 0; return 0;
} }
@ -449,7 +449,7 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
if (ret != STATUS_SUCCESS) if (ret != STATUS_SUCCESS)
{ {
__seterrno_from_win_error (RtlNtStatusToDosError (ret)); __seterrno_from_win_error (RtlNtStatusToDosError (ret));
debug_printf("NtQueryInformationProcess: ret = %d, " debug_printf ("NtQueryInformationProcess: ret = %d, "
"Dos(ret) = %d", "Dos(ret) = %d",
ret, RtlNtStatusToDosError (ret)); ret, RtlNtStatusToDosError (ret));
return 0; return 0;
@ -468,7 +468,7 @@ format_process_stat (_pinfo *p, char *destbuf, size_t maxsize)
*/ */
start_time = (spt.KernelTime.QuadPart + spt.UserTime.QuadPart) * HZ / 10000000ULL; start_time = (spt.KernelTime.QuadPart + spt.UserTime.QuadPart) * HZ / 10000000ULL;
priority = pbi.BasePriority; priority = pbi.BasePriority;
unsigned page_size = getpagesize(); unsigned page_size = getpagesize ();
vmsize = vmc.VirtualSize; vmsize = vmc.VirtualSize;
vmrss = vmc.WorkingSetSize / page_size; vmrss = vmc.WorkingSetSize / page_size;
vmmaxrss = ql.MaximumWorkingSetSize / page_size; vmmaxrss = ql.MaximumWorkingSetSize / page_size;
@ -507,7 +507,7 @@ format_process_status (_pinfo *p, char *destbuf, size_t maxsize)
strcpy (cmd, "<defunct>"); strcpy (cmd, "<defunct>");
else else
{ {
strcpy(cmd, p->progname); strcpy (cmd, p->progname);
char *last_slash = strrchr (cmd, '\\'); char *last_slash = strrchr (cmd, '\\');
if (last_slash != NULL) if (last_slash != NULL)
strcpy (cmd, last_slash + 1); strcpy (cmd, last_slash + 1);
@ -552,7 +552,7 @@ format_process_status (_pinfo *p, char *destbuf, size_t maxsize)
{ {
if (!get_mem_values (p->dwProcessId, &vmsize, &vmrss, &vmtext, &vmdata, &vmlib, &vmshare)) if (!get_mem_values (p->dwProcessId, &vmsize, &vmrss, &vmtext, &vmdata, &vmlib, &vmshare))
return 0; return 0;
unsigned page_size = getpagesize(); unsigned page_size = getpagesize ();
vmsize *= page_size; vmrss *= page_size; vmdata *= page_size; vmsize *= page_size; vmrss *= page_size; vmdata *= page_size;
vmtext *= page_size; vmlib *= page_size; vmtext *= page_size; vmlib *= page_size;
} }
@ -623,7 +623,7 @@ get_process_state (DWORD dwProcessId)
delete [] p, p = new ULONG[n *= 2]; delete [] p, p = new ULONG[n *= 2];
if (ret != STATUS_SUCCESS) if (ret != STATUS_SUCCESS)
{ {
debug_printf("NtQuerySystemInformation: ret = %d, " debug_printf ("NtQuerySystemInformation: ret = %d, "
"Dos(ret) = %d", "Dos(ret) = %d",
ret, RtlNtStatusToDosError (ret)); ret, RtlNtStatusToDosError (ret));
goto out; goto out;
@ -672,8 +672,9 @@ out:
static static
bool bool
get_mem_values(DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss, unsigned long *vmtext, get_mem_values (DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss,
unsigned long *vmdata, unsigned long *vmlib, unsigned long *vmshare) unsigned long *vmtext, unsigned long *vmdata,
unsigned long *vmlib, unsigned long *vmshare)
{ {
bool res = true; bool res = true;
NTSTATUS ret; NTSTATUS ret;
@ -682,14 +683,14 @@ get_mem_values(DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss, u
MEMORY_WORKING_SET_LIST *mwsl; MEMORY_WORKING_SET_LIST *mwsl;
ULONG n = 0x1000, length; ULONG n = 0x1000, length;
PULONG p = new ULONG[n]; PULONG p = new ULONG[n];
unsigned page_size = getpagesize(); unsigned page_size = getpagesize ();
hProcess = OpenProcess (PROCESS_QUERY_INFORMATION, hProcess = OpenProcess (PROCESS_QUERY_INFORMATION,
FALSE, dwProcessId); FALSE, dwProcessId);
if (hProcess == NULL) if (hProcess == NULL)
{ {
DWORD error = GetLastError(); DWORD error = GetLastError ();
__seterrno_from_win_error (error); __seterrno_from_win_error (error);
debug_printf("OpenProcess: ret = %d", debug_printf ("OpenProcess: ret = %d",
error); error);
return false; return false;
} }
@ -702,7 +703,7 @@ get_mem_values(DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss, u
delete [] p, p = new ULONG[n *= 2]; delete [] p, p = new ULONG[n *= 2];
if (ret != STATUS_SUCCESS) if (ret != STATUS_SUCCESS)
{ {
debug_printf("NtQueryVirtualMemory: ret = %d, " debug_printf ("NtQueryVirtualMemory: ret = %d, "
"Dos(ret) = %d", "Dos(ret) = %d",
ret, RtlNtStatusToDosError (ret)); ret, RtlNtStatusToDosError (ret));
res = false; res = false;
@ -728,9 +729,9 @@ get_mem_values(DWORD dwProcessId, unsigned long *vmsize, unsigned long *vmrss, u
sizeof vmc, NULL); sizeof vmc, NULL);
if (ret != STATUS_SUCCESS) if (ret != STATUS_SUCCESS)
{ {
debug_printf("NtQueryInformationProcess: ret = %d, " debug_printf ("NtQueryInformationProcess: ret = %d, "
"Dos(ret) = %d", "Dos(ret) = %d",
ret, RtlNtStatusToDosError (ret)); ret, RtlNtStatusToDosError (ret));
res = false; res = false;
goto out; goto out;
} }

View File

@ -24,7 +24,7 @@ details. */
#define PSEUDO_SHIFTVAL (21) #define PSEUDO_SHIFTVAL (21)
fhandler_dev_random::fhandler_dev_random (int nunit) fhandler_dev_random::fhandler_dev_random (int nunit)
: fhandler_base (FH_RANDOM), unit(nunit), crypt_prov((HCRYPTPROV) NULL) : fhandler_base (FH_RANDOM), unit (nunit), crypt_prov ((HCRYPTPROV) NULL)
{ {
} }
@ -145,7 +145,7 @@ fhandler_dev_random::close (void)
if (crypt_prov) if (crypt_prov)
while (!CryptReleaseContext (crypt_prov, 0) while (!CryptReleaseContext (crypt_prov, 0)
&& GetLastError () == ERROR_BUSY) && GetLastError () == ERROR_BUSY)
Sleep(10); Sleep (10);
return 0; return 0;
} }
@ -161,6 +161,6 @@ fhandler_dev_random::dup (fhandler_base *child)
void void
fhandler_dev_random::dump () fhandler_dev_random::dump ()
{ {
paranoid_printf("here, fhandler_dev_random"); paranoid_printf ("here, fhandler_dev_random");
} }

View File

@ -56,7 +56,7 @@ static BOOL read_file (HANDLE fh, void *buf, DWORD to_read,
BOOL ret; BOOL ret;
*err = 0; *err = 0;
if (!(ret = ReadFile(fh, buf, to_read, read, 0))) if (!(ret = ReadFile (fh, buf, to_read, read, 0)))
{ {
if ((*err = GetLastError ()) == ERROR_MEDIA_CHANGED if ((*err = GetLastError ()) == ERROR_MEDIA_CHANGED
|| *err == ERROR_BUS_RESET) || *err == ERROR_BUS_RESET)
@ -136,7 +136,7 @@ fhandler_dev_raw::open (path_conv *real_path, int flags, mode_t)
if (!wincap.has_raw_devices ()) if (!wincap.has_raw_devices ())
{ {
set_errno (ENOENT); set_errno (ENOENT);
debug_printf("%s is accessible under NT/W2K only",real_path->get_win32()); debug_printf ("%s is accessible under NT/W2K only",real_path->get_win32());
return 0; return 0;
} }

View File

@ -502,7 +502,7 @@ fhandler_socket::accept (struct sockaddr *peer, int *len)
if (len && ((unsigned) *len < sizeof (struct sockaddr_in))) if (len && ((unsigned) *len < sizeof (struct sockaddr_in)))
*len = sizeof (struct sockaddr_in); *len = sizeof (struct sockaddr_in);
if (!is_nonblocking()) if (!is_nonblocking ())
{ {
ev[0] = WSACreateEvent (); ev[0] = WSACreateEvent ();

View File

@ -347,8 +347,8 @@ fhandler_dev_tape::ioctl (unsigned int cmd, void *buf)
} }
if (devbufsiz > 1L && size > 1L) if (devbufsiz > 1L && size > 1L)
{ {
memcpy(buf, devbuf + devbufstart, memcpy (buf, devbuf + devbufstart,
devbufend - devbufstart); devbufend - devbufstart);
devbufend -= devbufstart; devbufend -= devbufstart;
} }
else else

View File

@ -114,7 +114,7 @@ tty_min::set_ctty (int ttynum, int flags)
(p == myself || !proc_exists (p))) (p == myself || !proc_exists (p)))
{ {
paranoid_printf ("resetting tty%d sid. Was %d, now %d. pgid was %d, now %d.", paranoid_printf ("resetting tty%d sid. Was %d, now %d. pgid was %d, now %d.",
ttynum, getsid(), myself->sid, getpgid (), myself->pgid); ttynum, getsid (), myself->sid, getpgid (), myself->pgid);
/* We are the session leader */ /* We are the session leader */
setsid (myself->sid); setsid (myself->sid);
setpgid (myself->pgid); setpgid (myself->pgid);
@ -137,7 +137,7 @@ fhandler_termios::bg_check (int sig)
if (sig < 0) if (sig < 0)
sig = -sig; sig = -sig;
termios_printf("bg I/O pgid %d, tpgid %d, ctty %d", termios_printf ("bg I/O pgid %d, tpgid %d, ctty %d",
myself->pgid, tc->getpgid (), myself->ctty); myself->pgid, tc->getpgid (), myself->ctty);
if (tc->getsid () == 0) if (tc->getsid () == 0)
@ -154,7 +154,7 @@ fhandler_termios::bg_check (int sig)
return with error */ return with error */
int pgid_gone = !pid_exists (myself->pgid); int pgid_gone = !pid_exists (myself->pgid);
int sigs_ignored = int sigs_ignored =
((void *) myself->getsig(sig).sa_handler == (void *) SIG_IGN) || ((void *) myself->getsig (sig).sa_handler == (void *) SIG_IGN) ||
(myself->getsigmask () & SIGTOMASK (sig)); (myself->getsigmask () & SIGTOMASK (sig));
if (pgid_gone) if (pgid_gone)

View File

@ -708,7 +708,7 @@ fhandler_tty_slave::read (void *ptr, size_t len)
termios_printf ("failed to acquire input mutex after input event arrived"); termios_printf ("failed to acquire input mutex after input event arrived");
break; break;
} }
if (!PeekNamedPipe (get_handle (), peek_buf, sizeof(peek_buf), &bytes_in_pipe, NULL, NULL)) if (!PeekNamedPipe (get_handle (), peek_buf, sizeof (peek_buf), &bytes_in_pipe, NULL, NULL))
{ {
termios_printf ("PeekNamedPipe failed, %E"); termios_printf ("PeekNamedPipe failed, %E");
_raise (SIGHUP); _raise (SIGHUP);

View File

@ -38,7 +38,7 @@ fhandler_dev_zero::write (const void *, size_t len)
int __stdcall int __stdcall
fhandler_dev_zero::read (void *ptr, size_t len) fhandler_dev_zero::read (void *ptr, size_t len)
{ {
memset(ptr, 0, len); memset (ptr, 0, len);
return len; return len;
} }
@ -51,5 +51,5 @@ fhandler_dev_zero::lseek (__off64_t, int)
void void
fhandler_dev_zero::dump () fhandler_dev_zero::dump ()
{ {
paranoid_printf("here, fhandler_dev_zero"); paranoid_printf ("here, fhandler_dev_zero");
} }

View File

@ -194,7 +194,7 @@ resume_child (PROCESS_INFORMATION &pi, HANDLE forker_finished)
Note that this has to be a macro since the parent may be messing with Note that this has to be a macro since the parent may be messing with
our stack. */ our stack. */
static void __stdcall static void __stdcall
sync_with_parent(const char *s, bool hang_self) sync_with_parent (const char *s, bool hang_self)
{ {
debug_printf ("signalling parent: %s", s); debug_printf ("signalling parent: %s", s);
/* Tell our parent we're waiting. */ /* Tell our parent we're waiting. */
@ -258,7 +258,7 @@ fork_child (HANDLE& hParent, dll *&first_dll, bool& load_dlls)
if (GetEnvironmentVariable ("CYGWIN_FORK_SLEEP", buf, sizeof (buf))) if (GetEnvironmentVariable ("CYGWIN_FORK_SLEEP", buf, sizeof (buf)))
{ {
small_printf ("Sleeping %d after fork, pid %u\n", atoi (buf), GetCurrentProcessId ()); small_printf ("Sleeping %d after fork, pid %u\n", atoi (buf), GetCurrentProcessId ());
Sleep (atoi(buf)); Sleep (atoi (buf));
} }
#endif #endif
@ -426,7 +426,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
si.cb = sizeof (STARTUPINFO); si.cb = sizeof (STARTUPINFO);
si.lpReserved2 = (LPBYTE)&ch; si.lpReserved2 = (LPBYTE)&ch;
si.cbReserved2 = sizeof(ch); si.cbReserved2 = sizeof (ch);
/* Remove impersonation */ /* Remove impersonation */
if (cygheap->user.issetuid ()) if (cygheap->user.issetuid ())
@ -475,8 +475,8 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
{ {
__seterrno (); __seterrno ();
syscall_printf ("CreateProcessA failed, %E"); syscall_printf ("CreateProcessA failed, %E");
ForceCloseHandle(subproc_ready); ForceCloseHandle (subproc_ready);
ForceCloseHandle(forker_finished); ForceCloseHandle (forker_finished);
/* Restore impersonation */ /* Restore impersonation */
if (cygheap->user.issetuid ()) if (cygheap->user.issetuid ())
ImpersonateLoggedOnUser (cygheap->user.token); ImpersonateLoggedOnUser (cygheap->user.token);
@ -503,7 +503,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
/* Initialize things that are done later in dll_crt0_1 that aren't done /* Initialize things that are done later in dll_crt0_1 that aren't done
for the forkee. */ for the forkee. */
strcpy(forked->progname, myself->progname); strcpy (forked->progname, myself->progname);
/* Restore impersonation */ /* Restore impersonation */
if (cygheap->user.issetuid ()) if (cygheap->user.issetuid ())
@ -517,7 +517,7 @@ fork_parent (HANDLE& hParent, dll *&first_dll,
/* Fill in fields in the child's process table entry. */ /* Fill in fields in the child's process table entry. */
forked->hProcess = pi.hProcess; forked->hProcess = pi.hProcess;
forked->dwProcessId = pi.dwProcessId; forked->dwProcessId = pi.dwProcessId;
forked->copysigs(myself); forked->copysigs (myself);
/* Hopefully, this will succeed. The alternative to doing things this /* Hopefully, this will succeed. The alternative to doing things this
way is to reserve space prior to calling CreateProcess and then fill way is to reserve space prior to calling CreateProcess and then fill

View File

@ -35,7 +35,7 @@ static int max_lines;
/* Position in the group cache */ /* Position in the group cache */
#ifdef _MT_SAFE #ifdef _MT_SAFE
#define grp_pos _reent_winsup()->_grp_pos #define grp_pos _reent_winsup ()->_grp_pos
#else #else
static int grp_pos = 0; static int grp_pos = 0;
#endif #endif
@ -45,7 +45,7 @@ static pwdgrp_check group_state;
static int static int
parse_grp (struct __group32 &grp, char *line) parse_grp (struct __group32 &grp, char *line)
{ {
int len = strlen(line); int len = strlen (line);
if (line[--len] == '\r') if (line[--len] == '\r')
line[len] = '\0'; line[len] = '\0';
@ -157,7 +157,7 @@ read_etc_group ()
if (strlen (line)) if (strlen (line))
add_grp_line (line); add_grp_line (line);
group_state.set_last_modified (gr.get_fhandle(), gr.get_fname ()); group_state.set_last_modified (gr.get_fhandle (), gr.get_fname ());
group_state = loaded; group_state = loaded;
gr.close (); gr.close ();
debug_printf ("Read /etc/group, %d lines", curr_lines); debug_printf ("Read /etc/group, %d lines", curr_lines);
@ -189,8 +189,8 @@ read_etc_group ()
snprintf (linebuf, sizeof (linebuf), "%s:%s:%lu:", snprintf (linebuf, sizeof (linebuf), "%s:%s:%lu:",
group_name, group_name,
tg.string (strbuf), tg.string (strbuf),
*GetSidSubAuthority(tg, *GetSidSubAuthority (tg,
*GetSidSubAuthorityCount(tg) - 1)); *GetSidSubAuthorityCount (tg) - 1));
debug_printf ("Emulating /etc/group: %s", linebuf); debug_printf ("Emulating /etc/group: %s", linebuf);
add_grp_line (linebuf); add_grp_line (linebuf);
group_state = emulated; group_state = emulated;
@ -243,7 +243,7 @@ getgrgid32 (__gid32_t gid)
{ {
struct __group32 * default_grp = NULL; struct __group32 * default_grp = NULL;
if (group_state <= initializing) if (group_state <= initializing)
read_etc_group(); read_etc_group ();
for (int i = 0; i < curr_lines; i++) for (int i = 0; i < curr_lines; i++)
{ {
@ -270,7 +270,7 @@ struct __group32 *
getgrnam32 (const char *name) getgrnam32 (const char *name)
{ {
if (group_state <= initializing) if (group_state <= initializing)
read_etc_group(); read_etc_group ();
for (int i = 0; i < curr_lines; i++) for (int i = 0; i < curr_lines; i++)
if (strcasematch (group_buf[i].gr_name, name)) if (strcasematch (group_buf[i].gr_name, name))
@ -291,17 +291,17 @@ getgrnam (const char *name)
extern "C" extern "C"
void void
endgrent() endgrent ()
{ {
grp_pos = 0; grp_pos = 0;
} }
extern "C" extern "C"
struct __group32 * struct __group32 *
getgrent32() getgrent32 ()
{ {
if (group_state <= initializing) if (group_state <= initializing)
read_etc_group(); read_etc_group ();
if (grp_pos < curr_lines) if (grp_pos < curr_lines)
return group_buf + grp_pos++; return group_buf + grp_pos++;
@ -311,7 +311,7 @@ getgrent32()
extern "C" extern "C"
struct __group16 * struct __group16 *
getgrent() getgrent ()
{ {
static struct __group16 g16; static struct __group16 g16;
@ -330,7 +330,7 @@ struct __group32 *
internal_getgrent (int pos) internal_getgrent (int pos)
{ {
if (group_state <= initializing) if (group_state <= initializing)
read_etc_group(); read_etc_group ();
if (pos < curr_lines) if (pos < curr_lines)
return group_buf + pos; return group_buf + pos;
@ -347,7 +347,7 @@ getgroups32 (int gidsetsize, __gid32_t *grouplist, __gid32_t gid,
struct __group32 *gr; struct __group32 *gr;
if (group_state <= initializing) if (group_state <= initializing)
read_etc_group(); read_etc_group ();
if (allow_ntsec && if (allow_ntsec &&
OpenProcessToken (hMainProc, TOKEN_QUERY, &hToken)) OpenProcessToken (hMainProc, TOKEN_QUERY, &hToken))

View File

@ -68,7 +68,7 @@ heap_init ()
/* Initialize page mask and default heap size. Preallocate a heap /* Initialize page mask and default heap size. Preallocate a heap
* to assure contiguous memory. */ * to assure contiguous memory. */
cygheap->heapptr = cygheap->heaptop = cygheap->heapbase = cygheap->heapptr = cygheap->heaptop = cygheap->heapbase =
VirtualAlloc(NULL, cygwin_shared->heap_chunk_size (), MEM_RESERVE, VirtualAlloc (NULL, cygwin_shared->heap_chunk_size (), MEM_RESERVE,
PAGE_NOACCESS); PAGE_NOACCESS);
if (cygheap->heapbase == NULL) if (cygheap->heapbase == NULL)
api_fatal ("2. unable to allocate heap, heap_chunk_size %d, %E", api_fatal ("2. unable to allocate heap, heap_chunk_size %d, %E",
@ -86,7 +86,7 @@ heap_init ()
/* FIXME: This function no longer handles "split heaps". */ /* FIXME: This function no longer handles "split heaps". */
extern "C" void * extern "C" void *
_sbrk(int n) _sbrk (int n)
{ {
sigframe thisframe (mainthread); sigframe thisframe (mainthread);
char *newtop, *newbrk; char *newtop, *newbrk;
@ -104,21 +104,21 @@ _sbrk(int n)
if (n < 0) if (n < 0)
{ /* Freeing memory */ { /* Freeing memory */
assert(newtop < cygheap->heaptop); assert (newtop < cygheap->heaptop);
n = (char *) cygheap->heaptop - newtop; n = (char *) cygheap->heaptop - newtop;
if (VirtualFree(newtop, n, MEM_DECOMMIT)) /* Give it back to OS */ if (VirtualFree (newtop, n, MEM_DECOMMIT)) /* Give it back to OS */
goto good; /* Didn't take */ goto good; /* Didn't take */
else else
goto err; goto err;
} }
assert(newtop > cygheap->heaptop); assert (newtop > cygheap->heaptop);
/* Need to grab more pages from the OS. If this fails it may be because /* Need to grab more pages from the OS. If this fails it may be because
* we have used up previously reserved memory. Or, we're just plumb out * we have used up previously reserved memory. Or, we're just plumb out
* of memory. */ * of memory. */
commitbytes = pround (newtop - (char *) cygheap->heaptop); commitbytes = pround (newtop - (char *) cygheap->heaptop);
if (VirtualAlloc(cygheap->heaptop, commitbytes, MEM_COMMIT, PAGE_READWRITE) != NULL) if (VirtualAlloc (cygheap->heaptop, commitbytes, MEM_COMMIT, PAGE_READWRITE) != NULL)
goto good; goto good;
/* Couldn't allocate memory. Maybe we can reserve some more. /* Couldn't allocate memory. Maybe we can reserve some more.
@ -128,8 +128,8 @@ _sbrk(int n)
if ((newbrksize = cygwin_shared->heap_chunk_size ()) < commitbytes) if ((newbrksize = cygwin_shared->heap_chunk_size ()) < commitbytes)
newbrksize = commitbytes; newbrksize = commitbytes;
if ((VirtualAlloc(cygheap->heaptop, newbrksize, MEM_RESERVE, PAGE_NOACCESS) != NULL) && if ((VirtualAlloc (cygheap->heaptop, newbrksize, MEM_RESERVE, PAGE_NOACCESS) != NULL) &&
(VirtualAlloc(cygheap->heaptop, commitbytes, MEM_COMMIT, PAGE_READWRITE) != NULL)) (VirtualAlloc (cygheap->heaptop, commitbytes, MEM_COMMIT, PAGE_READWRITE) != NULL))
goto good; goto good;
err: err:

View File

@ -27,21 +27,23 @@ WINAPI dll_entry (HANDLE h, DWORD reason, void *static_load)
case DLL_THREAD_ATTACH: case DLL_THREAD_ATTACH:
if (user_data->threadinterface) if (user_data->threadinterface)
{ {
if (!TlsSetValue(user_data->threadinterface->reent_index, if (!TlsSetValue (user_data->threadinterface->reent_index,
&user_data->threadinterface->reents)) &user_data->threadinterface->reents))
api_fatal("Sig proc MT init failed\n"); api_fatal ("Sig proc MT init failed\n");
} }
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
break; break;
case DLL_THREAD_DETACH: case DLL_THREAD_DETACH:
pthread *thisthread = (pthread *) TlsGetValue ( #if 0
user_data->threadinterface->thread_self_dwTlsIndex); pthread *thisthread = (pthread *)
TlsGetValue (user_data->threadinterface->thread_self_dwTlsIndex);
if (thisthread) { if (thisthread) {
/* Some non-pthread call created this thread, /* Some non-pthread call created this thread,
* but we need to clean it up */ * but we need to clean it up */
thisthread->exit(0); thisthread->exit (0);
} }
#endif
break; break;
} }
return 1; return 1;

View File

@ -448,7 +448,7 @@ mmap64 (caddr_t addr, size_t len, int prot, int flags, int fd, __off64_t off)
return MAP_FAILED; return MAP_FAILED;
} }
SetResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap"); SetResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
if (mmapped_areas == NULL) if (mmapped_areas == NULL)
{ {
@ -458,7 +458,7 @@ mmap64 (caddr_t addr, size_t len, int prot, int flags, int fd, __off64_t off)
{ {
set_errno (ENOMEM); set_errno (ENOMEM);
syscall_printf ("-1 = mmap(): ENOMEM"); syscall_printf ("-1 = mmap(): ENOMEM");
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap"); ReleaseResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
return MAP_FAILED; return MAP_FAILED;
} }
} }
@ -481,7 +481,7 @@ mmap64 (caddr_t addr, size_t len, int prot, int flags, int fd, __off64_t off)
if (cfd < 0) if (cfd < 0)
{ {
syscall_printf ("-1 = mmap(): EBADF"); syscall_printf ("-1 = mmap(): EBADF");
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap"); ReleaseResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
return MAP_FAILED; return MAP_FAILED;
} }
fh = cfd; fh = cfd;
@ -518,12 +518,12 @@ mmap64 (caddr_t addr, size_t len, int prot, int flags, int fd, __off64_t off)
{ {
set_errno (ENOMEM); set_errno (ENOMEM);
syscall_printf ("-1 = mmap(): ENOMEM"); syscall_printf ("-1 = mmap(): ENOMEM");
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK|WRITE_LOCK, "mmap"); ReleaseResourceLock (LOCK_MMAP_LIST, READ_LOCK|WRITE_LOCK, "mmap");
return MAP_FAILED; return MAP_FAILED;
} }
caddr_t ret = rec->get_address () + off; caddr_t ret = rec->get_address () + off;
syscall_printf ("%x = mmap() succeeded", ret); syscall_printf ("%x = mmap() succeeded", ret);
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap"); ReleaseResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
return ret; return ret;
} }
} }
@ -547,7 +547,7 @@ mmap64 (caddr_t addr, size_t len, int prot, int flags, int fd, __off64_t off)
if (h == INVALID_HANDLE_VALUE) if (h == INVALID_HANDLE_VALUE)
{ {
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap"); ReleaseResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
return MAP_FAILED; return MAP_FAILED;
} }
@ -570,7 +570,7 @@ mmap64 (caddr_t addr, size_t len, int prot, int flags, int fd, __off64_t off)
fh->munmap (h, base, gran_len); fh->munmap (h, base, gran_len);
set_errno (ENOMEM); set_errno (ENOMEM);
syscall_printf ("-1 = mmap(): ENOMEM"); syscall_printf ("-1 = mmap(): ENOMEM");
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap"); ReleaseResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
return MAP_FAILED; return MAP_FAILED;
} }
l = mmapped_areas->add_list (l, fd); l = mmapped_areas->add_list (l, fd);
@ -584,12 +584,12 @@ mmap64 (caddr_t addr, size_t len, int prot, int flags, int fd, __off64_t off)
l->erase (); l->erase ();
set_errno (ENOMEM); set_errno (ENOMEM);
syscall_printf ("-1 = mmap(): ENOMEM"); syscall_printf ("-1 = mmap(): ENOMEM");
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap"); ReleaseResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
return MAP_FAILED; return MAP_FAILED;
} }
caddr_t ret = rec->get_address () + off; caddr_t ret = rec->get_address () + off;
syscall_printf ("%x = mmap() succeeded", ret); syscall_printf ("%x = mmap() succeeded", ret);
ReleaseResourceLock(LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap"); ReleaseResourceLock (LOCK_MMAP_LIST, READ_LOCK | WRITE_LOCK, "mmap");
return ret; return ret;
} }
@ -617,13 +617,13 @@ munmap (caddr_t addr, size_t len)
return -1; return -1;
} }
SetResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "munmap"); SetResourceLock (LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "munmap");
/* Check if a mmap'ed area was ever created */ /* Check if a mmap'ed area was ever created */
if (mmapped_areas == NULL) if (mmapped_areas == NULL)
{ {
syscall_printf ("-1 = munmap(): mmapped_areas == NULL"); syscall_printf ("-1 = munmap(): mmapped_areas == NULL");
set_errno (EINVAL); set_errno (EINVAL);
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "munmap"); ReleaseResourceLock (LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "munmap");
return -1; return -1;
} }
@ -649,7 +649,7 @@ munmap (caddr_t addr, size_t len)
l->erase (li); l->erase (li);
} }
syscall_printf ("0 = munmap(): %x", addr); syscall_printf ("0 = munmap(): %x", addr);
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "munmap"); ReleaseResourceLock (LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "munmap");
return 0; return 0;
} }
} }
@ -658,7 +658,7 @@ munmap (caddr_t addr, size_t len)
set_errno (EINVAL); set_errno (EINVAL);
syscall_printf ("-1 = munmap(): EINVAL"); syscall_printf ("-1 = munmap(): EINVAL");
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "munmap"); ReleaseResourceLock (LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "munmap");
return -1; return -1;
} }
@ -680,13 +680,13 @@ msync (caddr_t addr, size_t len, int flags)
return -1; return -1;
} }
SetResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync"); SetResourceLock (LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync");
/* Check if a mmap'ed area was ever created */ /* Check if a mmap'ed area was ever created */
if (mmapped_areas == NULL) if (mmapped_areas == NULL)
{ {
syscall_printf ("-1 = msync(): mmapped_areas == NULL"); syscall_printf ("-1 = msync(): mmapped_areas == NULL");
set_errno (EINVAL); set_errno (EINVAL);
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync"); ReleaseResourceLock (LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync");
return -1; return -1;
} }
@ -716,7 +716,7 @@ msync (caddr_t addr, size_t len, int flags)
else else
syscall_printf ("0 = msync()"); syscall_printf ("0 = msync()");
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync"); ReleaseResourceLock (LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync");
return 0; return 0;
} }
} }
@ -728,7 +728,7 @@ invalid_address_range:
set_errno (ENOMEM); set_errno (ENOMEM);
syscall_printf ("-1 = msync(): ENOMEM"); syscall_printf ("-1 = msync(): ENOMEM");
ReleaseResourceLock(LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync"); ReleaseResourceLock (LOCK_MMAP_LIST, WRITE_LOCK | READ_LOCK, "msync");
return -1; return -1;
} }
@ -807,7 +807,7 @@ fhandler_disk_file::mmap (caddr_t *addr, size_t len, DWORD access,
debug_printf ("named sharing"); debug_printf ("named sharing");
if (!(h = OpenFileMapping (access, TRUE, namebuf))) if (!(h = OpenFileMapping (access, TRUE, namebuf)))
h = CreateFileMapping (get_handle(), &sec_none, protect, 0, 0, namebuf); h = CreateFileMapping (get_handle (), &sec_none, protect, 0, 0, namebuf);
} }
else else
h = CreateFileMapping (get_handle (), &sec_none, protect, 0, h = CreateFileMapping (get_handle (), &sec_none, protect, 0,

View File

@ -70,18 +70,18 @@ wsock_event::wait (int socket, LPDWORD flags)
int ret = -1; int ret = -1;
WSAEVENT ev[2] = { event, signal_arrived }; WSAEVENT ev[2] = { event, signal_arrived };
switch (WSAWaitForMultipleEvents(2, ev, FALSE, WSA_INFINITE, FALSE)) switch (WSAWaitForMultipleEvents (2, ev, FALSE, WSA_INFINITE, FALSE))
{ {
case WSA_WAIT_EVENT_0: case WSA_WAIT_EVENT_0:
DWORD len; DWORD len;
if (WSAGetOverlappedResult(socket, &ovr, &len, FALSE, flags)) if (WSAGetOverlappedResult (socket, &ovr, &len, FALSE, flags))
ret = (int) len; ret = (int) len;
break; break;
case WSA_WAIT_EVENT_0 + 1: case WSA_WAIT_EVENT_0 + 1:
if (!CancelIo ((HANDLE)socket)) if (!CancelIo ((HANDLE)socket))
{ {
debug_printf ("CancelIo() %E, fallback to blocking io"); debug_printf ("CancelIo() %E, fallback to blocking io");
WSAGetOverlappedResult(socket, &ovr, &len, TRUE, flags); WSAGetOverlappedResult (socket, &ovr, &len, TRUE, flags);
} }
else else
WSASetLastError (WSAEINTR); WSASetLastError (WSAEINTR);
@ -417,9 +417,9 @@ dup_addr_list (char **src, unsigned int size)
return NULL; return NULL;
while (cnt-- > 0) while (cnt-- > 0)
{ {
if (!(dst[cnt] = (char *) malloc(size))) if (!(dst[cnt] = (char *) malloc (size)))
return NULL; return NULL;
memcpy(dst[cnt], src[cnt], size); memcpy (dst[cnt], src[cnt], size);
} }
return dst; return dst;
} }
@ -1229,12 +1229,12 @@ get_2k_ifconf (struct ifconf *ifc, int what)
struct sockaddr_in *sa = NULL; struct sockaddr_in *sa = NULL;
struct sockaddr *so = NULL; struct sockaddr *so = NULL;
if (GetIfTable(NULL, &siz_if_table, TRUE) == ERROR_INSUFFICIENT_BUFFER && if (GetIfTable (NULL, &siz_if_table, TRUE) == ERROR_INSUFFICIENT_BUFFER &&
GetIpAddrTable(NULL, &siz_ip_table, TRUE) == ERROR_INSUFFICIENT_BUFFER && GetIpAddrTable (NULL, &siz_ip_table, TRUE) == ERROR_INSUFFICIENT_BUFFER &&
(ift = (PMIB_IFTABLE) alloca (siz_if_table)) && (ift = (PMIB_IFTABLE) alloca (siz_if_table)) &&
(ipt = (PMIB_IPADDRTABLE) alloca (siz_ip_table)) && (ipt = (PMIB_IPADDRTABLE) alloca (siz_ip_table)) &&
!GetIfTable(ift, &siz_if_table, TRUE) && !GetIfTable (ift, &siz_if_table, TRUE) &&
!GetIpAddrTable(ipt, &siz_ip_table, TRUE)) !GetIpAddrTable (ipt, &siz_ip_table, TRUE))
{ {
/* Iterate over all known interfaces */ /* Iterate over all known interfaces */
for (if_cnt = 0; if_cnt < ift->dwNumEntries; ++if_cnt) for (if_cnt = 0; if_cnt < ift->dwNumEntries; ++if_cnt)
@ -1903,7 +1903,7 @@ socketpair (int family, int type, int protocol, int *sb)
cygheap_fdnew sb0; cygheap_fdnew sb0;
fhandler_socket *fh; fhandler_socket *fh;
if (__check_null_invalid_struct_errno (sb, 2 * sizeof(int))) if (__check_null_invalid_struct_errno (sb, 2 * sizeof (int)))
return -1; return -1;
if (family != AF_LOCAL && family != AF_INET) if (family != AF_LOCAL && family != AF_INET)

View File

@ -153,7 +153,7 @@ read_etc_passwd ()
if (strlen (line)) if (strlen (line))
add_pwd_line (line); add_pwd_line (line);
passwd_state.set_last_modified (pr.get_fhandle(), pr.get_fname ()); passwd_state.set_last_modified (pr.get_fhandle (), pr.get_fname ());
passwd_state = loaded; passwd_state = loaded;
pr.close (); pr.close ();
debug_printf ("Read /etc/passwd, %d lines", curr_lines); debug_printf ("Read /etc/passwd, %d lines", curr_lines);
@ -179,9 +179,9 @@ read_etc_passwd ()
snprintf (linebuf, sizeof (linebuf), snprintf (linebuf, sizeof (linebuf),
"%s::%lu:%lu:%s:%s:/bin/sh", "%s::%lu:%lu:%s:%s:/bin/sh",
cygheap->user.name (), cygheap->user.name (),
*GetSidSubAuthority(tu, *GetSidSubAuthority (tu,
*GetSidSubAuthorityCount(tu) - 1), *GetSidSubAuthorityCount(tu) - 1),
*GetSidSubAuthority(tg, *GetSidSubAuthority (tg,
*GetSidSubAuthorityCount(tg) - 1), *GetSidSubAuthorityCount(tg) - 1),
tu.string (strbuf), getenv ("HOME") ?: "/"); tu.string (strbuf), getenv ("HOME") ?: "/");
debug_printf ("Emulating /etc/passwd: %s", linebuf); debug_printf ("Emulating /etc/passwd: %s", linebuf);
@ -246,7 +246,7 @@ getpwuid32 (__uid32_t uid)
if (passwd_state <= initializing) if (passwd_state <= initializing)
read_etc_passwd (); read_etc_passwd ();
pthread_testcancel(); pthread_testcancel ();
return search_for (uid, 0); return search_for (uid, 0);
} }
@ -268,7 +268,7 @@ getpwuid_r32 (__uid32_t uid, struct passwd *pwd, char *buffer, size_t bufsize, s
if (passwd_state <= initializing) if (passwd_state <= initializing)
read_etc_passwd (); read_etc_passwd ();
pthread_testcancel(); pthread_testcancel ();
struct passwd *temppw = search_for (uid, 0); struct passwd *temppw = search_for (uid, 0);
@ -311,7 +311,7 @@ getpwnam (const char *name)
if (passwd_state <= initializing) if (passwd_state <= initializing)
read_etc_passwd (); read_etc_passwd ();
pthread_testcancel(); pthread_testcancel ();
return search_for (0, name); return search_for (0, name);
} }
@ -332,7 +332,7 @@ getpwnam_r (const char *nam, struct passwd *pwd, char *buffer, size_t bufsize, s
if (passwd_state <= initializing) if (passwd_state <= initializing)
read_etc_passwd (); read_etc_passwd ();
pthread_testcancel(); pthread_testcancel ();
struct passwd *temppw = search_for (0, nam); struct passwd *temppw = search_for (0, nam);

View File

@ -131,8 +131,8 @@ create_shortcut_header (void)
(path_prefix_p (mount_table->cygdrive, (path), mount_table->cygdrive_len)) (path_prefix_p (mount_table->cygdrive, (path), mount_table->cygdrive_len))
#define iscygdrive_device(path) \ #define iscygdrive_device(path) \
(isalpha(path[mount_table->cygdrive_len]) && \ (isalpha (path[mount_table->cygdrive_len]) && \
(isdirsep(path[mount_table->cygdrive_len + 1]) || \ (isdirsep (path[mount_table->cygdrive_len + 1]) || \
!path[mount_table->cygdrive_len + 1])) !path[mount_table->cygdrive_len + 1]))
#define isproc(path) \ #define isproc(path) \
@ -843,7 +843,7 @@ static __inline int
digits (const char *name) digits (const char *name)
{ {
char *p; char *p;
int n = strtol(name, &p, 10); int n = strtol (name, &p, 10);
return p > name && !*p ? n : -1; return p > name && !*p ? n : -1;
} }
@ -1985,7 +1985,7 @@ mount_info::read_cygdrive_info_from_registry ()
error. */ error. */
cygdrive_flags = r.get_int (CYGWIN_INFO_CYGDRIVE_FLAGS, MOUNT_CYGDRIVE); cygdrive_flags = r.get_int (CYGWIN_INFO_CYGDRIVE_FLAGS, MOUNT_CYGDRIVE);
slashify (cygdrive, cygdrive, 1); slashify (cygdrive, cygdrive, 1);
cygdrive_len = strlen(cygdrive); cygdrive_len = strlen (cygdrive);
} }
} }
@ -2043,7 +2043,7 @@ mount_info::write_cygdrive_info_to_registry (const char *cygdrive_prefix, unsign
{ {
slashify (cygdrive_prefix, mount_table->cygdrive, 1); slashify (cygdrive_prefix, mount_table->cygdrive, 1);
mount_table->cygdrive_flags = flags; mount_table->cygdrive_flags = flags;
mount_table->cygdrive_len = strlen(mount_table->cygdrive); mount_table->cygdrive_len = strlen (mount_table->cygdrive);
} }
return 0; return 0;
@ -2334,7 +2334,7 @@ static mntent *
fillout_mntent (const char *native_path, const char *posix_path, unsigned flags) fillout_mntent (const char *native_path, const char *posix_path, unsigned flags)
{ {
#ifdef _MT_SAFE #ifdef _MT_SAFE
struct mntent &ret=_reent_winsup()->mntbuf; struct mntent &ret=_reent_winsup ()->mntbuf;
#else #else
static NO_COPY struct mntent ret; static NO_COPY struct mntent ret;
#endif #endif
@ -3220,7 +3220,7 @@ hashit:
\a\b\. but allow a single \ if that's all there is. */ \a\b\. but allow a single \ if that's all there is. */
do do
{ {
int ch = cyg_tolower(*name); int ch = cyg_tolower (*name);
hash = (hash << 5) - hash + ch; hash = (hash << 5) - hash + ch;
} }
while (*++name != '\0' && while (*++name != '\0' &&
@ -3311,7 +3311,7 @@ chdir (const char *in_dir)
path.get_win32 ()[3] = '\0'; path.get_win32 ()[3] = '\0';
} }
int res; int res;
int devn = path.get_devn(); int devn = path.get_devn ();
if (!isvirtual_dev (devn)) if (!isvirtual_dev (devn))
res = SetCurrentDirectory (native_dir) ? 0 : -1; res = SetCurrentDirectory (native_dir) ? 0 : -1;
else if (!path.exists ()) else if (!path.exists ())
@ -3725,7 +3725,7 @@ cwdstuff::get (char *buf, int need_posix, int with_chroot, unsigned ulen)
else else
tocopy = posix; tocopy = posix;
debug_printf("posix %s", posix); debug_printf ("posix %s", posix);
if (strlen (tocopy) >= ulen) if (strlen (tocopy) >= ulen)
{ {
set_errno (ERANGE); set_errno (ERANGE);

View File

@ -61,8 +61,7 @@ set_myself (pid_t pid, HANDLE h)
myself->process_state |= PID_IN_USE; myself->process_state |= PID_IN_USE;
myself->start_time = time (NULL); /* Register our starting time. */ myself->start_time = time (NULL); /* Register our starting time. */
(void) GetModuleFileName (NULL, myself->progname, (void) GetModuleFileName (NULL, myself->progname, sizeof (myself->progname));
sizeof(myself->progname));
if (!strace.active) if (!strace.active)
strace.hello (); strace.hello ();
return; return;

View File

@ -35,7 +35,7 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout)
if (fds[i].fd > max_fd) if (fds[i].fd > max_fd)
max_fd = fds[i].fd; max_fd = fds[i].fd;
size_t fds_size = howmany(max_fd + 1, NFDBITS) * sizeof (fd_mask); size_t fds_size = howmany (max_fd + 1, NFDBITS) * sizeof (fd_mask);
read_fds = (fd_set *) alloca (fds_size); read_fds = (fd_set *) alloca (fds_size);
write_fds = (fd_set *) alloca (fds_size); write_fds = (fd_set *) alloca (fds_size);
@ -55,7 +55,7 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout)
for (unsigned int i = 0; i < nfds; ++i) for (unsigned int i = 0; i < nfds; ++i)
{ {
fds[i].revents = 0; fds[i].revents = 0;
if (!cygheap->fdtab.not_open(fds[i].fd)) if (!cygheap->fdtab.not_open (fds[i].fd))
{ {
if (fds[i].events & POLLIN) if (fds[i].events & POLLIN)
FD_SET(fds[i].fd, read_fds); FD_SET(fds[i].fd, read_fds);
@ -81,7 +81,7 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout)
{ {
if (fds[i].fd >= 0) if (fds[i].fd >= 0)
{ {
if (cygheap->fdtab.not_open(fds[i].fd)) if (cygheap->fdtab.not_open (fds[i].fd))
fds[i].revents = POLLHUP; fds[i].revents = POLLHUP;
else else
{ {
@ -93,7 +93,7 @@ poll (struct pollfd *fds, unsigned int nfds, int timeout)
if (!sock) if (!sock)
fds[i].revents |= POLLIN; fds[i].revents |= POLLIN;
else else
switch (sock->recvfrom (peek, sizeof(peek), MSG_PEEK, switch (sock->recvfrom (peek, sizeof (peek), MSG_PEEK,
NULL, NULL)) NULL, NULL))
{ {
case -1: /* Something weird happened */ case -1: /* Something weird happened */

View File

@ -31,9 +31,9 @@ pthread_once (pthread_once_t * once_control, void (*init_routine) (void))
} }
int int
pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)) pthread_atfork (void (*prepare)(void), void (*parent)(void), void (*child)(void))
{ {
return pthread::atfork(prepare, parent, child); return pthread::atfork (prepare, parent, child);
} }
int int
@ -141,7 +141,7 @@ pthread_attr_getstackaddr (const pthread_attr_t * attr, void **stackaddr)
void void
pthread_exit (void *value_ptr) pthread_exit (void *value_ptr)
{ {
return pthread::self()->exit (value_ptr); return pthread::self ()->exit (value_ptr);
} }
int int
@ -176,7 +176,7 @@ pthread_getsequence_np (pthread_t * thread)
{ {
if (!pthread::isGoodObject (thread)) if (!pthread::isGoodObject (thread))
return EINVAL; return EINVAL;
return (*thread)->getsequence_np(); return (*thread)->getsequence_np ();
} }
/* Thread SpecificData */ /* Thread SpecificData */
@ -221,7 +221,7 @@ pthread_sigmask (int operation, const sigset_t * set, sigset_t * old_set)
pthread_t pthread_self () pthread_t pthread_self ()
{ {
return pthread::self(); return pthread::self ();
} }
int int
@ -431,31 +431,31 @@ pthread_cancel (pthread_t thread)
int int
pthread_setcancelstate (int state, int *oldstate) pthread_setcancelstate (int state, int *oldstate)
{ {
return pthread::self()->setcancelstate (state, oldstate); return pthread::self ()->setcancelstate (state, oldstate);
} }
int int
pthread_setcanceltype (int type, int *oldtype) pthread_setcanceltype (int type, int *oldtype)
{ {
return pthread::self()->setcanceltype (type, oldtype); return pthread::self ()->setcanceltype (type, oldtype);
} }
void void
pthread_testcancel (void) pthread_testcancel (void)
{ {
pthread::self()->testcancel (); pthread::self ()->testcancel ();
} }
void void
_pthread_cleanup_push (__pthread_cleanup_handler *handler) _pthread_cleanup_push (__pthread_cleanup_handler *handler)
{ {
pthread::self()->push_cleanup_handler (handler); pthread::self ()->push_cleanup_handler (handler);
} }
void void
_pthread_cleanup_pop (int execute) _pthread_cleanup_pop (int execute)
{ {
pthread::self()->pop_cleanup_handler (execute); pthread::self ()->pop_cleanup_handler (execute);
} }
/* Semaphores */ /* Semaphores */

View File

@ -76,7 +76,7 @@ fill_rusage (struct rusage *r, HANDLE h)
PROCESS_MEMORY_COUNTERS pmc; PROCESS_MEMORY_COUNTERS pmc;
memset (&pmc, 0, sizeof (pmc)); memset (&pmc, 0, sizeof (pmc));
if (GetProcessMemoryInfo( h, &pmc, sizeof (pmc))) if (GetProcessMemoryInfo (h, &pmc, sizeof (pmc)))
{ {
r->ru_maxrss += (long) (pmc.WorkingSetSize /1024); r->ru_maxrss += (long) (pmc.WorkingSetSize /1024);
r->ru_majflt += pmc.PageFaultCount; r->ru_majflt += pmc.PageFaultCount;
@ -165,7 +165,7 @@ setrlimit (int resource, const struct rlimit *rlp)
// Check if the request is to actually change the resource settings. // Check if the request is to actually change the resource settings.
// If it does not result in a change, take no action and do not // If it does not result in a change, take no action and do not
// fail. // fail.
if (getrlimit(resource, &oldlimits) < 0) if (getrlimit (resource, &oldlimits) < 0)
return -1; return -1;
if (oldlimits.rlim_cur == rlp->rlim_cur && if (oldlimits.rlim_cur == rlp->rlim_cur &&

View File

@ -86,13 +86,13 @@ setacl (const char *file, int nentries, __aclent16_t *aclbufp)
__seterrno (); __seterrno ();
return -1; return -1;
} }
if (!SetSecurityDescriptorOwner(&sd, owner, FALSE)) if (!SetSecurityDescriptorOwner (&sd, owner, FALSE))
{ {
__seterrno (); __seterrno ();
return -1; return -1;
} }
if (group if (group
&& !SetSecurityDescriptorGroup(&sd, group, FALSE)) && !SetSecurityDescriptorGroup (&sd, group, FALSE))
{ {
__seterrno (); __seterrno ();
return -1; return -1;
@ -538,7 +538,7 @@ acl_worker (const char *path, int cmd, int nentries, __aclent16_t *aclbufp,
switch (cmd) switch (cmd)
{ {
case SETACL: case SETACL:
if (!aclsort(nentries, 0, aclbufp)) if (!aclsort (nentries, 0, aclbufp))
return setacl (real_path.get_win32 (), return setacl (real_path.get_win32 (),
nentries, aclbufp); nentries, aclbufp);
break; break;
@ -732,9 +732,9 @@ extern "C"
int acecmp (const void *a1, const void *a2) int acecmp (const void *a1, const void *a2)
{ {
#define ace(i) ((const __aclent16_t *) a##i) #define ace(i) ((const __aclent16_t *) a##i)
int ret = ace(1)->a_type - ace(2)->a_type; int ret = ace (1)->a_type - ace (2)->a_type;
if (!ret) if (!ret)
ret = ace(1)->a_id - ace(2)->a_id; ret = ace (1)->a_id - ace (2)->a_id;
return ret; return ret;
#undef ace #undef ace
} }
@ -750,7 +750,7 @@ aclsort (int nentries, int, __aclent16_t *aclbufp)
set_errno (EINVAL); set_errno (EINVAL);
return -1; return -1;
} }
qsort((void *) aclbufp, nentries, sizeof (__aclent16_t), acecmp); qsort ((void *) aclbufp, nentries, sizeof (__aclent16_t), acecmp);
return 0; return 0;
} }
@ -791,7 +791,7 @@ acltomode (__aclent16_t *aclbufp, int nentries, mode_t *modep)
extern "C" extern "C"
int int
aclfrommode(__aclent16_t *aclbufp, int nentries, mode_t *modep) aclfrommode (__aclent16_t *aclbufp, int nentries, mode_t *modep)
{ {
int pos; int pos;

View File

@ -69,11 +69,11 @@ cygsid::string (char *nsidstr) const
if (!psid || !nsidstr) if (!psid || !nsidstr)
return NULL; return NULL;
strcpy (nsidstr, "S-1-"); strcpy (nsidstr, "S-1-");
__small_sprintf(t, "%u", GetSidIdentifierAuthority (psid)->Value[5]); __small_sprintf (t, "%u", GetSidIdentifierAuthority (psid)->Value[5]);
strcat (nsidstr, t); strcat (nsidstr, t);
for (i = 0; i < *GetSidSubAuthorityCount (psid); ++i) for (i = 0; i < *GetSidSubAuthorityCount (psid); ++i)
{ {
__small_sprintf(t, "-%lu", *GetSidSubAuthority (psid, i)); __small_sprintf (t, "-%lu", *GetSidSubAuthority (psid, i));
strcat (nsidstr, t); strcat (nsidstr, t);
} }
return nsidstr; return nsidstr;
@ -90,7 +90,7 @@ cygsid::get_sid (DWORD s, DWORD cnt, DWORD *r)
return NULL; return NULL;
} }
set (); set ();
InitializeSid(psid, &sid_auth[s], cnt); InitializeSid (psid, &sid_auth[s], cnt);
for (i = 0; i < cnt; ++i) for (i = 0; i < cnt; ++i)
memcpy ((char *) psid + 8 + sizeof (DWORD) * i, &r[i], sizeof (DWORD)); memcpy ((char *) psid + 8 + sizeof (DWORD) * i, &r[i], sizeof (DWORD));
return psid; return psid;
@ -198,7 +198,7 @@ cygsid::get_id (BOOL search_grp, int *type)
} }
/* We use the RID as default UID/GID */ /* We use the RID as default UID/GID */
int id = *GetSidSubAuthority(psid, *GetSidSubAuthorityCount(psid) - 1); int id = *GetSidSubAuthority (psid, *GetSidSubAuthorityCount (psid) - 1);
/* /*
* The RID maybe -1 if accountname == computername. * The RID maybe -1 if accountname == computername.
@ -325,13 +325,13 @@ lookup_name (const char *name, const char *logsrv, PSID ret_sid)
if (LookupAccountName (NULL, domuser, sid, SIDLEN, dom, DOMLEN,&acc_type)) if (LookupAccountName (NULL, domuser, sid, SIDLEN, dom, DOMLEN,&acc_type))
goto got_it; goto got_it;
} }
debug_printf ("LookupAccountName(%s) %E", name); debug_printf ("LookupAccountName (%s) %E", name);
__seterrno (); __seterrno ();
return FALSE; return FALSE;
got_it: got_it:
debug_printf ("sid : [%d]", *GetSidSubAuthority((PSID) sid, debug_printf ("sid : [%d]", *GetSidSubAuthority ((PSID) sid,
*GetSidSubAuthorityCount((PSID) sid) - 1)); *GetSidSubAuthorityCount ((PSID) sid) - 1));
if (ret_sid) if (ret_sid)
memcpy (ret_sid, sid, sidlen); memcpy (ret_sid, sid, sidlen);
@ -376,7 +376,7 @@ set_process_privilege (const char *privilege, BOOL enable)
goto out; goto out;
} }
/* AdjustTokenPrivileges returns TRUE even if the privilege could not /* AdjustTokenPrivileges returns TRUE even if the privilege could not
be enabled. GetLastError() returns an correct error code, though. */ be enabled. GetLastError () returns an correct error code, though. */
if (enable && GetLastError () == ERROR_NOT_ALL_ASSIGNED) if (enable && GetLastError () == ERROR_NOT_ALL_ASSIGNED)
{ {
debug_printf ("Privilege %s couldn't be assigned", privilege); debug_printf ("Privilege %s couldn't be assigned", privilege);

View File

@ -1206,8 +1206,8 @@ write_sd (const char *file, PSECURITY_DESCRIPTOR sd_buf, DWORD sd_size)
} }
static void static void
get_attribute_from_acl(int * attribute, PACL acl, PSID owner_sid, get_attribute_from_acl (int * attribute, PACL acl, PSID owner_sid,
PSID group_sid, BOOL grp_member) PSID group_sid, BOOL grp_member)
{ {
ACCESS_ALLOWED_ACE *ace; ACCESS_ALLOWED_ACE *ace;
int allow = 0; int allow = 0;
@ -1387,7 +1387,7 @@ get_file_attribute (int use_ntsec, const char *file,
if (allow_ntea) if (allow_ntea)
{ {
int oatt = *attribute; int oatt = *attribute;
res = NTReadEA (file, ".UNIXATTR", (char *)attribute, sizeof(*attribute)); res = NTReadEA (file, ".UNIXATTR", (char *)attribute, sizeof (*attribute));
*attribute |= oatt; *attribute |= oatt;
} }
else else

View File

@ -71,7 +71,7 @@ typedef long fd_mask;
#define NULL_fd_set ((fd_set *) NULL) #define NULL_fd_set ((fd_set *) NULL)
#define sizeof_fd_set(n) \ #define sizeof_fd_set(n) \
((unsigned) (NULL_fd_set->fds_bits + unix_howmany((n), UNIX_NFDBITS))) ((unsigned) (NULL_fd_set->fds_bits + unix_howmany ((n), UNIX_NFDBITS)))
#define UNIX_FD_SET(n, p) \ #define UNIX_FD_SET(n, p) \
((p)->fds_bits[(n)/UNIX_NFDBITS] |= (1L << ((n) % UNIX_NFDBITS))) ((p)->fds_bits[(n)/UNIX_NFDBITS] |= (1L << ((n) % UNIX_NFDBITS)))
#define UNIX_FD_CLR(n, p) \ #define UNIX_FD_CLR(n, p) \
@ -1290,7 +1290,7 @@ start_thread_socket (select_record *me, select_stuff *stuff)
int tmp = 1; int tmp = 1;
(void) setsockopt (si->exitsock, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, sizeof (tmp)); (void) setsockopt (si->exitsock, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp, sizeof (tmp));
int sin_len = sizeof(si->sin); int sin_len = sizeof (si->sin);
memset (&si->sin, 0, sizeof (si->sin)); memset (&si->sin, 0, sizeof (si->sin));
si->sin.sin_family = AF_INET; si->sin.sin_family = AF_INET;
si->sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK); si->sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
@ -1340,8 +1340,8 @@ socket_cleanup (select_record *, select_stuff *stuff)
/* Set LINGER with 0 timeout for hard close */ /* Set LINGER with 0 timeout for hard close */
struct linger tmp = {1, 0}; /* On, 0 delay */ struct linger tmp = {1, 0}; /* On, 0 delay */
(void) setsockopt (s, SOL_SOCKET, SO_LINGER, (char *)&tmp, sizeof(tmp)); (void) setsockopt (s, SOL_SOCKET, SO_LINGER, (char *)&tmp, sizeof (tmp));
(void) setsockopt (si->exitsock, SOL_SOCKET, SO_LINGER, (char *)&tmp, sizeof(tmp)); (void) setsockopt (si->exitsock, SOL_SOCKET, SO_LINGER, (char *)&tmp, sizeof (tmp));
/* Connecting to si->exitsock will cause any executing select to wake /* Connecting to si->exitsock will cause any executing select to wake
up. When this happens then the exitsock condition will cause the up. When this happens then the exitsock condition will cause the

View File

@ -461,7 +461,7 @@ proc_terminate (void)
hwait_subproc->detach (); hwait_subproc->detach ();
hwait_subproc = NULL; hwait_subproc = NULL;
sync_proc_subproc->acquire(WPSP); sync_proc_subproc->acquire (WPSP);
(void) proc_subproc (PROC_CLEARWAIT, 1); (void) proc_subproc (PROC_CLEARWAIT, 1);
/* Clean out zombie processes from the pid list. */ /* Clean out zombie processes from the pid list. */
@ -474,7 +474,7 @@ proc_terminate (void)
ForceCloseHandle1 (zombies[i]->pid_handle, pid_handle); ForceCloseHandle1 (zombies[i]->pid_handle, pid_handle);
} }
zombies[i]->process_state = PID_EXITED; /* CGF FIXME - still needed? */ zombies[i]->process_state = PID_EXITED; /* CGF FIXME - still needed? */
zombies[i].release(); // FIXME: this breaks older gccs for some reason zombies[i].release (); // FIXME: this breaks older gccs for some reason
} }
/* Disassociate my subprocesses */ /* Disassociate my subprocesses */
@ -564,7 +564,7 @@ sigproc_init ()
/* local event signaled when main thread has been dispatched /* local event signaled when main thread has been dispatched
to a signal handler function. */ to a signal handler function. */
signal_arrived = CreateEvent(&sec_none_nih, TRUE, FALSE, NULL); signal_arrived = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
ProtectHandle (signal_arrived); ProtectHandle (signal_arrived);
hwait_sig = new cygthread (wait_sig, cygself, "sig"); hwait_sig = new cygthread (wait_sig, cygself, "sig");

View File

@ -21,14 +21,14 @@ details. */
#include "cygthread.h" #include "cygthread.h"
#define PROTECT(x) x[sizeof(x)-1] = 0 #define PROTECT(x) x[sizeof(x)-1] = 0
#define CHECK(x) if (x[sizeof(x)-1] != 0) { small_printf("array bound exceeded %d\n", __LINE__); ExitProcess(1); } #define CHECK(x) if (x[sizeof(x)-1] != 0) { small_printf ("array bound exceeded %d\n", __LINE__); ExitProcess (1); }
class strace NO_COPY strace; class strace NO_COPY strace;
#ifndef NOSTRACE #ifndef NOSTRACE
void void
strace::hello() strace::hello ()
{ {
char buf[30]; char buf[30];
@ -196,11 +196,11 @@ strace::vprntf (unsigned category, const char *func, const char *fmt, va_list ap
int count; int count;
char buf[10000]; char buf[10000];
PROTECT(buf); PROTECT (buf);
SetLastError (err); SetLastError (err);
count = this->vsprntf (buf, func, fmt, ap); count = this->vsprntf (buf, func, fmt, ap);
CHECK(buf); CHECK (buf);
if (category & _STRACE_SYSTEM) if (category & _STRACE_SYSTEM)
{ {
DWORD done; DWORD done;

View File

@ -783,7 +783,7 @@ chown_worker (const char *name, unsigned fmode, __uid32_t uid, __gid32_t gid)
uid = old_uid; uid = old_uid;
if (gid == ILLEGAL_GID) if (gid == ILLEGAL_GID)
gid = old_gid; gid = old_gid;
if (win32_path.isdir()) if (win32_path.isdir ())
attrib |= S_IFDIR; attrib |= S_IFDIR;
res = set_file_attribute (win32_path.has_acls (), win32_path, uid, res = set_file_attribute (win32_path.has_acls (), win32_path, uid,
gid, attrib); gid, attrib);
@ -1969,7 +1969,7 @@ seteuid32 (__uid32_t uid)
sav_token = cygheap->user.token; sav_token = cygheap->user.token;
sav_impersonated = cygheap->user.impersonated; sav_impersonated = cygheap->user.impersonated;
RevertToSelf(); RevertToSelf ();
if (!OpenProcessToken (hMainProc, TOKEN_QUERY | TOKEN_ADJUST_DEFAULT, &ptok)) if (!OpenProcessToken (hMainProc, TOKEN_QUERY | TOKEN_ADJUST_DEFAULT, &ptok))
{ {
__seterrno (); __seterrno ();
@ -1979,7 +1979,7 @@ seteuid32 (__uid32_t uid)
Currently we do not try to differentiate between Currently we do not try to differentiate between
internal tokens and others */ internal tokens and others */
process_ok = verify_token (ptok, usersid, groups); process_ok = verify_token (ptok, usersid, groups);
debug_printf("Process token %sverified", process_ok ? "" : "not "); debug_printf ("Process token %sverified", process_ok ? "" : "not ");
if (process_ok) if (process_ok)
{ {
if (cygheap->user.issetuid ()) if (cygheap->user.issetuid ())
@ -1996,7 +1996,7 @@ seteuid32 (__uid32_t uid)
/* Verify if the current tokem is suitable */ /* Verify if the current tokem is suitable */
BOOL token_ok = verify_token (cygheap->user.token, usersid, groups, BOOL token_ok = verify_token (cygheap->user.token, usersid, groups,
&sav_token_is_internal_token); &sav_token_is_internal_token);
debug_printf("Thread token %d %sverified", debug_printf ("Thread token %d %sverified",
cygheap->user.token, token_ok?"":"not "); cygheap->user.token, token_ok?"":"not ");
if (!token_ok) if (!token_ok)
cygheap->user.token = INVALID_HANDLE_VALUE; cygheap->user.token = INVALID_HANDLE_VALUE;
@ -2014,8 +2014,8 @@ seteuid32 (__uid32_t uid)
} }
/* Set process def dacl to allow access to impersonated token */ /* Set process def dacl to allow access to impersonated token */
char dacl_buf[MAX_DACL_LEN(5)]; char dacl_buf[MAX_DACL_LEN (5)];
if (usersid != (origpsid = cygheap->user.orig_sid())) psid2 = usersid; if (usersid != (origpsid = cygheap->user.orig_sid ())) psid2 = usersid;
if (sec_acl ((PACL) dacl_buf, FALSE, origpsid, psid2)) if (sec_acl ((PACL) dacl_buf, FALSE, origpsid, psid2))
{ {
TOKEN_DEFAULT_DACL tdacl; TOKEN_DEFAULT_DACL tdacl;
@ -2030,7 +2030,7 @@ seteuid32 (__uid32_t uid)
if (!process_ok && cygheap->user.token == INVALID_HANDLE_VALUE) if (!process_ok && cygheap->user.token == INVALID_HANDLE_VALUE)
{ {
/* If no impersonation token is available, try to /* If no impersonation token is available, try to
authenticate using NtCreateToken() or subauthentication. */ authenticate using NtCreateToken () or subauthentication. */
cygheap->user.token = create_token (usersid, groups, pw_new); cygheap->user.token = create_token (usersid, groups, pw_new);
if (cygheap->user.token != INVALID_HANDLE_VALUE) if (cygheap->user.token != INVALID_HANDLE_VALUE)
explicitly_created_token = TRUE; explicitly_created_token = TRUE;
@ -2059,7 +2059,7 @@ seteuid32 (__uid32_t uid)
/* Try setting primary group in token to current group */ /* Try setting primary group in token to current group */
if (!SetTokenInformation (cygheap->user.token, if (!SetTokenInformation (cygheap->user.token,
TokenPrimaryGroup, TokenPrimaryGroup,
&groups.pgsid, sizeof(cygsid))) &groups.pgsid, sizeof (cygsid)))
debug_printf ("SetTokenInformation(user.token, " debug_printf ("SetTokenInformation(user.token, "
"TokenPrimaryGroup): %E"); "TokenPrimaryGroup): %E");
} }

View File

@ -72,9 +72,9 @@ sysconf (int in)
!= STATUS_SUCCESS) != STATUS_SUCCESS)
{ {
__seterrno_from_win_error (RtlNtStatusToDosError (ret)); __seterrno_from_win_error (RtlNtStatusToDosError (ret));
debug_printf("NtQuerySystemInformation: ret = %d, " debug_printf ("NtQuerySystemInformation: ret = %d, "
"Dos(ret) = %d", "Dos(ret) = %d",
ret, RtlNtStatusToDosError (ret)); ret, RtlNtStatusToDosError (ret));
return -1; return -1;
} }
switch (in) switch (in)

View File

@ -42,11 +42,11 @@ get_win95_event_log_path ()
/* FIXME: For MT safe code these will need to be replaced */ /* FIXME: For MT safe code these will need to be replaced */
#ifdef _MT_SAFE #ifdef _MT_SAFE
#define process_ident _reent_winsup()->_process_ident #define process_ident _reent_winsup ()->_process_ident
#define process_logopt _reent_winsup()->_process_logopt #define process_logopt _reent_winsup ()->_process_logopt
#define process_facility _reent_winsup()->_process_facility #define process_facility _reent_winsup ()->_process_facility
/* Default priority logmask */ /* Default priority logmask */
#define process_logmask _reent_winsup()->_process_logmask #define process_logmask _reent_winsup ()->_process_logmask
#else #else
static char *process_ident = 0; static char *process_ident = 0;
static int process_logopt = 0; static int process_logopt = 0;
@ -303,7 +303,7 @@ syslog (int priority, const char *message, ...)
if (process_logopt & LOG_PID) if (process_logopt & LOG_PID)
{ {
if (pass.print ("Win32 Process Id = 0x%X : Cygwin Process Id = 0x%X : ", if (pass.print ("Win32 Process Id = 0x%X : Cygwin Process Id = 0x%X : ",
GetCurrentProcessId(), getpid ()) == -1) GetCurrentProcessId (), getpid ()) == -1)
return; return;
} }
@ -389,7 +389,7 @@ syslog (int priority, const char *message, ...)
HANDLE fHandle = cygheap->fdtab[fileno (fp)]->get_handle (); HANDLE fHandle = cygheap->fdtab[fileno (fp)]->get_handle ();
if (LockFile (fHandle, 0, 0, 1, 0) == FALSE) if (LockFile (fHandle, 0, 0, 1, 0) == FALSE)
{ {
debug_printf ("failed to lock file %s", get_win95_event_log_path()); debug_printf ("failed to lock file %s", get_win95_event_log_path ());
fclose (fp); fclose (fp);
return; return;
} }

View File

@ -238,14 +238,14 @@ tcsetpgrp (int fd, pid_t pgid)
extern "C" speed_t extern "C" speed_t
cfgetospeed (struct termios *tp) cfgetospeed (struct termios *tp)
{ {
return __tonew_termios(tp)->c_ospeed; return __tonew_termios (tp)->c_ospeed;
} }
/* cfgetispeed: POSIX96 7.1.3.1 */ /* cfgetispeed: POSIX96 7.1.3.1 */
extern "C" speed_t extern "C" speed_t
cfgetispeed (struct termios *tp) cfgetispeed (struct termios *tp)
{ {
return __tonew_termios(tp)->c_ispeed; return __tonew_termios (tp)->c_ispeed;
} }
/* cfsetospeed: POSIX96 7.1.3.1 */ /* cfsetospeed: POSIX96 7.1.3.1 */

View File

@ -308,7 +308,7 @@ pthread::precreate (pthread_attr *newattr)
attr.stacksize = newattr->stacksize; attr.stacksize = newattr->stacksize;
} }
if (!pthread_mutex::isGoodObject(&verifyable_mutex_obj)) if (!pthread_mutex::isGoodObject (&verifyable_mutex_obj))
{ {
thread_printf ("New thread object access mutex is not valid. this %p", thread_printf ("New thread object access mutex is not valid. this %p",
this); this);
@ -1013,7 +1013,7 @@ pthread_key::set (const void *value)
void * void *
pthread_key::get () const pthread_key::get () const
{ {
int savedError = ::GetLastError(); int savedError = ::GetLastError ();
void *result = TlsGetValue (dwTlsIndex); void *result = TlsGetValue (dwTlsIndex);
::SetLastError (savedError); ::SetLastError (savedError);
return result; return result;
@ -1038,7 +1038,7 @@ void
pthread_key::run_destructor () const pthread_key::run_destructor () const
{ {
if (destructor) if (destructor)
destructor (get()); destructor (get ());
} }
/*pshared mutexs: /*pshared mutexs:

View File

@ -96,7 +96,7 @@ settimeofday (const struct timeval *tv, const struct timezone *tz)
tz = tz; /* silence warning about unused variable */ tz = tz; /* silence warning about unused variable */
ptm = gmtime(&tv->tv_sec); ptm = gmtime (&tv->tv_sec);
st.wYear = ptm->tm_year + 1900; st.wYear = ptm->tm_year + 1900;
st.wMonth = ptm->tm_mon + 1; st.wMonth = ptm->tm_mon + 1;
st.wDayOfWeek = ptm->tm_wday; st.wDayOfWeek = ptm->tm_wday;
@ -106,7 +106,7 @@ settimeofday (const struct timeval *tv, const struct timezone *tz)
st.wSecond = ptm->tm_sec; st.wSecond = ptm->tm_sec;
st.wMilliseconds = tv->tv_usec / 1000; st.wMilliseconds = tv->tv_usec / 1000;
res = !SetSystemTime(&st); res = !SetSystemTime (&st);
syscall_printf ("%d = settimeofday (%x, %x)", res, tv, tz); syscall_printf ("%d = settimeofday (%x, %x)", res, tv, tz);
@ -118,13 +118,13 @@ extern "C" char *
timezone () timezone ()
{ {
#ifdef _MT_SAFE #ifdef _MT_SAFE
char *b=_reent_winsup()->timezone_buf; char *b=_reent_winsup ()->timezone_buf;
#else #else
static NO_COPY char b[20] = {0}; static NO_COPY char b[20] = {0};
#endif #endif
tzset(); tzset ();
__small_sprintf (b,"GMT%+d:%02d", (int) (-_timezone / 3600), (int) (abs(_timezone / 60) % 60)); __small_sprintf (b,"GMT%+d:%02d", (int) (-_timezone / 3600), (int) (abs (_timezone / 60) % 60));
return b; return b;
} }
@ -158,7 +158,7 @@ gettimeofday (struct timeval *tv, struct timezone *tz)
{ {
if (!tzflag) if (!tzflag)
{ {
tzset(); tzset ();
tzflag = true; tzflag = true;
} }
tz->tz_minuteswest = _timezone / 60; tz->tz_minuteswest = _timezone / 60;

View File

@ -118,7 +118,7 @@ uinfo_init ()
/* Real and effective uid/gid are identical on process start up. */ /* Real and effective uid/gid are identical on process start up. */
cygheap->user.orig_uid = cygheap->user.real_uid = myself->uid; cygheap->user.orig_uid = cygheap->user.real_uid = myself->uid;
cygheap->user.orig_gid = cygheap->user.real_gid = myself->gid; cygheap->user.orig_gid = cygheap->user.real_gid = myself->gid;
cygheap->user.set_orig_sid(); /* Update the original sid */ cygheap->user.set_orig_sid (); /* Update the original sid */
cygheap->user.token = INVALID_HANDLE_VALUE; /* No token present */ cygheap->user.token = INVALID_HANDLE_VALUE; /* No token present */
} }
@ -259,7 +259,7 @@ cygheap_user::ontherange (homebodies what, struct passwd *pw)
{ {
WCHAR wlogsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3]; WCHAR wlogsrv[INTERNET_MAX_HOST_NAME_LENGTH + 3];
sys_mbstowcs (wlogsrv, logsrv (), sys_mbstowcs (wlogsrv, logsrv (),
sizeof (wlogsrv) / sizeof(*wlogsrv)); sizeof (wlogsrv) / sizeof (*wlogsrv));
sys_mbstowcs (wuser, winname (), sizeof (wuser) / sizeof (*wuser)); sys_mbstowcs (wuser, winname (), sizeof (wuser) / sizeof (*wuser));
if (!(ret = NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE *)&ui))) if (!(ret = NetUserGetInfo (wlogsrv, wuser, 3,(LPBYTE *)&ui)))
{ {

View File

@ -477,14 +477,14 @@ wincapc::init ()
{ {
case 0: case 0:
os = "95"; os = "95";
if (strchr(version.szCSDVersion, 'C')) if (strchr (version.szCSDVersion, 'C'))
caps = &wincap_95osr2; caps = &wincap_95osr2;
else else
caps = &wincap_95; caps = &wincap_95;
break; break;
case 10: case 10:
os = "98"; os = "98";
if (strchr(version.szCSDVersion, 'A')) if (strchr (version.szCSDVersion, 'A'))
caps = &wincap_98se; caps = &wincap_98se;
else else
caps = &wincap_98; caps = &wincap_98;