Wrong typecast in GetApplicationAttrs() autodoc?

Have a question about our Software Developer Kit? Ask them here.
Post Reply
User avatar
trixie
Posts: 395
Joined: Thu Jun 30, 2011 2:54 pm
Location: Czech Republic

Wrong typecast in GetApplicationAttrs() autodoc?

Post by trixie »

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
salass00
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 516
Joined: Sat Jun 18, 2011 3:12 pm
Location: Finland
Contact:

Re: Wrong typecast in GetApplicationAttrs() autodoc?

Post by salass00 »

@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
ssolie
Beta Tester
Beta Tester
Posts: 1010
Joined: Mon Dec 20, 2010 8:51 pm
Location: Canada
Contact:

Re: Wrong typecast in GetApplicationAttrs() autodoc?

Post by ssolie »

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
Hans-Joerg Frieden
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 223
Joined: Wed Dec 08, 2010 3:52 pm

Re: Wrong typecast in GetApplicationAttrs() autodoc?

Post by Hans-Joerg Frieden »

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

Post Reply