From 14cb5f9e41e8f906499c50179cc768fddc9b10f8 Mon Sep 17 00:00:00 2001 From: midipix Date: Sat, 26 Aug 2017 09:32:41 -0400 Subject: __ntapi_sem_set(), __ntapi_sem_query(): handle hlock more elegantly. --- src/sem/ntapi_sem_query.c | 15 ++++++++------- src/sem/ntapi_sem_set.c | 17 +++++++++-------- 2 files changed, 17 insertions(+), 15 deletions(-) (limited to 'src/sem') diff --git a/src/sem/ntapi_sem_query.c b/src/sem/ntapi_sem_query.c index 816d50d..f1e53a9 100644 --- a/src/sem/ntapi_sem_query.c +++ b/src/sem/ntapi_sem_query.c @@ -16,10 +16,9 @@ static int32_t __sem_query_return( intptr_t * hlock, - int32_t status, - int32_t cmd) + int32_t status) { - if (cmd == NT_SEM_CMD_GETALL) + if (hlock) at_store(hlock,0); return status; @@ -53,6 +52,9 @@ int32_t __stdcall __ntapi_sem_query( if (sem_info_length != sizeof(nt_sem_info)) return NT_STATUS_INFO_LENGTH_MISMATCH; + /* init */ + hlock = 0; + /* section */ hsection = 0; secaddr = 0; @@ -93,17 +95,16 @@ int32_t __stdcall __ntapi_sem_query( msg.data.seminfo.section_size = secsize; if ((status = __ntapi->zw_request_wait_reply_port(sem->hport,&msg,&msg))) - return __sem_query_return(hlock,status,sem_ipc_cmd); + return __sem_query_return(hlock,status); else if (msg.data.ttyinfo.status) - return __sem_query_return(hlock,msg.data.ttyinfo.status,sem_ipc_cmd); + return __sem_query_return(hlock,msg.data.ttyinfo.status); /* reply */ if (sem_ipc_cmd == NT_SEM_CMD_GETALL) { if (msg.data.seminfo.section_size > sem_info_length) return __sem_query_return( hlock, - NT_STATUS_BUFFER_TOO_SMALL, - sem_ipc_cmd); + NT_STATUS_BUFFER_TOO_SMALL); __ntapi->tt_generic_memcpy( sem_info,secaddr, diff --git a/src/sem/ntapi_sem_set.c b/src/sem/ntapi_sem_set.c index 813de30..02a23e6 100644 --- a/src/sem/ntapi_sem_set.c +++ b/src/sem/ntapi_sem_set.c @@ -16,10 +16,9 @@ static int32_t __sem_set_return( intptr_t * hlock, - int32_t status, - int32_t cmd) + int32_t status) { - if (cmd == NT_SEM_CMD_SETALL) + if (hlock) at_store(hlock,0); return status; @@ -53,6 +52,9 @@ int32_t __stdcall __ntapi_sem_set( if (sem_info_length != sizeof(nt_sem_info)) return NT_STATUS_INFO_LENGTH_MISMATCH; + /* init */ + hlock = 0; + /* section */ hsection = 0; secaddr = 0; @@ -84,8 +86,7 @@ int32_t __stdcall __ntapi_sem_set( __ntapi->tt_generic_memcpy( secaddr,sem_info, sem_info_length); - } else - hlock = 0; + } /* msg */ __ntapi->tt_aligned_block_memset( @@ -105,13 +106,13 @@ int32_t __stdcall __ntapi_sem_set( msg.data.seminfo.section_size = sem_info_length; if ((status = __ntapi->zw_request_wait_reply_port(sem->hport,&msg,&msg))) - return __sem_set_return(hlock,status,sem_ipc_cmd); + return __sem_set_return(hlock,status); else if (msg.data.ttyinfo.status) - return __sem_set_return(hlock,msg.data.ttyinfo.status,sem_ipc_cmd); + return __sem_set_return(hlock,msg.data.ttyinfo.status); /* reply */ iosb->status = NT_STATUS_SUCCESS; iosb->info = 0; - return __sem_set_return(hlock,NT_STATUS_SUCCESS,sem_ipc_cmd); + return __sem_set_return(hlock,NT_STATUS_SUCCESS); } -- cgit v1.2.3