Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-03

Errors in win32winapi.inc and elsewhere spotted by compiler

6 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Juha Manninen

Hi

I fixed lots of uninitialized variables based on compiler warnings in r48476 - r484782.
I also added some ToDo items for things I could not fix. I would need help for the ToDo items especially in LCL-Win32 code. I know there are people here who know that code.
In win32winapi.inc there are 3 ToDos :

In function TWin32WidgetSet.Frame3D
there is :
  // ToDo: Fix Result and the loop. "I" is not used for anything.
  for I := 0 to FrameWidth - 1 do
    Result := Boolean(DrawEdge(DC, ARect, Edge[Style], BF_RECT or BF_ADJUST));
In function TWin32WidgetSet.StretchMaskBlt
there is :
  // check if the Src has an alpha channel
  Bmp := Windows.GetCurrentObject(SrcDC, OBJ_BITMAP);
  // get info
  // ToDo: WinBmp is not  it be initialized from Bmp?
  HasAlpha := (Windows.GetObject(bmp, SizeOf(WinBmp), @WinBmp)  0)
          and (WinBmp.bmBitsPixel = 32)
          and CreatePremultipliedBitmap(WinBmp, Bmp, AlphaBmp);
and later:
    // ToDo: Initialize AlphaDC, AlphaObj and Blend.

Other fixes are welcome, too.

Regards,
Juha

Reply by email

Dmitry Boyarintsev
to Juha Manninen
Juha Manninen wrote 7 lines
I also added some ToDo items for things I could not fix. I would need help for the ToDo items especially in LCL-Win32 code. I know there are people here who know that code. // ToDo: WinBmp is not it be initialized from Bmp? HasAlpha := (Windows.GetObject(bmp, SizeOf(WinBmp), @WinBmp) 0)

According to the specs, there's no need for initialization.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd144904%28v=vs.85%29.aspx

It's pure out parameter. (for parameters requiring initialization it would be _In_ or _In_Out_)

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150324/4c9bd190/attachment.html>

Reply by email

Juha Manninen
to Dmitry Boyarintsev
Dmitry Boyarintsev wrote
> HasAlpha := (Windows.GetObject(bmp, SizeOf(WinBmp), @WinBmp) 0) According to the specs, there's no need for initialization.

Right, I missed that one. Now it is clear when I got plenty or warning with fpc -Oodfa. Some of them were false positives but many of them were real errors.
I removed the ToDo item in r48485.

Juha

Reply by email

Dmitry Boyarintsev
to Juha Manninen: Hi I fixed lots of uninitialized variables based on compiler warnings in r48476 - r484782.
Juha Manninen wrote 5 lines
// ToDo: Fix Result and the loop. "I" is not used for anything. for I := 0 to FrameWidth - 1 do Result := Boolean(DrawEdge(DC, ARect, Edge[Style], BF_RECT or BF_ADJUST));

false positive.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd162477%28v=vs.85%29.aspx BF_ADJUST causes ARect to be different on every call. Side-effect function :)

hmm... of is DrawEdge declaration wrong having ARect be passed as "const" rather than "var"?

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150324/6bfa3d41/attachment.html>

Reply by email

Dmitry Boyarintsev
to Dmitry Boyarintsev: On Tue, Mar 24, 2015 at 2:06 PM, Juha Manninen false positive.…

On Tue, Mar 24, 2015 at 4:36 PM, Dmitry Boyarintsev <

Show quoted text 6 lines
wrote: hmm... or is DrawEdge declaration wrong having ARect be passed as "const" rather than "var"? it's var!
function DrawEdge(hdc: HDC; var qrc: TRect; edge: UINT; grfFlags: UINT):
BOOL; external 'user32' name 'DrawEdge';

Imho, the compiler should be adjusted for these cases not to give a note. Since number of iterations is important in this case, not the iterator value.

thanks,
Dmitry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150324/287aaca9/attachment-0001.html>

Reply by email