[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);
        ^~~~~
This commit is contained in:
Hermès Bélusca-Maïto 2021-04-21 18:18:41 +02:00
parent 89860ab543
commit cba0d64645
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0
2 changed files with 14 additions and 8 deletions

View file

@ -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;

View file

@ -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;