Skip to content

Commit

Permalink
Fix more GCC 8.1 warnings   1   master 
Browse files Browse the repository at this point in the history
Fix 3 warnings reported by GCC 8.1 of the following type

```src/client/gameui.cpp:191:43: warning: « void* memset(void*, int, size_t) » effacement d'un objet du type non trivial « struct GameUI::Flags »; use assignment or value-initialization instead [-Wclass-memaccess]
  memset(&m_flags, 0, sizeof(GameUI::Flags));
```
  • Loading branch information
nerzhul committed May 28, 2018
1 parent b620f2f commit a78659e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/client/gameui.cpp
Expand Up @@ -188,7 +188,7 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_

void GameUI::initFlags()
{
memset(&m_flags, 0, sizeof(GameUI::Flags));
m_flags = GameUI::Flags();

This comment has been minimized.

Copy link
@lhofhansl

lhofhansl May 28, 2018

Contributor

Turns out that this changes the behavior.
Before this change show_minimap and show_profiler_graph were false, no they are true.

This comment has been minimized.

Copy link
@lhofhansl

lhofhansl May 28, 2018

Contributor

This comment has been minimized.

Copy link
@nerzhul

nerzhul May 29, 2018

Author Member

exact ! the default constructor doesn't use false flags, looking for this

This comment has been minimized.

Copy link
@nerzhul

nerzhul May 29, 2018

Author Member

i'm fixing it, improving the unittests and cleaning it

This comment has been minimized.

Copy link
@nerzhul

nerzhul May 29, 2018

Author Member

nice catch

This comment has been minimized.

Copy link
@nerzhul

nerzhul May 29, 2018

Author Member

Fixed

m_flags.show_chat = true;
m_flags.show_hud = true;
m_flags.show_debug = g_settings->getBool("show_debug");
Expand Down
3 changes: 2 additions & 1 deletion src/game.cpp
Expand Up @@ -1014,7 +1014,8 @@ bool Game::startup(bool *kill,
RenderingEngine::get_scene_manager()->getParameters()->
setAttribute(scene::OBJ_LOADER_IGNORE_MATERIAL_FILES, true);

memset(&runData, 0, sizeof(runData));
// Reinit runData
runData = GameRunData();
runData.time_from_last_punch = 10.0;
runData.update_wielded_item_trigger = true;

Expand Down
1 change: 0 additions & 1 deletion src/gui/guiTable.cpp
Expand Up @@ -334,7 +334,6 @@ void GUITable::setTable(const TableOptions &options,

// Make template for new cells
Cell newcell;
memset(&newcell, 0, sizeof newcell);
newcell.content_type = columntype;
newcell.tooltip_index = tooltip_index;
newcell.reported_column = j+1;
Expand Down

0 comments on commit a78659e

Please sign in to comment.