Author: fireball
Date: Wed Apr 7 23:17:42 2010
New Revision: 46772
URL:
http://svn.reactos.org/svn/reactos?rev=46772&view=rev
Log:
- Code cleanup: remove unnecessary PTHREADINFO/PPROCESSINFO casts, reduce diff to the
original code, make the code smaller by querying the current thread info only once per
function.
Modified:
branches/arwinss/reactos/subsystems/win32/win32k/wine/handle.c
branches/arwinss/reactos/subsystems/win32/win32k/wine/hook.c
branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c
branches/arwinss/reactos/subsystems/win32/win32k/wine/window.c
branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c
Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/handle.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/handle.c [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/handle.c [iso-8859-1] Wed Apr 7
23:17:42 2010
@@ -536,7 +536,7 @@
if (ops && obj->ops != ops)
set_error( STATUS_OBJECT_TYPE_MISMATCH );
else
- handle = alloc_handle( (PPROCESSINFO)PsGetCurrentProcessWin32Process() , obj,
access, attr );
+ handle = alloc_handle( PsGetCurrentProcessWin32Process() , obj, access, attr
);
release_object( obj );
}
else
@@ -554,14 +554,14 @@
/* close a handle */
DECL_HANDLER(close_handle)
{
- unsigned int err = close_handle( (PPROCESSINFO)PsGetCurrentProcessWin32Process(),
req->handle );
+ unsigned int err = close_handle( PsGetCurrentProcessWin32Process(), req->handle
);
set_error( err );
}
/* set a handle information */
DECL_HANDLER(set_handle_info)
{
- reply->old_flags = set_handle_flags(
(PPROCESSINFO)PsGetCurrentProcessWin32Process() , req->handle, req->mask,
req->flags );
+ reply->old_flags = set_handle_flags( PsGetCurrentProcessWin32Process() ,
req->handle, req->mask, req->flags );
}
/* duplicate a handle */
@@ -597,9 +597,9 @@
struct object *obj;
WCHAR *name;
- if (!(obj = get_handle_obj( (PPROCESSINFO)PsGetCurrentProcessWin32Process(),
req->handle, 0, NULL ))) return;
-
- reply->access = get_handle_access(
(PPROCESSINFO)PsGetCurrentProcessWin32Process(), req->handle );
+ if (!(obj = get_handle_obj( PsGetCurrentProcessWin32Process(), req->handle, 0,
NULL ))) return;
+
+ reply->access = get_handle_access( PsGetCurrentProcessWin32Process(),
req->handle );
reply->ref_count = obj->refcount;
if ((name = get_object_full_name( obj, &reply->total )))
set_reply_data_ptr( (void*)req, name, min( reply->total,
get_reply_max_size((void*)req) ));
@@ -627,7 +627,7 @@
if (req->security_info & DACL_SECURITY_INFORMATION)
access |= WRITE_DAC;
- if (!(obj = get_handle_obj( (PPROCESSINFO)PsGetCurrentProcessWin32Process(),
req->handle, access, NULL ))) return;
+ if (!(obj = get_handle_obj( PsGetCurrentProcessWin32Process(), req->handle,
access, NULL ))) return;
obj->ops->set_sd( obj, sd, req->security_info );
release_object( obj );
Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/hook.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/hook.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/hook.c [iso-8859-1] Wed Apr 7
23:17:42 2010
@@ -451,7 +451,6 @@
{
ObReferenceObjectByPointer(current->peThread, 0, NULL, KernelMode);
hook->owner = current;
- //hook->process = process ? (struct process *)grab_object( process ) : NULL;
if (process)
ObReferenceObjectByPointer(process->peProcess, 0, NULL, KernelMode);
hook->process = process;
Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c [iso-8859-1] (original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c [iso-8859-1] Wed Apr 7
23:17:42 2010
@@ -1674,7 +1674,7 @@
/* if skip wait is set, do what would have been done in the subsequent wait
*/
if (req->skip_wait)
{
- msg_queue_satisfied( &queue->obj,
(PTHREADINFO)PsGetCurrentThreadWin32Thread() );
+ msg_queue_satisfied( &queue->obj, PsGetCurrentThreadWin32Thread()
);
}
else
{
@@ -2087,7 +2087,7 @@
}
else
{
- thread = (PTHREADINFO)PsGetCurrentThreadWin32Thread();
+ thread = PsGetCurrentThreadWin32Thread();
ObReferenceObjectByPointer(thread->peThread, 0, NULL, KernelMode);
}
Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/window.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/window.c [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/window.c [iso-8859-1] Wed Apr 7
23:17:42 2010
@@ -408,7 +408,7 @@
if (!(desktop = get_thread_desktop( current, DESKTOP_CREATEWINDOW ))) return NULL;
- if (!(class = grab_class( (PPROCESSINFO)PsGetCurrentProcessWin32Process(), atom,
instance, &extra_bytes )))
+ if (!(class = grab_class( current->process, atom, instance, &extra_bytes )))
{
release_object( desktop );
return NULL;
@@ -1778,7 +1778,7 @@
if (win)
{
if (!is_desktop_window(win)) destroy_window( win );
- else if (win->thread == (PTHREADINFO)PsGetCurrentThreadWin32Thread())
detach_window_thread( win );
+ else if (win->thread == PsGetCurrentThreadWin32Thread()) detach_window_thread(
win );
else set_error( STATUS_ACCESS_DENIED );
}
}
@@ -1787,7 +1787,7 @@
/* retrieve the desktop window for the current thread */
DECL_HANDLER(get_desktop_window)
{
- struct desktop *desktop = get_thread_desktop(
(PTHREADINFO)PsGetCurrentThreadWin32Thread(), 0 );
+ struct desktop *desktop = get_thread_desktop( PsGetCurrentThreadWin32Thread(), 0 );
if (!desktop) return;
@@ -1865,7 +1865,7 @@
struct window *win = get_window( req->handle );
if (!win) return;
- if (req->flags && is_desktop_window(win) && win->thread !=
(PTHREADINFO)PsGetCurrentThreadWin32Thread())
+ if (req->flags && is_desktop_window(win) && win->thread !=
PsGetCurrentThreadWin32Thread())
{
set_error( STATUS_ACCESS_DENIED );
return;
@@ -1941,21 +1941,20 @@
struct unicode_str cls_name;
atom_t atom = req->atom;
struct desktop *desktop = NULL;
- PTHREADINFO current_thread = (PTHREADINFO)PsGetCurrentThreadWin32Thread();
- PPROCESSINFO current_process = (PPROCESSINFO)PsGetCurrentProcessWin32Process();
+ PTHREADINFO current = PsGetCurrentThreadWin32Thread();
get_req_unicode_str( (void*)req, &cls_name );
if (cls_name.len && !(atom = find_global_atom( NULL, &cls_name )))
return;
if (req->desktop)
{
- if (!(desktop = get_desktop_obj( current_process, req->desktop,
DESKTOP_ENUMERATE ))) return;
+ if (!(desktop = get_desktop_obj( current->process, req->desktop,
DESKTOP_ENUMERATE ))) return;
parent = desktop->top_window;
}
else
{
if (req->parent && !(parent = get_window( req->parent ))) return;
- if (!parent && !(desktop = get_thread_desktop( current_thread, 0 )))
return;
+ if (!parent && !(desktop = get_thread_desktop( current, 0 ))) return;
}
if (parent)
Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c
URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
==============================================================================
--- branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c [iso-8859-1]
(original)
+++ branches/arwinss/reactos/subsystems/win32/win32k/wine/winstation.c [iso-8859-1] Wed
Apr 7 23:17:42 2010
@@ -532,7 +532,7 @@
get_req_unicode_str( (void*)req, &name );
if ((winstation = create_winstation( &name, req->attributes, req->flags
)))
{
- reply->handle = alloc_handle( (PPROCESSINFO)PsGetCurrentProcessWin32Process(),
winstation, req->access, req->attributes );
+ reply->handle = alloc_handle( PsGetCurrentProcessWin32Process(), winstation,
req->access, req->attributes );
release_object( winstation );
}
}
@@ -555,11 +555,12 @@
DECL_HANDLER(close_winstation)
{
struct winstation *winstation;
-
- if ((winstation = (struct winstation *)get_handle_obj(
(PPROCESSINFO)PsGetCurrentProcessWin32Process(), req->handle,
+ PTHREADINFO current = PsGetCurrentThreadWin32Thread();
+
+ if ((winstation = (struct winstation *)get_handle_obj( current->process,
req->handle,
0, &winstation_ops )))
{
- if (close_handle( PsGetCurrentProcessWin32Process(), req->handle )) set_error(
STATUS_ACCESS_DENIED );
+ if (close_handle( current->process, req->handle )) set_error(
STATUS_ACCESS_DENIED );
release_object( winstation );
}
}
@@ -576,12 +577,13 @@
DECL_HANDLER(set_process_winstation)
{
struct winstation *winstation;
-
- if ((winstation = (struct winstation *)get_handle_obj(
(PPROCESSINFO)PsGetCurrentProcessWin32Process(), req->handle,
+ PTHREADINFO current = PsGetCurrentThreadWin32Thread();
+
+ if ((winstation = (struct winstation *)get_handle_obj( current->process,
req->handle,
0, &winstation_ops )))
{
/* FIXME: should we close the old one? */
- ((PPROCESSINFO)PsGetCurrentProcessWin32Process())->winstation =
req->handle;
+ current->process->winstation = req->handle;
release_object( winstation );
}
}
@@ -592,15 +594,15 @@
struct desktop *desktop;
struct winstation *winstation;
struct unicode_str name;
- PPROCESSINFO current = (PPROCESSINFO)PsGetCurrentProcessWin32Process();
+ PTHREADINFO current = PsGetCurrentThreadWin32Thread();
reply->handle = 0;
get_req_unicode_str( (void*)req, &name );
- if ((winstation = get_process_winstation( current, WINSTA_CREATEDESKTOP )))
+ if ((winstation = get_process_winstation( current->process, WINSTA_CREATEDESKTOP
)))
{
if ((desktop = create_desktop( &name, req->attributes, req->flags,
winstation )))
{
- reply->handle = alloc_handle( current, desktop, req->access,
req->attributes );
+ reply->handle = alloc_handle( current->process, desktop,
req->access, req->attributes );
release_object( desktop );
}
release_object( winstation );
@@ -612,14 +614,15 @@
{
struct winstation *winstation;
struct unicode_str name;
+ PTHREADINFO current = PsGetCurrentThreadWin32Thread();
get_req_unicode_str( (void*)req, &name );
/* FIXME: check access rights */
if (!req->winsta)
- winstation = get_process_winstation(
(PPROCESSINFO)PsGetCurrentProcessWin32Process(), 0 );
+ winstation = get_process_winstation( current->process, 0 );
else
- winstation = (struct winstation *)get_handle_obj(
(PPROCESSINFO)PsGetCurrentProcessWin32Process(), req->winsta, 0, &winstation_ops
);
+ winstation = (struct winstation *)get_handle_obj( current->process,
req->winsta, 0, &winstation_ops );
if (winstation)
{
@@ -641,12 +644,13 @@
DECL_HANDLER(close_desktop)
{
struct desktop *desktop;
+ PTHREADINFO current = PsGetCurrentThreadWin32Thread();
/* make sure it is a desktop handle */
- if ((desktop = (struct desktop *)get_handle_obj(
(PPROCESSINFO)PsGetCurrentProcessWin32Process(), req->handle,
+ if ((desktop = (struct desktop *)get_handle_obj( current->process,
req->handle,
0, &desktop_ops )))
{
- if (close_handle( PsGetCurrentProcessWin32Process(), req->handle )) set_error(
STATUS_DEVICE_BUSY );
+ if (close_handle( current->process, req->handle )) set_error(
STATUS_DEVICE_BUSY );
release_object( desktop );
}
}
@@ -678,7 +682,7 @@
{
struct desktop *old_desktop, *new_desktop;
struct winstation *winstation;
- PTHREADINFO current = (PTHREADINFO)PsGetCurrentThreadWin32Thread();
+ PTHREADINFO current = PsGetCurrentThreadWin32Thread();
if (!(winstation = get_process_winstation( current->process, 0 /* FIXME: access
rights? */ )))
return;
@@ -723,7 +727,7 @@
{
struct object *obj;
- if (!(obj = get_handle_obj( (PPROCESSINFO)PsGetCurrentProcessWin32Process(),
req->handle, 0, NULL ))) return;
+ if (!(obj = get_handle_obj( PsGetCurrentProcessWin32Process(), req->handle, 0,
NULL ))) return;
if (obj->ops == &desktop_ops)
{
@@ -777,7 +781,7 @@
struct desktop *desktop;
unsigned int index = 0;
- if (!(winstation = (struct winstation *)get_handle_obj(
(PPROCESSINFO)PsGetCurrentProcessWin32Process(), req->winstation,
+ if (!(winstation = (struct winstation *)get_handle_obj(
PsGetCurrentProcessWin32Process(), req->winstation,
WINSTA_ENUMDESKTOPS,
&winstation_ops )))
return;