* registry.cc (reg_key::get_dword): Rename from get_int, use DWORD
rather than int type. Avoid compiler warning. (reg_key::set_dword): Rename from set_int, use DWORD rather than int type. Change return type to NTSTATUS. (reg_key::get_string): Change return type to NTSTATUS. (reg_key::set_string): Ditto. * registry.h: Accommodate above changes. * environ.cc (regopt): Test return value of reg_key::get_string as NTSTATUS. * sched.cc (sched_rr_get_interval): Change local int vars to DWORD. Call reg_key::get_dword instead of reg_key::get_int. * shared.cc (init_installation_root): Test return value of reg_key::get_string as NTSTATUS. (shared_info::heap_slop_size): Call reg_key::get_dword rather than reg_key::get_int. (shared_info::heap_chunk_size): Ditto. * shared_info.h (CURR_SHARED_MAGIC): Update. (class shared_info): Change heap_chunk and heap_slop to DWORD values.
This commit is contained in:
		| @@ -1,3 +1,24 @@ | ||||
| 2011-04-23  Corinna Vinschen  <corinna@vinschen.de> | ||||
|  | ||||
| 	* registry.cc (reg_key::get_dword): Rename from get_int, use DWORD | ||||
| 	rather than int type.  Avoid compiler warning. | ||||
| 	(reg_key::set_dword): Rename from set_int, use DWORD rather than int | ||||
| 	type.  Change return type to NTSTATUS. | ||||
| 	(reg_key::get_string): Change return type to NTSTATUS. | ||||
| 	(reg_key::set_string): Ditto. | ||||
| 	* registry.h: Accommodate above changes. | ||||
| 	* environ.cc (regopt): Test return value of reg_key::get_string as | ||||
| 	NTSTATUS. | ||||
| 	* sched.cc (sched_rr_get_interval): Change local int vars to DWORD. | ||||
| 	Call reg_key::get_dword instead of reg_key::get_int. | ||||
| 	* shared.cc (init_installation_root): Test return value of | ||||
| 	reg_key::get_string as NTSTATUS. | ||||
| 	(shared_info::heap_slop_size): Call reg_key::get_dword rather than | ||||
| 	reg_key::get_int. | ||||
| 	(shared_info::heap_chunk_size): Ditto. | ||||
| 	* shared_info.h (CURR_SHARED_MAGIC): Update. | ||||
| 	(class shared_info): Change heap_chunk and heap_slop to DWORD  values. | ||||
|  | ||||
| 2011-04-21  Corinna Vinschen  <corinna@vinschen.de> | ||||
|  | ||||
| 	* cygtls.cc (_cygtls::init_thread): Drop setting locals.process_logmask. | ||||
|   | ||||
| @@ -712,7 +712,8 @@ regopt (const WCHAR *name, char *buf) | ||||
|     { | ||||
|       reg_key r (i, KEY_READ, _WIDE (CYGWIN_INFO_PROGRAM_OPTIONS_NAME), NULL); | ||||
|  | ||||
|       if (r.get_string (lname.Buffer, (PWCHAR) buf, NT_MAX_PATH, L"") == ERROR_SUCCESS) | ||||
|       if (NT_SUCCESS (r.get_string (lname.Buffer, (PWCHAR) buf, | ||||
| 				    NT_MAX_PATH, L""))) | ||||
| 	{ | ||||
| 	  char *newp; | ||||
| 	  sys_wcstombs_alloc(&newp, HEAP_NOTHEAP, (PWCHAR) buf); | ||||
|   | ||||
| @@ -121,11 +121,11 @@ reg_key::build_reg (HKEY top, REGSAM access, va_list av) | ||||
|     } | ||||
| } | ||||
|  | ||||
| /* Given the current registry key, return the specific int value | ||||
| /* Given the current registry key, return the specific DWORD value | ||||
|    requested.  Return def on failure. */ | ||||
|  | ||||
| int | ||||
| reg_key::get_int (PCWSTR name, int def) | ||||
| DWORD | ||||
| reg_key::get_dword (PCWSTR name, DWORD def) | ||||
| { | ||||
|   if (key_is_invalid) | ||||
|     return def; | ||||
| @@ -142,14 +142,14 @@ reg_key::get_int (PCWSTR name, int def) | ||||
| 			    size, &rsize); | ||||
|   if (status != STATUS_SUCCESS || vbuf->Type != REG_DWORD) | ||||
|     return def; | ||||
|   DWORD dst = *(DWORD *) vbuf->Data; | ||||
|   return (int) dst; | ||||
|   DWORD *dst = (DWORD *) vbuf->Data; | ||||
|   return *dst; | ||||
| } | ||||
|  | ||||
| /* Given the current registry key, set a specific int value. */ | ||||
| /* Given the current registry key, set a specific DWORD value. */ | ||||
|  | ||||
| int | ||||
| reg_key::set_int (PCWSTR name, int val) | ||||
| NTSTATUS | ||||
| reg_key::set_dword (PCWSTR name, DWORD val) | ||||
| { | ||||
|   if (key_is_invalid) | ||||
|     return key_is_invalid; | ||||
| @@ -157,15 +157,13 @@ reg_key::set_int (PCWSTR name, int val) | ||||
|   DWORD value = (DWORD) val; | ||||
|   UNICODE_STRING uname; | ||||
|   RtlInitUnicodeString (&uname, name); | ||||
|   NTSTATUS status = NtSetValueKey (key, &uname, 0, REG_DWORD,  | ||||
| 				   &value, sizeof (value)); | ||||
|   return (int) status; | ||||
|   return NtSetValueKey (key, &uname, 0, REG_DWORD, &value, sizeof (value)); | ||||
| } | ||||
|  | ||||
| /* Given the current registry key, return the specific string value | ||||
|    requested.  Return zero on success, non-zero on failure. */ | ||||
|  | ||||
| int | ||||
| NTSTATUS | ||||
| reg_key::get_string (PCWSTR name, PWCHAR dst, size_t max, PCWSTR def) | ||||
| { | ||||
|   NTSTATUS status; | ||||
| @@ -193,12 +191,12 @@ reg_key::get_string (PCWSTR name, PWCHAR dst, size_t max, PCWSTR def) | ||||
| 	wcpncpy (dst, (PWCHAR) vbuf->Data, max); | ||||
|        | ||||
|     } | ||||
|   return (int) status; | ||||
|   return status; | ||||
| } | ||||
|  | ||||
| /* Given the current registry key, set a specific string value. */ | ||||
|  | ||||
| int | ||||
| NTSTATUS | ||||
| reg_key::set_string (PCWSTR name, PCWSTR src) | ||||
| { | ||||
|   if (key_is_invalid) | ||||
| @@ -206,9 +204,8 @@ reg_key::set_string (PCWSTR name, PCWSTR src) | ||||
|  | ||||
|   UNICODE_STRING uname; | ||||
|   RtlInitUnicodeString (&uname, name); | ||||
|   NTSTATUS status = NtSetValueKey (key, &uname, 0, REG_SZ, (PVOID) src, | ||||
|   return NtSetValueKey (key, &uname, 0, REG_SZ, (PVOID) src, | ||||
| 			(wcslen (src) + 1) * sizeof (WCHAR)); | ||||
|   return (int) status; | ||||
| } | ||||
|  | ||||
| reg_key::~reg_key () | ||||
|   | ||||
| @@ -25,13 +25,13 @@ public: | ||||
|   void *operator new (size_t, void *p) {return p;} | ||||
|   void build_reg (HKEY key, REGSAM access, va_list av); | ||||
|  | ||||
|   int error () {return key == NULL;} | ||||
|   bool error () {return key == NULL;} | ||||
|  | ||||
|   int get_int (PCWSTR, int); | ||||
|   int get_string (PCWSTR, PWCHAR, size_t, PCWSTR); | ||||
|   DWORD get_dword (PCWSTR, DWORD); | ||||
|   NTSTATUS get_string (PCWSTR, PWCHAR, size_t, PCWSTR); | ||||
|  | ||||
|   int set_int (PCWSTR, int); | ||||
|   int set_string (PCWSTR, PCWSTR); | ||||
|   NTSTATUS set_dword (PCWSTR, DWORD); | ||||
|   NTSTATUS set_string (PCWSTR, PCWSTR); | ||||
|  | ||||
|   bool created () const {return _disposition & REG_CREATED_NEW_KEY;} | ||||
|  | ||||
|   | ||||
| @@ -262,7 +262,7 @@ sched_rr_get_interval (pid_t pid, struct timespec *interval) | ||||
|  | ||||
|   HWND forwin; | ||||
|   DWORD forprocid; | ||||
|   int vfindex, slindex, qindex, prisep; | ||||
|   DWORD vfindex, slindex, qindex, prisep; | ||||
|   long nsec; | ||||
|  | ||||
|   forwin = GetForegroundWindow (); | ||||
| @@ -278,7 +278,7 @@ sched_rr_get_interval (pid_t pid, struct timespec *interval) | ||||
|       set_errno (ESRCH); | ||||
|       return -1; | ||||
|     } | ||||
|   prisep = reg.get_int (L"Win32PrioritySeparation", 2); | ||||
|   prisep = reg.get_dword (L"Win32PrioritySeparation", 2); | ||||
|   pinfo pi (pid ? pid : myself->pid); | ||||
|   if (!pi) | ||||
|     { | ||||
|   | ||||
| @@ -111,8 +111,8 @@ init_installation_root () | ||||
| 	{ | ||||
| 	  reg_key r (i, KEY_WRITE, _WIDE (CYGWIN_INFO_INSTALLATIONS_NAME), | ||||
| 		     NULL); | ||||
| 	  if (r.set_string (installation_key_buf, installation_root) | ||||
| 	      == ERROR_SUCCESS) | ||||
| 	  if (NT_SUCCESS (r.set_string (installation_key_buf, | ||||
| 					installation_root))) | ||||
| 	    break; | ||||
| 	} | ||||
|  | ||||
| @@ -450,7 +450,7 @@ shared_info::heap_slop_size () | ||||
| 	{ | ||||
| 	  reg_key reg (i, KEY_READ, NULL); | ||||
|  | ||||
| 	  if ((heap_slop = reg.get_int (L"heap_slop_in_mb", 0))) | ||||
| 	  if ((heap_slop = reg.get_dword (L"heap_slop_in_mb", 0))) | ||||
| 	    break; | ||||
| 	  heap_slop = wincap.heapslop (); | ||||
| 	} | ||||
| @@ -476,7 +476,7 @@ shared_info::heap_chunk_size () | ||||
| 	  /* FIXME: We should not be restricted to a fixed size heap no matter | ||||
| 	     what the fixed size is. */ | ||||
|  | ||||
| 	  if ((heap_chunk = reg.get_int (L"heap_chunk_in_mb", 0))) | ||||
| 	  if ((heap_chunk = reg.get_dword (L"heap_chunk_in_mb", 0))) | ||||
| 	    break; | ||||
| 	  heap_chunk = 384; /* Default */ | ||||
| 	} | ||||
|   | ||||
| @@ -1,6 +1,7 @@ | ||||
| /* shared_info.h: shared info for cygwin | ||||
|  | ||||
|    Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 Red Hat, Inc. | ||||
|    Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009, | ||||
|    2010, 2011 Red Hat, Inc. | ||||
|  | ||||
| This file is part of Cygwin. | ||||
|  | ||||
| @@ -29,7 +30,7 @@ public: | ||||
| /* Data accessible to all tasks */ | ||||
|  | ||||
|  | ||||
| #define CURR_SHARED_MAGIC 0xcebb78fcU | ||||
| #define CURR_SHARED_MAGIC 0x7f4db5d3U | ||||
|  | ||||
| #define USER_VERSION   1 | ||||
| #define CURR_USER_MAGIC 0x6112afb3U | ||||
| @@ -42,9 +43,9 @@ class shared_info | ||||
|   LONG version; | ||||
|   DWORD cb; | ||||
|  public: | ||||
|   unsigned heap_chunk; | ||||
|   DWORD heap_chunk; | ||||
|   bool heap_slop_inited; | ||||
|   unsigned heap_slop; | ||||
|   DWORD heap_slop; | ||||
|   DWORD sys_mount_table_counter; | ||||
|   tty_list tty; | ||||
|   LONG last_used_bindresvport; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user