while doing some static code analysis I’ve found a weird one. On a call like this one:
if(!AfxWinInit(moduleHandle,NULL,::GetCommandLine(),0)
I get the warning C6309 at the second parameter (C6309: argument 2 is null: it does not adhere to function specification of AfxWinInit)
Docs say that for Win32 applications the second parameter must be NULL so the questions is:
a) What’s wrong, my code, the AfxWinInit declaration or the static code analysis?
Thanks in advance!
That looks wrong to me, the 2nd argument should have been annotated as
_In_opt_. From the SAL Annotations documentation:Optional Option
Describes if the buffer itself is optional. These annotations can be applied to values in the Parameters layer, Return Value layer, or Pre / Post layer.
The pointer to the buffer must not be NULL.
The pointer to the buffer might be NULL. It will be checked before being dereferenced.