https://git.reactos.org/?p=reactos.git;a=commitdiff;h=38db074491768faf5a8dd1e83139fd16a7681d92

commit 38db074491768faf5a8dd1e83139fd16a7681d92
Author:     Serge Gautherie <[email protected]>
AuthorDate: Tue Jun 4 16:56:33 2019 +0200
Commit:     Hermès BÉLUSCA - MAÏTO <[email protected]>
CommitDate: Tue Jun 4 16:56:33 2019 +0200

    Misc addendum to CORE-14271 (#1529)
    
    * [ADVAPI32] Simplify RtlCreateUnicodeStringFromAsciiz() return value check
    
    RtlCreateUnicodeStringFromAsciiz() returns a BOOLEAN, not a BOOL.
    
    No functional change.
    
    Addendum to
    CORE-14271
    
    * [USER32] Simplify RtlCreateUnicodeStringFromAsciiz() return value check
    
    RtlCreateUnicodeStringFromAsciiz() returns a BOOLEAN, not a UINT.
    
    Also, add a FIXME.
    
    No functional change.
    
    Addendum to
    CORE-14271
    
    * [USER32] Simplify RegisterClipboardFormatA/W() a bit
    
    No functional change.
    
    * [UDFS] Simplify SeSinglePrivilegeCheck() return value check
    
    No functional change.
    
    Addendum to
    CORE-14271
---
 dll/win32/advapi32/reg/reg.c            |  5 +----
 drivers/filesystems/udfs/secursup.cpp   |  5 ++---
 win32ss/user/user32/windows/clipboard.c | 26 ++++++++++++--------------
 3 files changed, 15 insertions(+), 21 deletions(-)

diff --git a/dll/win32/advapi32/reg/reg.c b/dll/win32/advapi32/reg/reg.c
index 37ac117de60..8841c15f999 100644
--- a/dll/win32/advapi32/reg/reg.c
+++ b/dll/win32/advapi32/reg/reg.c
@@ -4847,10 +4847,7 @@ RegSetValueExA(HKEY hKey,
     /* Convert SubKey name to Unicode */
     if (lpValueName != NULL && lpValueName[0] != '\0')
     {
-        BOOL bConverted;
-        bConverted = RtlCreateUnicodeStringFromAsciiz(&ValueName,
-                                                  (PSTR)lpValueName);
-        if(!bConverted)
+        if (!RtlCreateUnicodeStringFromAsciiz(&ValueName, (PSTR)lpValueName))
             return ERROR_NOT_ENOUGH_MEMORY;
     }
     else
diff --git a/drivers/filesystems/udfs/secursup.cpp 
b/drivers/filesystems/udfs/secursup.cpp
index de5bb1536d3..8e4a5e0548e 100644
--- a/drivers/filesystems/udfs/secursup.cpp
+++ b/drivers/filesystems/udfs/secursup.cpp
@@ -934,9 +934,9 @@ UDFCheckAccessRights(
     )
 {
     NTSTATUS RC;
-    BOOLEAN SecurityCheck = TRUE;
     BOOLEAN ROCheck = FALSE;
 #ifdef UDF_ENABLE_SECURITY
+    BOOLEAN SecurityCheck;
     PSECURITY_DESCRIPTOR SecDesc;
     SECURITY_SUBJECT_CONTEXT SubjectContext;
     ACCESS_MASK LocalAccessMask;
@@ -1011,8 +1011,7 @@ treat_as_ro:
         } else
 #endif //UDF_ENABLE_SECURITY
         if(DesiredAccess & ACCESS_SYSTEM_SECURITY) {
-            SecurityCheck = 
SeSinglePrivilegeCheck(SeExports->SeSecurityPrivilege, UserMode);
-            if(!SecurityCheck)
+            if (!SeSinglePrivilegeCheck(SeExports->SeSecurityPrivilege, 
UserMode))
                 return STATUS_ACCESS_DENIED;
             Ccb->PreviouslyGrantedAccess |= ACCESS_SYSTEM_SECURITY;
         }
diff --git a/win32ss/user/user32/windows/clipboard.c 
b/win32ss/user/user32/windows/clipboard.c
index bb51ce76ab1..d7cfb79237a 100644
--- a/win32ss/user/user32/windows/clipboard.c
+++ b/win32ss/user/user32/windows/clipboard.c
@@ -71,7 +71,7 @@ GetClipboardFormatNameA(UINT format,
             /* clear result string */
             Length = 0;
         }
-        lpszFormatName[Length] = '\0';
+        lpszFormatName[Length] = ANSI_NULL;
     }
 
     RtlFreeHeap(RtlGetProcessHeap(), 0, lpBuffer);
@@ -97,7 +97,7 @@ UINT
 WINAPI
 RegisterClipboardFormatA(LPCSTR lpszFormat)
 {
-    UINT ret = 0;
+    UINT ret;
     UNICODE_STRING usFormat = {0};
 
     if (lpszFormat == NULL)
@@ -106,20 +106,22 @@ RegisterClipboardFormatA(LPCSTR lpszFormat)
         return 0;
     }
 
-    /* check for "" */
-    if (*lpszFormat == 0) //NULL
+    if (*lpszFormat == ANSI_NULL)
     {
         SetLastError(ERROR_INVALID_NAME);
         return 0;
     }
 
-    ret = RtlCreateUnicodeStringFromAsciiz(&usFormat, lpszFormat);
-    if (ret)
+    if (!RtlCreateUnicodeStringFromAsciiz(&usFormat, lpszFormat))
     {
-        ret = NtUserRegisterWindowMessage(&usFormat); //(LPCWSTR)
-        RtlFreeUnicodeString(&usFormat);
+        // FIXME: Shouldn't we 'SetLastError(ERROR_NOT_ENOUGH_MEMORY);'?
+        return 0;
     }
 
+    ret = NtUserRegisterWindowMessage(&usFormat); //(LPCWSTR)
+
+    RtlFreeUnicodeString(&usFormat);
+
     return ret;
 }
 
@@ -130,7 +132,6 @@ UINT
 WINAPI
 RegisterClipboardFormatW(LPCWSTR lpszFormat)
 {
-    UINT ret = 0;
     UNICODE_STRING usFormat = {0};
 
     if (lpszFormat == NULL)
@@ -139,17 +140,14 @@ RegisterClipboardFormatW(LPCWSTR lpszFormat)
         return 0;
     }
 
-    /* check for "" */
-    if (*lpszFormat == 0) //NULL
+    if (*lpszFormat == UNICODE_NULL)
     {
         SetLastError(ERROR_INVALID_NAME);
         return 0;
     }
 
     RtlInitUnicodeString(&usFormat, lpszFormat);
-    ret = NtUserRegisterWindowMessage(&usFormat);
-
-    return ret;
+    return NtUserRegisterWindowMessage(&usFormat);
 }
 
 static PVOID WINAPI

Reply via email to