Skip to content

Fix control reaches end of non-void function warnings#117

Merged
DanielaOrtner merged 1 commit into
RebelToolbox:mainfrom
madmiraal:fix-control-reaches-end-of-non-void-function-warning
Jan 26, 2025
Merged

Fix control reaches end of non-void function warnings#117
DanielaOrtner merged 1 commit into
RebelToolbox:mainfrom
madmiraal:fix-control-reaches-end-of-non-void-function-warning

Conversation

@madmiraal
Copy link
Copy Markdown
Contributor

The mingw-w64 compiler, raises warnings that control reaches end of non-void function [-Wreturn-type] in:

  • core/io/resource_loader.cpp line 388, in static member function static RES ResourceLoader::_load(const String&, const String&, const String&, bool, Error*)
  • core/io/resource_loader.cpp line 656, in static member function static Ref<ResourceInteractiveLoader> ResourceLoader::load_interactive(const String&, const String&, bool, Error*)
  • core/os/os.cpp line 791, in member function virtual PoolStringArray OS::get_connected_midi_inputs()
  • core/packed_data_container.cpp line 82, in member function Variant PackedDataContainer::_iter_get_ofs(const Variant&, uint32_t)
  • core/project_settings.cpp line 1087, in member function Error ProjectSettings::save_custom(const String&, const CustomMap&, const Vector<String>&, bool)
    -platform/windows/windows_dir_access.cpp line 336, in member function virtual String WindowsDirAccess::get_filesystem_type() const

It appears that the compiler doesn't recognise that the ERR_FAIL_V and ERR_FAIL_V_MSG macros if (true) condition implies that the else branch will never be reached:

#define ERR_FAIL_V_MSG(m_retval, m_msg) \
if (true) { \
_err_print_error( \
__FUNCTION__, \
__FILE__, \
__LINE__, \
"Method/function failed. Returning: " _STR(m_retval), \
m_msg \
); \
return m_retval; \
} else \
((void)0)

#define ERR_FAIL_V(m_retval) \
if (true) { \
_err_print_error( \
__FUNCTION__, \
__FILE__, \
__LINE__, \
"Method/function failed. Returning: " _STR(m_retval) \
); \
return m_retval; \
} else \
((void)0)

To avoid these warnings, this PR adds additional returns that mirror the if (true) returns.

@madmiraal madmiraal added the PR Type: Bug Fix Your current game should now work as expected. label Jan 26, 2025
@DanielaOrtner DanielaOrtner self-requested a review January 26, 2025 09:28
Copy link
Copy Markdown
Contributor

@DanielaOrtner DanielaOrtner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the good work :)

@DanielaOrtner DanielaOrtner merged commit 649f35b into RebelToolbox:main Jan 26, 2025
@madmiraal madmiraal deleted the fix-control-reaches-end-of-non-void-function-warning branch January 27, 2025 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR Type: Bug Fix Your current game should now work as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants