Wrong typecast in GetApplicationAttrs() autodoc?

Have a question about our Software Developer Kit? Ask them here.

Wrong typecast in GetApplicationAttrs() autodoc?

Postby trixie » Sun Jan 27, 2013 1:11 pm

I see that the autodoc for GetApplicationAttrs() / GetApplicationAttrsA() contains the following example code:

Code: Select all
       struct MsgPort *port;

       if (GetApplicationAttrs(appID, APPATTR_Port, (uint32)&port, TAG_DONE))
       {
           ... receive messages ...
       }

But surely the typecast is wrong? Assuming that the function uses the same type of storage as Intuition's GetAttrs(), I guess the line should read:

if (GetApplicationAttrs(appID, APPATTR_Port, (uint32 *)&port, TAG_DONE))
Smoke me a kipper, I'll be back for breakfast!

AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon RX 560 / ESI Juli@ / AmigaOS 4.1 Final Edition
SAM440ep-flex @ 667MHz / 1GB RAM / Radeon 9250 / AmigaOS 4.1 Final Edition
User avatar
trixie
 
Posts: 395
Joined: Thu Jun 30, 2011 3:54 pm
Location: Czech Republic

Re: Wrong typecast in GetApplicationAttrs() autodoc?

Postby salass00 » Sun Jan 27, 2013 4:43 pm

@trixie

It's defined as a varargs function so no cast should be necessary unlike with GetAttr() where the type of the storage pointer is defined in the function definition.
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 516
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland

Re: Wrong typecast in GetApplicationAttrs() autodoc?

Postby ssolie » Mon Jan 28, 2013 7:50 pm

As salass00 already pointed out, type casting with varargs is quite irrelevant. Removing the type cast completely is the correct fix.
ExecSG Team Lead
User avatar
ssolie
Beta Tester
Beta Tester
 
Posts: 1010
Joined: Mon Dec 20, 2010 9:51 pm
Location: Canada

Re: Wrong typecast in GetApplicationAttrs() autodoc?

Postby Hans-Joerg Frieden » Tue Jan 29, 2013 12:54 pm

The typecasting is pretty much irrelevant, that's true. However, Trixie has a point here, it's bad style because it will produce code that is not 64 bit clean. Not that we run on any 64 bit target, but then, there is no need to artificially create these issues :)
NOTICE: If you want to contact me, use E-Mail. I cannot be contacted via the forum/private messages anymore
User avatar
Hans-Joerg Frieden
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 223
Joined: Wed Dec 08, 2010 4:52 pm


Return to SDK Support

Who is online

Users browsing this forum: No registered users and 2 guests