Alex Ionescu wrote:
No they are correct, most of the times the
"may" means "given certain code paths", not "may" as in
"uhhh... I think it could happen?"
The reason the error often happens, with GCC *AND* MSVC (see previous e-mail) is stuff
like this:
BOOLEAN HaveYourDad;
PVOID Pen15;
ULONG YourMom;
if (YourMom)
{
Pen15 = ExAllocateYourDad();
HaveYourDad = TRUE;
}
....
if (HaveYourDad) ExReleaseYourDad(Pen15);
In this case, the compiler might say that your Pen15 may be used without having been
initialized because it doesn't realize that I'm only going to have your dad if I
also already had your mom.
Had you written:
if (YourMom) ExReleaseYourDad(Pen15); the compiler would probably be smart enough to
realize the side-effect.
You can't always simplify it by having a YourMum equivalent to HaveYourDad.
It's a pity that compilers don't provide a way to link Pen15 to
HaveYourDad. With such a hint they could realise that Pen15 is not being
used uninitialised there, while checking for usages not into a
HaveYourDad conditional (as well as warn you if you set HaveYourDad and
Pen15 isn't set on that branch).