Issues found by Cppcheck 1.56

src/logic/world.h:136: (style) The struct 'MapGenAreaInfo' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instanciated. That may cause bugs or undefined behavior.
src/logic/world.h:205: (style) The struct 'MapGenBobArea' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instanciated. That may cause bugs or undefined behavior.
src/logic/world.h:232: (style) The struct 'MapGenInfo' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instanciated. That may cause bugs or undefined behavior.
src/logic/field.h:61: (style) The struct 'Field' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instanciated. That may cause bugs or undefined behavior.
src/logic/player.h:140: (warning) Member variable 'Field::constructionsite' is not initialized in the constructor.
src/io/basic_filewrite.h:97: (error) Common realloc mistake: 'data' nulled but not freed upon failure
src/logic/widelands_geometry.h:97: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/widelands_geometry.h:100: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/widelands_geometry.h:113: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/widelands_geometry.h:117: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/widelands_geometry.h:151: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/widelands_geometry.h:154: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/widelands_geometry.h:168: (performance) Parameter 'Triangle' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/widelands.h:102: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/widelands.h:103: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/widelands.h:104: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/widelands.h:105: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/field.h:138: (performance) Parameter 't' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/message_id.h:49: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/message_id.h:50: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/message_id.h:51: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/message_queue.h:70: (performance) Parameter 'id' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/message_queue.h:109: (performance) Parameter 'id' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/message_queue.h:125: (performance) Parameter 'id' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/production_program.h:180: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/production_program.h:193: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/productionsite.h:77: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/productionsite.h:80: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/productionsite.h:273: (performance) Parameter 'Ware' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/tribe.h:77: (performance) Parameter 'index' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/tribe.h:96: (performance) Parameter 'index' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/tribe.h:99: (performance) Parameter 'index' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/tribe.h:102: (performance) Parameter 'index' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/tribe.h:111: (performance) Parameter 'index' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/player.h:102: (performance) Parameter 'id' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/player.h:399: (performance) Parameter 'area' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/player.h:412: (performance) Parameter 'area' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/player.h:430: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/player.h:436: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/player.h:533: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/descr_maintainer.h:133: (performance) Parameter 'idx' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/descr_maintainer.h:69: (performance) Parameter 'n' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/io/basic_filewrite.h:79: (performance) Parameter 'pos' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/io/basic_filewrite.h:86: (performance) Parameter 'pos' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/io/basic_fileread.h:98: (performance) Parameter 'pos' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/io/basic_fileread.h:117: (performance) Parameter 'pos' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/io/basic_fileread.h:130: (performance) Parameter 'pos' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/machdep.h:70: (error) Uninitialized variable: s
src/machdep.h:72: (error) Uninitialized variable: s
src/machdep.h:74: (error) Uninitialized variable: s
src/machdep.h:76: (error) Uninitialized variable: s
src/machdep.h:78: (error) Uninitialized variable: s
src/rect.h:27: (performance) Parameter 'p' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/warelist.h:55: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/economy/economy.h:119: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/economy/economy.h:122: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/economy/economy.h:136: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/economy/economy.h:139: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/economy/economy.h:142: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/economy/economy.h:145: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/chat.cc:74: (portability) Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'.
src/map_io/widelands_map_message_saver.h:43: (performance) Parameter 'id' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/map_io/widelands_map_message_saver.h:47: (performance) Parameter 'id' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/economy/warehousesupply.h:44: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/economy/warehousesupply.h:47: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/economy/fleet.cc:278: (error) Reference to temporary returned.
src/economy/fleet.cc:288: (error) Reference to temporary returned.
src/economy/test/test_road.cc:35: (performance) Parameter 'c' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/economy/test/test_routing.cc:97] -> [src/economy/test/test_routing.cc:97: (style) Finding the same expression on both sides of an operator is suspicious and might indicate a cut and paste or logic error. Please examine this code carefully to determine if it is correct.
src/economy/test/test_routing.cc:411: (performance) Parameter 'pos' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/overlay_manager.h:68: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/overlay_manager.h:72: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/overlay_manager.h:171: (performance) Parameter 'Jobid' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/overlay_manager.h:173: (performance) Parameter 'Hotspot' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/editor/tools/editor_set_height_tool.h:50: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/editor/tools/editor_noise_height_tool.h:29: (performance) Parameter 'the_interval' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/editor/tools/editor_noise_height_tool.h:54: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/ui_basic/checkbox.h:97: (performance) Parameter 'p' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/editor/tools/editor_decrease_height_tool.cc:65: (performance) Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
src/editor/tools/editor_increase_resources_tool.cc:33: (performance) Parameter 'c' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/editor/tools/editor_set_height_tool.cc:64: (performance) Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
src/editor/ui_menus/editor_main_menu_new_map.cc] -> [src/editor/ui_menus/editor_main_menu_new_map.cc:61: (error) Internal error. Token::Match called with varid 0. Please report this to Cppcheck developers
src/editor/ui_menus/editor_main_menu_random_map.cc] -> [src/editor/ui_menus/editor_main_menu_random_map.cc:97: (error) Internal error. Token::Match called with varid 0. Please report this to Cppcheck developers
src/logic/cmd_expire_message.h:38: (performance) Parameter 'm' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/playercommand.h:92: (performance) Parameter 'c' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/playercommand.h:93: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/playercommand.h:114: (performance) Parameter 'c' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/playercommand.h:201: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/playercommand.h:550: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/playercommand.h:568: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/playercommand.h:583: (performance) Parameter 'i' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/gameview.cc:1191: (performance) Parameter 'rc' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/gameview.cc:1192: (performance) Parameter 'viewpoint' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/gameview.cc:1193: (performance) Parameter 'framepoint' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/gameview.cc:1130: (performance) Parameter 'ptopleft' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/gameview.cc:1131: (performance) Parameter 'pbottomright' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/terrain_sdl.h:563: (performance) Parameter 'start' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/terrain_sdl.h:563: (performance) Parameter 'end' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/terrain_sdl.h:536: (performance) Parameter 'start' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/terrain_sdl.h:536: (performance) Parameter 'end' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/gameview.cc:264: (error) Uninitialized variable: r_player_field
src/graphic/render/surface_sdl.cc:125: (style) Variable 'pix' is assigned a value that is never used
src/graphic/richtext.cc:395: (performance) Prefix ++/-- operators should be preferred for non-primitive types. Pre-increment/decrement can be more efficient than post-increment/decrement. Post-increment/decrement usually involves keeping a copy of the previous value around and adds a little extra code.
src/graphic/texture.cc:178: (error) Common realloc mistake: 'm_pixels' nulled but not freed upon failure
src/i18n.cc:164: (style) Variable 'alt_str' is assigned a value that is never used
src/io/dedicated_log.cc:46: (portability) Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'.
src/io/dedicated_log.cc:76: (portability) Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'.
src/io/dedicated_log.cc:163: (portability) Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'.
src/io/dedicated_log.cc:166: (portability) Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'.
src/io/dedicated_log.cc:200: (portability) Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'.
src/io/filesystem/filesystem.cc:69: (performance) When an object of a class is created, the constructors of all member variables are called consecutively in the order the variables are declared, even if you don't explicitly write them to the initialization list. You could avoid assigning 'm_root' a value by passing the value to the constructor in the initialization list.
(information) Skipping configuration 'ELOOP' because it seems to be invalid. Use -D if you want to check it. src/logic/building.cc:524: (style) Statements following return, break, continue, goto or throw will never be executed.
src/logic/building.cc:536: (style) Statements following return, break, continue, goto or throw will never be executed.
src/logic/dismantlesite.cc:67: (performance) Parameter 'c' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/game.cc:128: (warning) Member variable 'Game::m_replayreader' is not initialized in the constructor.
src/network/network.h:133: (style) The struct 'Deserializer' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instanciated. That may cause bugs or undefined behavior.
src/logic/game.cc:592: (style) The obsolete function 'usleep' is called. POSIX.1-2001 declares usleep() function obsolete and POSIX.1-2008 removes it. It is recommended that new applications use the 'nanosleep' or 'setitimer' function.
src/logic/immovable.cc:510: (performance) Parameter 'pos' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:1784: (style) Suspicious expression. Boolean result is used in bitwise operation. The ! operator and the comparison operators have higher precedence than bitwise operators. It is recommended that the expression is clarified with parentheses.
src/logic/map.cc:71: (warning) Member variable 'Map::m_filename' is not initialized in the constructor.
src/logic/map.cc:71: (warning) Member variable 'Map::m_author' is not initialized in the constructor.
src/logic/map.cc:71: (warning) Member variable 'Map::m_name' is not initialized in the constructor.
src/logic/map.cc:71: (warning) Member variable 'Map::m_description' is not initialized in the constructor.
src/logic/map.cc:629: (error) Common realloc mistake: 'm_starting_pos' nulled but not freed upon failure
src/logic/map.cc:795: (performance) Parameter 'area' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:812: (performance) Parameter 'cur' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:899: (performance) Parameter 'cur' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:1008: (performance) Parameter 'cur' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:750: (performance) Checking for 'queue' emptiness might be inefficient. Using queue.empty() instead of queue.size() can be faster. queue.size() can take linear time but queue.empty() is guaranteed to take constant time.
src/logic/player.cc:615: (performance) Parameter 'index_of_new_building' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/player.cc:1129: (performance) Parameter 'ware' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/player.cc:1141: (performance) Parameter 'ware' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/player.cc:1149: (performance) Parameter 'ware' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/playercommand.cc:210: (performance) When an object of a class is created, the constructors of all member variables are called consecutively in the order the variables are declared, even if you don't explicitly write them to the initialization list. You could avoid assigning 'bi' a value by passing the value to the constructor in the initialization list.
src/logic/playercommand.cc:262: (performance) When an object of a class is created, the constructors of all member variables are called consecutively in the order the variables are declared, even if you don't explicitly write them to the initialization list. You could avoid assigning 'coords' a value by passing the value to the constructor in the initialization list.
src/logic/playercommand.cc:315: (performance) When an object of a class is created, the constructors of all member variables are called consecutively in the order the variables are declared, even if you don't explicitly write them to the initialization list. You could avoid assigning 'start' a value by passing the value to the constructor in the initialization list.
src/logic/replay.cc:182: (style) The second of the two statements can never be executed, and so should be removed.
src/logic/soldier.cc:547: (performance) Parameter 'pos' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/soldier.cc:194: (performance) The conversion from const char* as returned by c_str to std::string creates an unnecessary string copy. Solve that by directly passing the string.
src/logic/world.cc:259: (style) Variable 'res_str' is assigned a value that is never used
src/map_generator.cc:459: (style) The scope of the variable 'landType' can be reduced. Warning: It can be unsafe to fix this message. Be careful. Especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x) { int i = 0; if (x) { // it's safe to move 'int i = 0' here for (int n = 0; n < 10; ++n) { // it is possible but not safe to move 'int i = 0' here do_something(&i); } } } When you see this message it is always safe to reduce the variable scope 1 level. src/map_generator.cc:133: (performance) Parameter 'fc' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/map_generator.cc:444: (performance) Parameter 'c0' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/map_generator.cc:444: (performance) Parameter 'c1' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/map_generator.cc:444: (performance) Parameter 'c2' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/map_io/widelands_map_player_names_and_tribes_data_packet.cc:96: (style) Unused variable: name
src/map_io/widelands_map_player_names_and_tribes_data_packet.cc:96: (style) Unused variable: tribe
src/map_io/widelands_map_players_view_data_packet.cc:846: (style) Suspicious expression. Boolean result is used in bitwise operation. The ! operator and the comparison operators have higher precedence than bitwise operators. It is recommended that the expression is clarified with parentheses.
src/map_io/widelands_map_players_view_data_packet.cc:858: (style) Suspicious expression. Boolean result is used in bitwise operation. The ! operator and the comparison operators have higher precedence than bitwise operators. It is recommended that the expression is clarified with parentheses.
src/map_io/widelands_map_players_view_data_packet.cc:869: (style) Suspicious expression. Boolean result is used in bitwise operation. The ! operator and the comparison operators have higher precedence than bitwise operators. It is recommended that the expression is clarified with parentheses.
src/map_io/widelands_map_players_view_data_packet.cc:871: (style) Suspicious expression. Boolean result is used in bitwise operation. The ! operator and the comparison operators have higher precedence than bitwise operators. It is recommended that the expression is clarified with parentheses.
src/map_io/widelands_map_players_view_data_packet.cc:873: (style) Suspicious expression. Boolean result is used in bitwise operation. The ! operator and the comparison operators have higher precedence than bitwise operators. It is recommended that the expression is clarified with parentheses.
src/map_io/widelands_map_players_view_data_packet.cc:504: (error) Memory leak: mod
src/map_io/widelands_map_players_view_data_packet.cc:556: (error) Memory leak: mod
src/map_io/widelands_map_players_view_data_packet.cc:580: (error) Memory leak: mod
src/map_io/widelands_map_resources_data_packet.cc:123: (style) Variable 'smap' is assigned a value that is never used
src/network/internet_gaming.cc:107: (portability) Non reentrant function 'gethostbyname' called. For threadsafe applications it is recommended to use the reentrant replacement function 'gethostbyname_r'.
src/network/internet_gaming.cc:107: (style) Obsolete function 'gethostbyname' called. It is recommended to use the function 'getaddrinfo' instead.
src/gamesettings.h:168: (error) Reference to temporary returned.
src/network/netclient.cc:737: (error) Object pointed by an 'auto_ptr' is destroyed using operator 'delete'. This means that you should only use 'auto_ptr' for pointers obtained with operator 'new'. This excludes arrays, which are allocated by operator 'new[]' and must be deallocated by operator 'delete[]'.
src/network/netclient.cc:822: (error) Object pointed by an 'auto_ptr' is destroyed using operator 'delete'. This means that you should only use 'auto_ptr' for pointers obtained with operator 'new'. This excludes arrays, which are allocated by operator 'new[]' and must be deallocated by operator 'delete[]'.
src/network/nethost.cc:442: (style) Unused variable: name
src/network/nethost.cc:807: (style) Variable 'tips' is assigned a value that is never used
src/network/nethost.cc:2580: (style) Variable 'name' is assigned a value that is never used
src/network/nethost.cc:754: (style) The obsolete function 'usleep' is called. POSIX.1-2001 declares usleep() function obsolete and POSIX.1-2008 removes it. It is recommended that new applications use the 'nanosleep' or 'setitimer' function.
src/network/nethost.cc:761: (style) The obsolete function 'usleep' is called. POSIX.1-2001 declares usleep() function obsolete and POSIX.1-2008 removes it. It is recommended that new applications use the 'nanosleep' or 'setitimer' function.
src/network/nethost.cc:265: (performance) Parameter 'ps' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/network/nethost.cc:1140: (performance) Useless call of function 'substr' because it returns a copy of the object. Use operator= instead.
src/network/nethost.cc:731: (style) Variable 'needip' is assigned a value that is never used
src/scripting/lua_game.cc:463: (style) Variable 'title' is assigned a value that is never used
src/scripting/lua_game.cc:464: (style) Variable 'body' is assigned a value that is never used
src/scripting/lua_game.cc:985: (performance) When an object of a class is created, the constructors of all member variables are called consecutively in the order the variables are declared, even if you don't explicitly write them to the initialization list. You could avoid assigning 'm_name' a value by passing the value to the constructor in the initialization list.
src/scripting/lua_game.cc:150: (performance) The conversion from const char* as returned by c_str to std::string creates an unnecessary string copy. Solve that by directly passing the string.
src/scripting/lua_game.cc:169: (performance) The conversion from const char* as returned by c_str to std::string creates an unnecessary string copy. Solve that by directly passing the string.
src/scripting/lua_game.cc:989: (performance) The conversion from const char* as returned by c_str to std::string creates an unnecessary string copy. Solve that by directly passing the string.
src/scripting/lua_game.cc:1009: (performance) The conversion from const char* as returned by c_str to std::string creates an unnecessary string copy. Solve that by directly passing the string.
src/scripting/lua_game.cc:1019: (performance) The conversion from const char* as returned by c_str to std::string creates an unnecessary string copy. Solve that by directly passing the string.
src/scripting/lua_game.cc:1034: (performance) The conversion from const char* as returned by c_str to std::string creates an unnecessary string copy. Solve that by directly passing the string.
src/scripting/lua_map.cc:338: (style) Statements following return, break, continue, goto or throw will never be executed.
src/scripting/lua_map.cc:235: (performance) The conversion from const char* as returned by c_str to std::string creates an unnecessary string copy. Solve that by directly passing the string.
src/scripting/lua_map.cc:1054: (performance) The conversion from const char* as returned by c_str to std::string creates an unnecessary string copy. Solve that by directly passing the string.
src/scripting/lua_map.cc:1065: (performance) The conversion from const char* as returned by c_str to std::string creates an unnecessary string copy. Solve that by directly passing the string.
src/scripting/lua_map.cc:2375: (performance) The conversion from const char* as returned by c_str to std::string creates an unnecessary string copy. Solve that by directly passing the string.
src/scripting/lua_map.cc:2471: (performance) The conversion from const char* as returned by c_str to std::string creates an unnecessary string copy. Solve that by directly passing the string.
src/scripting/lua_map.cc:2493: (performance) The conversion from const char* as returned by c_str to std::string creates an unnecessary string copy. Solve that by directly passing the string.
src/scripting/pluto.cc:1002: (style) The scope of the variable 'sizep' can be reduced. Warning: It can be unsafe to fix this message. Be careful. Especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x) { int i = 0; if (x) { // it's safe to move 'int i = 0' here for (int n = 0; n < 10; ++n) { // it is possible but not safe to move 'int i = 0' here do_something(&i); } } } When you see this message it is always safe to reduce the variable scope 1 level. src/scripting/pluto.cc:1002: (style) The scope of the variable 'sizek' can be reduced. Warning: It can be unsafe to fix this message. Be careful. Especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x) { int i = 0; if (x) { // it's safe to move 'int i = 0' here for (int n = 0; n < 10; ++n) { // it is possible but not safe to move 'int i = 0' here do_something(&i); } } } When you see this message it is always safe to reduce the variable scope 1 level. src/scripting/pluto.cc:1334: (style) Variable 'stacksize' is assigned a value that is never used
src/text_parser.cc:106: (style) Unused variable: block_text
src/text_parser.cc:54: (performance) When an object of a class is created, the constructors of all member variables are called consecutively in the order the variables are declared, even if you don't explicitly write them to the initialization list. You could avoid assigning 'm_font_color' a value by passing the value to the constructor in the initialization list.
src/timestring.cc:34: (portability) Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'.
src/ui_basic/table.h:122: (performance) Parameter 'c' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/ui_fsmenu/internet_lobby.cc:400: (portability) Non reentrant function 'gethostbyname' called. For threadsafe applications it is recommended to use the reentrant replacement function 'gethostbyname_r'.
src/ui_fsmenu/internet_lobby.cc:400: (style) Obsolete function 'gethostbyname' called. It is recommended to use the function 'getaddrinfo' instead.
src/ui_fsmenu/internet_lobby.cc:312: (performance) Either inefficent or wrong usage of string::find. string::compare will be faster if string::find's result is compared with 0, because it will not scan the whole string. If your intention is to check that there are no findings in the string, you should compare with string::npos.
src/ui_fsmenu/launchMPG.cc:603: (performance) Either inefficent or wrong usage of string::find. string::compare will be faster if string::find's result is compared with 0, because it will not scan the whole string. If your intention is to check that there are no findings in the string, you should compare with string::npos.
src/ui_fsmenu/netsetup_lan.cc:157: (portability) Non reentrant function 'gethostbyname' called. For threadsafe applications it is recommended to use the reentrant replacement function 'gethostbyname_r'.
src/ui_fsmenu/netsetup_lan.cc:157: (style) Obsolete function 'gethostbyname' called. It is recommended to use the function 'getaddrinfo' instead.
src/wlapplication.cc:1769: (style) Suspicious expression. Boolean result is used in bitwise operation. The ! operator and the comparison operators have higher precedence than bitwise operators. It is recommended that the expression is clarified with parentheses.
src/wlapplication.cc:1926: (performance) Parameter 'ps' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wlapplication.cc:1479: (style) The obsolete function 'usleep' is called. POSIX.1-2001 declares usleep() function obsolete and POSIX.1-2008 removes it. It is recommended that new applications use the 'nanosleep' or 'setitimer' function.
src/wlapplication.cc:2291: (style) Variable 'name_length' is assigned a value that is never used
src/wui/encyclopedia_window.h:52: (performance) Parameter 'o' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/game_debug_ui.cc:291: (style) Expression is always false because 'else if' condition matches previous condition at line 289.
src/wui/game_debug_ui.cc:293: (style) Expression is always false because 'else if' condition matches previous condition at line 289.
src/wui/interactive_player.cc:446: (style) Suspicious expression. Boolean result is used in bitwise operation. The ! operator and the comparison operators have higher precedence than bitwise operators. It is recommended that the expression is clarified with parentheses.
src/wui/interactive_spectator.cc:277: (style) Suspicious expression. Boolean result is used in bitwise operation. The ! operator and the comparison operators have higher precedence than bitwise operators. It is recommended that the expression is clarified with parentheses.
src/vector.h:44: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/vector.h:49: (performance) Parameter 'other' is passed as a value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/military_box.cc:108: (style) The scope of the variable 'buf' can be reduced. Warning: It can be unsafe to fix this message. Be careful. Especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x) { int i = 0; if (x) { // it's safe to move 'int i = 0' here for (int n = 0; n < 10; ++n) { // it is possible but not safe to move 'int i = 0' here do_something(&i); } } } When you see this message it is always safe to reduce the variable scope 1 level. src/wui/military_box.cc:123: (style) The scope of the variable 'buf' can be reduced. Warning: It can be unsafe to fix this message. Be careful. Especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:
void f(int x) { int i = 0; if (x) { // it's safe to move 'int i = 0' here for (int n = 0; n < 10; ++n) { // it is possible but not safe to move 'int i = 0' here do_something(&i); } } } When you see this message it is always safe to reduce the variable scope 1 level. src/graphic/render/gameview.cc:1128: (style) The function 'draw_minimap_frameborder' is never used
src/editor/tools/editor_set_starting_pos_tool.cc:117: (style) The function 'get_current_player' is never used
src/ui_basic/multilineeditbox.cc:183: (style) The function 'get_maximum_bytes' is never used
src/scripting/pluto.cc:1314: (style) The function 'inreftable' is never used
src/scripting/test/test_luna.cc:128: (style) The function 'multitest' is never used
src/economy/flag.cc:318: (style) The function 'nr_of_roads' is never used
src/scripting/test/test_luna.cc:60: (style) The function 'set_prop1' is never used
src/scripting/test/test_luna.cc:85: (style) The function 'subtest' is never used
src/scripting/test/test_luna.cc:108: (style) The function 'virtualtest' is never used
(information) Cppcheck cannot find all the include files. Cppcheck can check the code without the include files found. But the results will probably be more accurate if all the include files are found. Please check your project's include directories and add all of them as include directories for Cppcheck. To see what files Cppcheck cannot find use --check-config.