https://git.reactos.org/?p=reactos.git;a=commitdiff;h=43108ba763b346fffad5a31c974fe70fe89ccc69

commit 43108ba763b346fffad5a31c974fe70fe89ccc69
Author:     Katayama Hirofumi MZ <katayama.hirofumi...@gmail.com>
AuthorDate: Sun Aug 28 09:48:56 2022 +0900
Commit:     Katayama Hirofumi MZ <katayama.hirofumi...@gmail.com>
CommitDate: Sun Aug 28 09:48:56 2022 +0900

    [KBSWITCH] Simplify checking NULLs
    
    CORE-10667
---
 base/applications/kbswitch/kbswitch.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/base/applications/kbswitch/kbswitch.c 
b/base/applications/kbswitch/kbswitch.c
index aac2c895d9a..13a1470ce2b 100644
--- a/base/applications/kbswitch/kbswitch.c
+++ b/base/applications/kbswitch/kbswitch.c
@@ -169,16 +169,6 @@ CreateTrayIcon(LPTSTR szLCID)
     hdc = CreateCompatibleDC(NULL);
     hbmColor = CreateCompatibleBitmap(hdc, CX_ICON, CY_ICON);
     hbmMono = CreateBitmap(CX_ICON, CY_ICON, 1, 1, NULL);
-    if (!hdc || !hbmColor || !hbmMono)
-    {
-        if (hdc)
-            DeleteDC(hdc);
-        if (hbmColor)
-            DeleteObject(hbmColor);
-        if (hbmMono)
-            DeleteObject(hbmMono);
-        return NULL;
-    }
 
     /* Create a font */
     ZeroMemory(&lf, sizeof(lf));
@@ -187,11 +177,18 @@ CreateTrayIcon(LPTSTR szLCID)
     lf.lfWeight = FW_NORMAL;
     StringCchCopy(lf.lfFaceName, ARRAYSIZE(lf.lfFaceName), _T("Tahoma"));
     hFont = CreateFontIndirect(&lf);
-    if (!hFont)
+
+    /* Checking NULL */
+    if (!hdc || !hbmColor || !hbmMono || !hFont)
     {
-        DeleteDC(hdc);
-        DeleteObject(hbmColor);
-        DeleteObject(hbmMono);
+        if (hdc)
+            DeleteDC(hdc);
+        if (hbmColor)
+            DeleteObject(hbmColor);
+        if (hbmMono)
+            DeleteObject(hbmMono);
+        if (hFont)
+            DeleteObject(hFont);
         return NULL;
     }
 

Reply via email to