diff options
author | midipix <writeonce@midipix.org> | 2017-08-26 09:32:41 -0400 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2017-08-26 09:40:18 -0400 |
commit | 14cb5f9e41e8f906499c50179cc768fddc9b10f8 (patch) | |
tree | aae00ff69a27dab6646c2605536e65499d44cfae /src | |
parent | 93df7957a125a9e6948da9101388f91667b25826 (diff) | |
download | ntapi-14cb5f9e41e8f906499c50179cc768fddc9b10f8.tar.bz2 ntapi-14cb5f9e41e8f906499c50179cc768fddc9b10f8.tar.xz |
__ntapi_sem_set(), __ntapi_sem_query(): handle hlock more elegantly.
Diffstat (limited to 'src')
-rw-r--r-- | src/sem/ntapi_sem_query.c | 15 | ||||
-rw-r--r-- | src/sem/ntapi_sem_set.c | 17 |
2 files changed, 17 insertions, 15 deletions
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); } |