Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KYRA: Fix pointless NULL validation #3949

Merged
merged 1 commit into from Jun 3, 2022
Merged

KYRA: Fix pointless NULL validation #3949

merged 1 commit into from Jun 3, 2022

Conversation

orgads
Copy link
Contributor

@orgads orgads commented Jun 2, 2022

Reported by GCC 12:

../scummvm/engines/kyra/script/script_hof.cpp: In member function 'int Kyra::KyraEngine_HoF::o2_defineSceneAnim(Kyra::EMCState*)':
../scummvm/engines/kyra/script/script_hof.cpp:875:32: warning: comparing the result of pointer addition '(((const char*)script->Kyra::EMCState::dataPtr->Kyra::EMCData::text) + ((sizetype)READ_BE_UINT16((((const void*)script->Kyra::EMCState::dataPtr->Kyra::EMCData::text) + ((sizetype)(((int)((Kyra::KyraEngine_HoF*)this)->Kyra::KyraEngine_HoF::<anonymous>.Kyra::KyraEngine_v2::<anonymous>.Kyra::KyraEngine_v1::emcSafeReadStack(script, 12, 875, ((const char*)"../scummvm/engines/kyra/script/script_hof.cpp"))) << 1))))))' and NULL [-Waddress]
  875 |         if (stackPosString(12) != nullptr)

Reported by GCC 12:
../scummvm/engines/kyra/script/script_hof.cpp: In member function 'int Kyra::KyraEngine_HoF::o2_defineSceneAnim(Kyra::EMCState*)':
../scummvm/engines/kyra/script/script_hof.cpp:875:32: warning: comparing the result of pointer addition '(((const char*)script->Kyra::EMCState::dataPtr->Kyra::EMCData::text) + ((sizetype)READ_BE_UINT16((((const void*)script->Kyra::EMCState::dataPtr->Kyra::EMCData::text) + ((sizetype)(((int)((Kyra::KyraEngine_HoF*)this)->Kyra::KyraEngine_HoF::<anonymous>.Kyra::KyraEngine_v2::<anonymous>.Kyra::KyraEngine_v1::emcSafeReadStack(script, 12, 875, ((const char*)"../scummvm/engines/kyra/script/script_hof.cpp"))) << 1))))))' and NULL [-Waddress]
  875 |         if (stackPosString(12) != nullptr)
@orgads
Copy link
Contributor Author

@orgads orgads commented Jun 2, 2022

I'm not sure if this was maybe supposed to be if (!*stackPosString(12)).

@athrxx
Copy link
Member

@athrxx athrxx commented Jun 3, 2022

Thanks!
From HOF disasm, it does have exactly that weird check.
I think it never matters, because the check is always true throughout the game.
It probably should be the opposite of what you suggested: if (*stackPosString(12)).
I'll just add that...

@athrxx athrxx merged commit 5d4baa9 into scummvm:master Jun 3, 2022
8 checks passed
athrxx added a commit that referenced this issue Jun 3, 2022
@orgads orgads deleted the kyra-null branch Jun 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants