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

Return anything from non-void function. #7527

Closed

Conversation

nelchael
Copy link
Contributor

@nelchael nelchael commented Nov 10, 2024

Android and Xbox compilation logs a warning that non-void function in some code paths doesn't return anything, this is correct as the last invocation in the catch is app_fatal. To prevent this warning I'm adding a return statement that will not be actually executed but will silence the compiler warnings.

Android warning:

C/C++: In file included from /home/runner/work/devilutionX/devilutionX/Source/capture.cpp:30:
C/C++: /home/runner/work/devilutionX/devilutionX/Source/utils/log.hpp:62:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
C/C++: }
C/C++: ^
C/C++: /home/runner/work/devilutionX/devilutionX/Source/utils/log.hpp:160:21: note: in instantiation of function template specialization 'devilution::detail::format<std::string &, const char *>' requested here
C/C++:         auto str = detail::format(fmt, std::forward<Args>(args)...);
C/C++:                            ^
C/C++: /home/runner/work/devilutionX/devilutionX/Source/utils/log.hpp:167:2: note: in instantiation of function template specialization 'devilution::LogError<std::string &, const char *>' requested here
C/C++:         LogError(defaultCategory, fmt, std::forward<Args>(args)...);
C/C++:         ^
C/C++: /home/runner/work/devilutionX/devilutionX/Source/capture.cpp:84:3: note: in instantiation of function template specialization 'devilution::LogError<std::string &, const char *>' requested here
C/C++:                 LogError("Failed to open {} for writing: {}", fileName, SDL_GetError());
C/C++:                 ^

With this change the Android build log is readable again -- down from ~21500 lines to ~1100.

@nelchael nelchael force-pushed the silence-compiler-warning branch from 99464f8 to 600ce65 Compare November 10, 2024 19:26
@nelchael nelchael force-pushed the silence-compiler-warning branch from 600ce65 to 7728c04 Compare November 10, 2024 19:33
@nelchael nelchael marked this pull request as ready for review November 10, 2024 19:47
@glebm
Copy link
Collaborator

glebm commented Nov 10, 2024

I'm hoping that for Android the warning will be solved with #7524

For Xbox, perhaps we could silence the warning with a compilation flag (-Wno-return-type)?

I'd rather we don't add these return statements here for a couple of outdated compilers.

@nelchael
Copy link
Contributor Author

Sounds fair 😄 I'll close this PR and we'll see how the new NDK behaves, thanks!

@nelchael nelchael closed this Nov 10, 2024
@nelchael nelchael deleted the silence-compiler-warning branch November 10, 2024 22:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants