https://git.reactos.org/?p=reactos.git;a=commitdiff;h=cba0d6464534227726af9…
commit cba0d6464534227726af9a310c03772923930aa0
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Wed Apr 21 18:18:41 2021 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Wed May 5 17:24:10 2021 +0200
[SYSDM][USERINIT] Fix uninitialized variables warnings detected by Clang. (#3619)
CORE-17545
Addendum to commit d635ce0c.
- Move the HDC variables initialization via function calls, out of
the variables declaration block.
- Fix warnings (and identical for base/system/userinit/livecd.c):
dll/cpl/sysdm/general.c:72:9: warning: variable 'hLogo' is used uninitialized
whenever 'if' condition is true [-Wsometimes-uninitialized]
if (hDC == NULL || hDCLogo == NULL || hDCMask == NULL)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dll/cpl/sysdm/general.c:130:9: note: uninitialized use occurs here
if (hLogo != NULL) DeleteObject(hLogo);
^~~~~
and similar for hMask too:
dll/cpl/sysdm/general.c:129:9: note: uninitialized use occurs here
if (hMask != NULL) DeleteObject(hMask);
^~~~~
---
base/system/userinit/livecd.c | 11 +++++++----
dll/cpl/sysdm/general.c | 11 +++++++----
2 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/base/system/userinit/livecd.c b/base/system/userinit/livecd.c
index 40626609402..216579f427b 100644
--- a/base/system/userinit/livecd.c
+++ b/base/system/userinit/livecd.c
@@ -27,13 +27,16 @@ InitLogo(PIMGINFO pImgInfo, HWND hwndDlg)
BITMAP logoBitmap;
BITMAP maskBitmap;
BITMAPINFO bmpi;
- HDC hDC = GetDC(hwndDlg);
- HDC hDCLogo = CreateCompatibleDC(NULL);
- HDC hDCMask = CreateCompatibleDC(NULL);
- HBITMAP hMask, hLogo, hAlphaLogo = NULL;
+ HDC hDC, hDCLogo, hDCMask;
+ HBITMAP hMask = NULL, hLogo = NULL;
+ HBITMAP hAlphaLogo = NULL;
COLORREF *pBits;
INT line, column;
+ hDC = GetDC(hwndDlg);
+ hDCLogo = CreateCompatibleDC(NULL);
+ hDCMask = CreateCompatibleDC(NULL);
+
if (hDC == NULL || hDCLogo == NULL || hDCMask == NULL)
goto Cleanup;
diff --git a/dll/cpl/sysdm/general.c b/dll/cpl/sysdm/general.c
index d43a75cf4e7..746c8235b16 100644
--- a/dll/cpl/sysdm/general.c
+++ b/dll/cpl/sysdm/general.c
@@ -62,13 +62,16 @@ static VOID InitLogo(HWND hwndDlg)
BITMAP logoBitmap;
BITMAP maskBitmap;
BITMAPINFO bmpi;
- HDC hDC = GetDC(hwndDlg);
- HDC hDCLogo = CreateCompatibleDC(NULL);
- HDC hDCMask = CreateCompatibleDC(NULL);
- HBITMAP hMask, hLogo, hAlphaLogo = NULL;
+ HDC hDC, hDCLogo, hDCMask;
+ HBITMAP hMask = NULL, hLogo = NULL;
+ HBITMAP hAlphaLogo = NULL;
COLORREF *pBits;
INT line, column;
+ hDC = GetDC(hwndDlg);
+ hDCLogo = CreateCompatibleDC(NULL);
+ hDCMask = CreateCompatibleDC(NULL);
+
if (hDC == NULL || hDCLogo == NULL || hDCMask == NULL)
goto Cleanup;