Throughout use wincap.allocation_granularity instead of getpagesize.

Throughout use wincap.page_size instead of getsystempagesize.
	Throughout use "status" as variable name to hold NTSTATUS values.
	* fhandler_mem.cc: Check for NT_SUCCESS rather than for STATUS_SUCCESS.
	Fix debug_printf output.  Rectify long statements.  Fix comment
	formatting.
	* fhandler_proc.cc: Ditto.
	(format_proc_swaps): Drop useless test for ERROR_PROC_NOT_FOUND.
	* fhandler_process.cc: Ditto as in fhandler_mem.cc.
	(get_process_state): Rearrange allocation loop.  Use malloc/realloc.
	(get_mem_values): Fix potential NULL pointer usage.  Drop unused
	variable.
	* pinfo.cc (winpids::enum_processes): Handle low memory gracefully.
	* sec_auth.cc (get_priv_list): Drop local variable ret.
	* shared.cc (memory_init): Drop outdated call to getpagesize.
	* syscalls.cc (getsystempagesize): Remove.
	* sysconf.cc: Check for NT_SUCCESS rather than for STATUS_SUCCESS.
	(sysinfo): Constify sizeof_stodi.  Drop useless test for
	ERROR_PROC_NOT_FOUND.
	* thread.cc (pthread_getattr_np): Cast pointers to uintptr_t rather
	than to int for pointer arithmetic.
	* winsup.h (getsystempagesize): Drop declaration.
This commit is contained in:
Corinna Vinschen
2011-12-22 11:02:36 +00:00
parent 8176232ddc
commit 177dc6c7f6
14 changed files with 337 additions and 314 deletions

View File

@@ -1323,29 +1323,51 @@ winpids::enum_processes (bool winpid)
if (winpid)
{
static DWORD szprocs;
static SYSTEM_PROCESSES *procs;
static PSYSTEM_PROCESSES procs;
if (!szprocs)
procs = (SYSTEM_PROCESSES *) malloc (sizeof (*procs) + (szprocs = 200 * sizeof (*procs)));
NTSTATUS res;
for (;;)
{
res = NtQuerySystemInformation (SystemProcessesAndThreadsInformation,
procs, szprocs, NULL);
if (res == 0)
break;
if (res == STATUS_INFO_LENGTH_MISMATCH)
procs = (SYSTEM_PROCESSES *) realloc (procs, szprocs += 200 * sizeof (*procs));
else
procs = (PSYSTEM_PROCESSES)
malloc (sizeof (*procs) + (szprocs = 200 * sizeof (*procs)));
if (!procs)
{
system_printf ("error %p reading system process information", res);
system_printf ("out of memory reading system process "
"information");
return 0;
}
}
SYSTEM_PROCESSES *px = procs;
for (;;)
{
status =
NtQuerySystemInformation (SystemProcessesAndThreadsInformation,
procs, szprocs, NULL);
if (NT_SUCCESS (status))
break;
if (status == STATUS_INFO_LENGTH_MISMATCH)
{
PSYSTEM_PROCESSES new_p;
new_p = (PSYSTEM_PROCESSES)
realloc (procs, szprocs += 200 * sizeof (*procs));
if (!new_p)
{
system_printf ("out of memory reading system process "
"information");
return 0;
}
procs = new_p;
}
else
{
system_printf ("error %p reading system process information",
status);
return 0;
}
}
PSYSTEM_PROCESSES px = procs;
for (;;)
{
if (px->ProcessId)
@@ -1362,7 +1384,7 @@ winpids::enum_processes (bool winpid)
}
if (!px->NextEntryDelta)
break;
px = (SYSTEM_PROCESSES *) ((char *) px + px->NextEntryDelta);
px = (PSYSTEM_PROCESSES) ((char *) px + px->NextEntryDelta);
}
}