Issues found by Cppcheck 1.66

src/io/machdep.h:45: (style) Unused variable: s
src/io/machdep.h:54: (style) Unused variable: s
src/io/machdep.h:68: (style) Unused variable: s
src/logic/field.h:58: (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 instantiated. That may cause bugs or undefined behavior.
src/economy/shippingitem.h:60: (style) The struct 'Loader' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior.
src/logic/player.h:142: (warning) Member variable 'Field::resource_amounts' is not initialized in the constructor.
src/ai/ai_help_structs.h:227: (warning) Member variable 'BuildableField::unowned_mines_pots_nearby_' is not initialized in the constructor.
src/base/md5.h:75: (warning) Member variable 'MD5Checksum::sum' is not initialized in the constructor.
src/logic/findnode.h:61: (style) Value of pointer 'capsule', which points to allocated memory, is copied in copy constructor instead of allocating new memory.
src/economy/trackptr.h:41: (style) 'class Trackable' does not have a copy constructor which is recommended since the class contains a pointer to allocated memory.
src/logic/widelands_geometry.h:157: (performance) Parameter 'other' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/widelands_geometry.h:160: (performance) Parameter 'other' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/message.h:52: (performance) Parameter 'c' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/ai/ai_help_structs.cc:63: (performance) Parameter 'dest' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/ai/defaultai.cc:1100: (style) Expression is always false because 'else if' condition matches previous condition at line 1015.
src/ai/defaultai.cc:962: (warning) The expression '0' is of type 'bool' and it is compared against an integer value.
src/ai/defaultai.cc:984: (warning) The expression '2' is of type 'bool' and it is compared against an integer value.
src/ai/defaultai.cc:986: (warning) The expression '1' is of type 'bool' and it is compared against an integer value.
src/ai/defaultai.cc:2029: (warning) The expression '0' is of type 'bool' and it is compared against an integer value.
src/ai/defaultai.cc:2653: (style) The scope of the variable 'position' can be reduced. Warning: Be careful when fixing this message, 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/logic/findimmovable.h:60: (style) Value of pointer 'capsule', which points to allocated memory, is copied in copy constructor instead of allocating new memory.
src/base/i18n.cc:241: (style) Variable 'alt_str' is assigned a value that is never used.
src/base/md5.h:75: (warning) Member variable 'MD5Checksum::sum' is not initialized in the constructor.
src/io/fileread.h:56: (performance) Parameter 'other' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/io/filewrite.h:56: (performance) Parameter 'other' is passed by 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:44: (performance) Parameter 'id' is passed by 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:48: (performance) Parameter 'id' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/economy/flag.cc:115: (performance) Parameter 'coords' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/widelands_geometry_io.h:109: (performance) Parameter 'area' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/ui_basic/checkbox.h:96: (performance) Parameter 'p' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/ui_basic/slider.h:189: (performance) Parameter 'labels_in' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/plot_area.h:94: (performance) Parameter 'color' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/overlay_manager.h:122: (performance) Parameter 'c' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/overlay_manager.h:134: (performance) Parameter 'init_hotspot' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/interactive_base.h:161: (performance) Parameter 'Pos' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/economy/test/test_road.cc:41: (performance) Parameter 'c' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/economy/test/test_routing.cc:181: (style) 'struct TestingNode_DefaultNodes_Fixture' does not have a copy constructor which is recommended since the class contains a pointer to allocated memory.
src/economy/test/test_routing.cc:227: (style) 'struct SimpleRouterFixture' does not have a copy constructor which is recommended since the class contains a pointer to allocated memory.
src/economy/test/test_routing.cc:393: (style) 'struct ComplexRouterFixture' does not have a copy constructor which is recommended since the class contains a pointer to allocated memory.
src/economy/test/test_routing.cc:413: (performance) Parameter 'pos' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/editor/tools/editor_tool_action.h:62: (style) Value of pointer 'args', which points to allocated memory, is copied in copy constructor instead of allocating new memory.
src/editor/tools/editor_tool.h:51: (performance) Parameter 'center' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/editor/tools/editor_tool.h:61: (performance) Parameter 'center' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/editor/tools/editor_history.h:46: (performance) Parameter 'center' is passed by 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:54: (performance) Parameter 'i' is passed by 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 by 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:58: (performance) Parameter 'i' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/image.h:47: (style) The Image::operator= does not conform to standard C/C++ behaviour. To conform to standard C/C++ behaviour, return a reference to self (such as: 'Image &Image::operator=(..) { .. return *this; }'. For safety reasons it might be better to not fix this message. If you think that safety is always more important than conformance then please ignore/suppress this message. For more details about this topic, see the book "Effective C++" by Scott Meyers.
src/editor/map_generator.h:99: (performance) Parameter 'fc' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/editor/map_generator.h:111: (performance) Parameter 'c0' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/editor/map_generator.h:111: (performance) Parameter 'c1' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/editor/map_generator.h:111: (performance) Parameter 'c2' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/editor/ui_menus/editor_main_menu_random_map.cc:536: (performance, inconclusive) The const variable 'text' is assigned a copy of the data. You can avoid the unnecessary data copying by converting 'text' to const reference.
src/editor/ui_menus/categorized_item_selection_menu.h:51: (performance) Parameter 'select_correct_tool' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/interactive_player.h:82: (performance) Parameter 'location' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/game_io/game_preload_data_packet.h:34: (style) The struct 'Game_Preload_Data_Packet' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior.
src/logic/cmd_expire_message.h:40: (performance) Parameter 'm' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/colormap.h:30: (style) 'class Colormap' does not have a copy constructor which is recommended since the class contains a pointer to allocated memory.
src/graphic/font_handler1.h:51: (style) The IFont_Handler1::operator= does not conform to standard C/C++ behaviour. To conform to standard C/C++ behaviour, return a reference to self (such as: 'IFont_Handler1 &IFont_Handler1::operator=(..) { .. return *this; }'. For safety reasons it might be better to not fix this message. If you think that safety is always more important than conformance then please ignore/suppress this message. For more details about this topic, see the book "Effective C++" by Scott Meyers.
src/graphic/graphic.cc:72: (warning) Member variable 'Graphic::m_sdl_screen' is not initialized in the constructor.
src/graphic/graphic.cc:72: (warning) Member variable 'Graphic::m_caps' is not initialized in the constructor.
src/graphic/image_io.cc:69: (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/graphic/render/gamerenderer.cc:32: (warning) Member variable 'GameRenderer::m_dst' is not initialized in the constructor.
src/graphic/render/gamerenderer.cc:32: (warning) Member variable 'GameRenderer::m_egbase' is not initialized in the constructor.
src/graphic/render/gamerenderer.cc:32: (warning) Member variable 'GameRenderer::m_player' is not initialized in the constructor.
src/graphic/render/gamerenderer.cc:32: (warning) Member variable 'GameRenderer::m_minfx' is not initialized in the constructor.
src/graphic/render/gamerenderer.cc:32: (warning) Member variable 'GameRenderer::m_minfy' is not initialized in the constructor.
src/graphic/render/gamerenderer.cc:32: (warning) Member variable 'GameRenderer::m_maxfx' is not initialized in the constructor.
src/graphic/render/gamerenderer.cc:32: (warning) Member variable 'GameRenderer::m_maxfy' is not initialized in the constructor.
src/graphic/render/gamerenderer_gl.cc:44: (warning) Member variable 'GameRendererGL::m_surface' is not initialized in the constructor.
src/graphic/render/gamerenderer_gl.cc:44: (warning) Member variable 'GameRendererGL::m_road_freq' is not initialized in the constructor.
src/graphic/render/terrain_sdl.h:557: (performance) Parameter 'start' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/terrain_sdl.h:557: (performance) Parameter 'end' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/terrain_sdl.h:530: (performance) Parameter 'start' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/terrain_sdl.h:530: (performance) Parameter 'end' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/gl_surface.cc:64: (performance) Parameter 'clr' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/gl_surface.cc:85: (performance) Parameter 'clr' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/gl_surface_texture.cc:238: (performance) Parameter 'clr' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/gl_surface_texture.cc:252: (performance) Parameter 'clr' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/sdl_surface.cc:153: (performance) Parameter 'clr' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/render/sdl_surface.cc:178: (performance) Parameter 'clr' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/graphic/richtext.cc:209: (style) struct or union member 'TextBuilder::linespacing' is never used.
src/graphic/richtext.cc:455: (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/text/rt_render.cc:458: (warning) Member variable 'SubTagRenderNode::m_w' is not initialized in the constructor.
src/graphic/text/rt_render.cc:458: (warning) Member variable 'SubTagRenderNode::m_h' is not initialized in the constructor.
src/graphic/text_parser.cc:51: (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/io/dedicated_log.h:31: (style) 'struct DedicatedLog' does not have a copy constructor which is recommended since the class contains a pointer to allocated memory.
src/io/fileread.cc:60: (performance) Parameter 'pos' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/io/fileread.cc:80: (performance) Parameter 'pos' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/io/fileread.cc:92: (performance) Parameter 'pos' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/io/filesystem/disk_filesystem.cc:348: (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/io/filesystem/disk_filesystem.cc:357: (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/io/filesystem/filesystem.cc:65: (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.
src/io/filesystem/filesystem.cc:1: (information) Skipping configuration 'ELOOP' since the value of 'ELOOP' is unknown. Use -D if you want to check it. You can use -U to skip it explicitly.
src/io/filewrite.cc:53: (performance) Parameter 'pos' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/battle.cc:57: (warning) Member variable 'Battle::m_creationtime' is not initialized in the constructor.
src/logic/battle.cc:57: (warning) Member variable 'Battle::m_last_attack_hits' is not initialized in the constructor.
src/logic/bob.cc:780: (performance) Parameter 'pos' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/building.cc:522: (style) Statements following return, break, continue, goto or throw will never be executed.
src/logic/building.cc:534: (style) Statements following return, break, continue, goto or throw will never be executed.
src/logic/building.cc:263: (warning) Member variable 'Building::m_priority' is not initialized in the constructor.
src/logic/building.cc:201: (performance) Parameter 'fc' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/checkstep.cc:62: (performance) Parameter 'start' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/checkstep.cc:62: (performance) Parameter 'end' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/checkstep.cc:74: (performance) Parameter 'dest' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/checkstep.cc:106: (performance) Parameter 'dest' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/checkstep.cc:129: (performance) Parameter 'start' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/checkstep.cc:130: (performance) Parameter 'end' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/checkstep.cc:165: (performance) Parameter 'start' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/checkstep.cc:165: (performance) Parameter 'end' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/checkstep.cc:196: (performance) Parameter 'dest' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/checkstep.cc:213: (performance) Parameter 'end' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/playercommand.h:92: (warning) Member variable 'Cmd_Build::bi' is not initialized in the constructor.
src/logic/playercommand.h:201: (warning) Member variable 'Cmd_MilitarySiteSetSoldierPreference::preference' is not initialized in the constructor.
src/logic/playercommand.h:221: (warning) Member variable 'Cmd_StartOrCancelExpedition::serial' is not initialized in the constructor.
src/logic/playercommand.h:241: (warning) Member variable 'Cmd_EnhanceBuilding::bi' is not initialized in the constructor.
src/logic/playercommand.h:313: (warning) Member variable 'Cmd_ShipScoutDirection::dir' is not initialized in the constructor.
src/logic/playercommand.h:357: (warning) Member variable 'Cmd_ShipExploreIsland::clockwise' is not initialized in the constructor.
src/logic/playercommand.h:96: (performance) Parameter 'c' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/playercommand.h:118: (performance) Parameter 'c' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/playercommand.h:684: (performance) Parameter 'i' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/playercommand.h:702: (performance) Parameter 'i' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/playercommand.h:717: (performance) Parameter 'i' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/dismantlesite.cc:69: (performance) Parameter 'c' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:69: (warning) Member variable 'Map::m_filename' is not initialized in the constructor.
src/logic/map.cc:69: (warning) Member variable 'Map::m_author' is not initialized in the constructor.
src/logic/map.cc:69: (warning) Member variable 'Map::m_name' is not initialized in the constructor.
src/logic/map.cc:69: (warning) Member variable 'Map::m_description' is not initialized in the constructor.
src/logic/map.cc:84: (performance) Parameter 'fc' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:352: (performance) Parameter 'new_origin' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:539: (performance) Parameter 'c' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:591: (performance) Parameter 'coord' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:659: (performance) Parameter 'area' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:676: (performance) Parameter 'cur' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:763: (performance) Parameter 'cur' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:874: (performance) Parameter 'cur' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:967: (performance) Parameter 'f' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:1012: (performance) Parameter 'f' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:1016: (performance) Parameter 'f' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:1130: (performance) Parameter 'f' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:1398: (performance) Parameter 'a' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:1398: (performance) Parameter 'b' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:1472: (performance) Parameter 'a' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:1472: (performance) Parameter 'b' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:1481: (performance) Parameter 'a' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:1481: (performance) Parameter 'b' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:1533: (performance) Parameter 'coords' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:1555: (performance) Parameter 'coords' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:1819: (performance) Parameter 'field' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map.cc:1862: (performance) Parameter 'fc' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/map_revision.cc:31: (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_map_creator_version' a value by passing the value to the constructor in the initialization list.
src/logic/maphollowregion.h:35: (performance) Parameter 'hollow_area' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/path.cc:123: (performance) Parameter 'c' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/playercommand.cc:1826: (warning) Member variable 'Cmd_SetStockPolicy::m_ware' is not initialized in the constructor.
src/logic/playercommand.cc:283: (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:336: (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/production_program.cc:1247: (style) The scope of the variable 'pick' can be reduced. Warning: Be careful when fixing this message, 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/logic/ship.cc:934: (warning) Member variable 'Loader::m_ship_state' is not initialized in the constructor.
src/logic/single_player_game_settings_provider.cc:46: (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/single_player_game_settings_provider.cc:212: (performance) Parameter 'ps' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/soldier.cc:513: (performance) Parameter 'pos' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/trainingsite.cc:767: (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/logic/widelands_geometry_io.cc:103: (performance) Parameter 'area' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/logic/worker.cc:2832: (style) The scope of the variable 'oldest_distance' can be reduced. Warning: Be careful when fixing this message, 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/logic/worker.cc:782: (style) Unused variable: is_tribe_specific
src/map_io/widelands_map_bob_data_packet.cc:37: (performance) Parameter 'coords' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/map_io/widelands_map_buildingdata_data_packet.cc:1563: (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/map_io/widelands_map_elemental_data_packet.h:37: (style) The struct 'Map_Elemental_Data_Packet' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior.
src/map_io/widelands_map_port_spaces_data_packet.h:32: (style) The struct 'Map_Port_Spaces_Data_Packet' does not have a constructor although it has private member variables. Member variables of builtin types are left uninitialized when the class is instantiated. That may cause bugs or undefined behavior.
src/map_io/widelands_map_players_view_data_packet.cc:1122: (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:1133: (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:1143: (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:1145: (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:1147: (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/profile/profile.cc:618: (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/third_party/minizip/unzip.cc:699: (style) Variable 'lSeek' is assigned a value that is never used.
src/third_party/minizip/unzip.cc:260: (error) Memory leak: buf
src/third_party/minizip/unzip.cc:954: (error) Memory leak: pfile_in_zip_read_info
src/third_party/minizip/unzip.cc:1633: (error) Memory leak: buf
src/third_party/minizip/unzip.cc:1721: (error) Memory leak: zi
src/ui_basic/listselect.cc:267: (performance) Parameter 'col' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/ui_basic/panel.cc:189: (style) The scope of the variable 'startTime' can be reduced. Warning: Be careful when fixing this message, 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/ui_basic/panel.cc:190: (style) The scope of the variable 'diffTime' can be reduced. Warning: Be careful when fixing this message, 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/ui_basic/panel.cc:304: (performance) Parameter 'n' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/ui_basic/panel.cc:612: (performance) Parameter 'p' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/ui_basic/progresswindow.cc:167: (error) Same iterator is used with different containers 'visualizations' and 'm_visualizations'.
src/ui_basic/scrollbar.cc:246: (performance) Parameter 'r' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/ui_basic/scrollbar.cc:296: (performance) Parameter 'r' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/ui_basic/slider.cc:553: (performance) Parameter 'labels_in' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/ui_basic/table.h:146: (warning) Member variable '_data::d_picture' is not initialized in the constructor.
src/ui_basic/table.h:124: (performance) Parameter 'c' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/ui_fsmenu/options.h:37: (style) 'class Options_Ctrl' does not have a copy constructor which is recommended since the class contains a pointer to allocated memory.
src/wlapplication.cc:276: (warning) Assignment of function parameter has no effect outside the function.
src/wlapplication.cc:346: (warning) Assignment of function parameter has no effect outside the function.
src/wlapplication.cc:1799: (error) Resource leak: newfp
src/wlapplication.cc:1809: (error) Resource leak: newfp
src/logic/single_player_game_settings_provider.h:56: (performance) Parameter 'ps' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wlapplication.cc:666: (performance) Parameter 'position' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wlapplication.cc:1784: (style) Variable 'name_length' is assigned a value that is never used.
src/wui/attack_box.cc:140: (style) The scope of the variable 'buf' can be reduced. Warning: Be careful when fixing this message, 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/encyclopedia_window.h:49: (performance) Parameter 'o' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/game_debug_ui.cc:482: (performance) Parameter 'coords' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/gamechatpanel.cc:60: (performance, inconclusive) The const variable 'msgs' is assigned a copy of the data. You can avoid the unnecessary data copying by converting 'msgs' to const reference.
src/wui/interactive_player.cc:420: (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_player.cc:70: (performance) Parameter 'c' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/interactive_spectator.cc:272: (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/vector.h:42: (performance) Parameter 'other' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/vector.h:47: (performance) Parameter 'other' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/overlay_manager.cc:29: (warning) Member variable 'OverlayManager::m_buildhelp_infos' is not initialized in the constructor.
src/wui/plot_area.cc:415: (performance) Parameter 'color' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/wui/watchwindow.cc:400: (performance) Parameter 'coords' is passed by value. It could be passed as a (const) reference which is usually faster and recommended in C++.
src/editor/tools/editor_make_infrastructure_tool.cc:34: (style) The function 'Editor_Make_Infrastructure_Tool_Callback' is never used.
src/io/filewrite.cc:83: (style) The function 'GetData' is never used.
src/wui/interactive_player.cc:69: (style) The function 'Int_Player_overlay_callback_function' is never used.
src/logic/widelands_geometry_io.cc:79: (style) The function 'ReadArea48' is never used.
src/io/filesystem/layered_filesystem.cc:63: (style) The function 'RemoveFileSystem' is never used.
src/logic/replay.cc:276: (style) The function 'SendPlayerCommand' is never used.
src/io/fileread.cc:60: (style) The function 'SetFilePos' is never used.
src/io/filewrite.cc:53: (style) The function 'SetPos' is never used.
src/logic/widelands_geometry_io.cc:103: (style) The function 'WriteArea48' is never used.
src/economy/economy.cc:955: (style) The function 'accept_warehouse_if_policy' is never used.
src/logic/instances.cc:295: (style) The function 'add_attributes' is never used.
src/logic/world/world.cc:69: (style) The function 'add_critter_type' is never used.
src/logic/world/world.cc:89: (style) The function 'add_editor_immovable_category' is never used.
src/logic/world/world.cc:81: (style) The function 'add_editor_terrain_category' is never used.
src/economy/flag.cc:770: (style) The function 'add_flag_job' is never used.
src/logic/world/world.cc:77: (style) The function 'add_immovable_type' is never used.
src/logic/world/world.cc:61: (style) The function 'add_resource_type' is never used.
src/logic/world/world.cc:65: (style) The function 'add_terrain_type' is never used.
src/graphic/graphic.cc:477: (style) The function 'animate_maptextures' is never used.
src/economy/road.cc:434: (style) The function 'assign_carrier' is never used.
src/ai/defaultai.cc:2338: (style) The function 'calculate_need_for_ps' is never used.
src/logic/single_player_game_settings_provider.cc:41: (style) The function 'canChangeMap' is never used.
src/logic/single_player_game_settings_provider.cc:61: (style) The function 'canLaunch' is never used.
src/io/dedicated_log.cc:105: (style) The function 'chatAddSpacer' is never used.
src/wui/game_chat_menu.cc:60: (style) The function 'create_script_console' is never used.
src/logic/replay_game_controller.cc:88: (style) The function 'desiredSpeed' is never used.
src/logic/warehouse.cc:1183: (style) The function 'disable_spawn' is never used.
src/logic/warehouse.cc:1173: (style) The function 'enable_spawn' is never used.
src/network/network.cc:49: (style) The function 'fastforward' is never used.
src/io/filesystem/filesystem.cc:110: (style) The function 'fixCrossFile' is never used.
src/ui_fsmenu/base.cc:115: (style) The function 'font_big' is never used.
src/io/dedicated_log.cc:148: (style) The function 'game_end' is never used.
src/io/dedicated_log.cc:135: (style) The function 'game_start' is never used.
src/wui/debugconsole.cc:119: (style) The function 'getChatProvider' is never used.
src/logic/replay_game_controller.cc:76: (style) The function 'getFrametime' is never used.
src/logic/replay_game_controller.cc:80: (style) The function 'getGameDescription' is never used.
src/ui_basic/spinbox.cc:246: (style) The function 'getUnit' is never used.
src/logic/single_player_game_settings_provider.cc:233: (style) The function 'getWinConditionScript' is never used.
src/wui/overlay_manager.cc:306: (style) The function 'get_a_job_id' is never used.
src/logic/instances.cc:335: (style) The function 'get_attribute_name' is never used.
src/wui/interactive_gamebase.cc:67: (style) The function 'get_chat_provider' is never used.
src/editor/tools/editor_set_starting_pos_tool.cc:108: (style) The function 'get_current_player' is never used.
src/wui/interactive_gamebase.cc:48: (style) The function 'get_game' is never used.
src/graphic/render/terrain_sdl.cc:24: (style) The function 'get_horiz_linearcomb' is never used.
src/logic/warehouse.cc:686: (style) The function 'get_incorporated_workers' is never used.
src/logic/ship.cc:99: (style) The function 'get_lastdock' is never used.
src/base/i18n.cc:318: (style) The function 'get_locale' is never used.
src/ui_basic/multilineeditbox.cc:181: (style) The function 'get_maximum_bytes' is never used.
src/logic/world/world.cc:134: (style) The function 'get_nr_immovables' is never used.
src/ui_basic/spinbox.cc:345: (style) The function 'has_replacement' is never used.
src/map_io/one_world_legacy_lookup_table.cc:51: (style) The function 'lookup_immovable' is never used.
src/editor/ui_menus/editor_player_menu.cc:385: (style) The function 'make_infrastructure_clicked' is never used.
src/network/network.cc:97: (style) The function 'networktime' is never used.
src/graphic/graphic.cc:468: (style) The function 'new_maptexture' is never used.
src/logic/single_player_game_settings_provider.cc:241: (style) The function 'nextWinCondition' is never used.
src/economy/flag.cc:313: (style) The function 'nr_of_roads' is never used.
src/logic/warehouse.cc:1351: (style) The function 'outcorporateSoldier' is never used.
src/logic/worker_program.cc:187: (style) The function 'parse_setdescription' is never used.
src/graphic/image_transformations.cc:456: (style) The function 'player_colored' is never used.
src/graphic/image_io.cc:44: (style) The function 'png_flush_function' is never used.
src/graphic/image_io.cc:38: (style) The function 'png_write_function' is never used.
src/graphic/text/rt_render.cc:84: (style) The function 'query' is never used.
src/logic/map.cc:187: (style) The function 'recalc_default_resources' is never used.
src/editor/tools/editor_history.cc:77: (style) The function 'redo_action' is never used.
src/wui/overlay_manager.cc:302: (style) The function 'remove_overlay_callback_function' is never used.
src/ui_basic/spinbox.cc:333: (style) The function 'remove_replacement' is never used.
src/logic/single_player_game_controller.cc:132: (style) The function 'report_result' is never used.
src/logic/cmd_queue.cc:101: (style) The function 'run_queue' is never used.
src/logic/worker.cc:318: (style) The function 'run_setdescription' is never used.
src/economy/shippingitem.cc:140: (style) The function 'schedule_update' is never used.
src/logic/militarysite.cc:980: (style) The function 'sendAttacker' is never used.
src/logic/replay_game_controller.cc:72: (style) The function 'sendPlayerCommand' is never used.
src/ui_basic/editbox.cc:157: (style) The function 'setMaxLength' is never used.
src/logic/single_player_game_settings_provider.cc:115: (style) The function 'setPlayerAI' is never used.
src/logic/single_player_game_settings_provider.cc:199: (style) The function 'setPlayerCloseable' is never used.
src/logic/single_player_game_settings_provider.cc:207: (style) The function 'setPlayerName' is never used.
src/logic/single_player_game_settings_provider.cc:33: (style) The function 'setScenario' is never used.
src/ui_basic/spinbox.cc:228: (style) The function 'setUnit' is never used.
src/logic/single_player_game_settings_provider.cc:237: (style) The function 'setWinConditionScript' is never used.
src/graphic/richtext.cc:163: (style) The function 'set_background_color' is never used.
src/logic/campaign_visibility.cc:166: (style) The function 'set_campaign_visibility' is never used.
src/wui/mapview.cc:116: (style) The function 'set_changeview' is never used.
src/io/dedicated_log.cc:244: (style) The function 'set_chat_file_path' is never used.
src/wui/interactive_gamebase.cc:59: (style) The function 'set_chat_provider' is never used.
src/ui_basic/listselect.cc:266: (style) The function 'set_entry_color' is never used.
src/graphic/text/rt_render.cc:122: (style) The function 'set_halign' is never used.
src/io/dedicated_log.cc:273: (style) The function 'set_info_file_path' is never used.
src/wui/itemwaresdisplay.cc:79: (style) The function 'set_itemsperrow' is never used.
src/logic/soldier.cc:379: (style) The function 'set_level' is never used.
src/io/dedicated_log.cc:299: (style) The function 'set_log_file_path' is never used.
src/logic/campaign_visibility.cc:184: (style) The function 'set_map_visibility' is never used.
src/ui_basic/multilineeditbox.cc:168: (style) The function 'set_maximum_bytes' is never used.
src/ui_basic/slider.cc:127: (style) The function 'set_min_value' is never used.
src/io/dedicated_log.cc:116: (style) The function 'set_server_data' is never used.
src/io/dedicated_log.cc:126: (style) The function 'set_server_ip' is never used.
src/wui/quicknavigation.cc:41: (style) The function 'set_setview' is never used.
src/economy/portdock.cc:424: (style) The function 'start_expedition' is never used.
src/ui_basic/progresswindow.cc:143: (style) The function 'stepf' is never used.
src/logic/building.cc:201: (style) The function 'suitability' is never used.
src/ui_basic/listselect.cc:206: (style) The function 'switch_entries' is never used.
src/editor/tools/editor_history.cc:58: (style) The function 'undo_action' is never used.
src/wui/waresdisplay.cc:422: (style) The function 'unhide_ware' is never used.
src/wui/quicknavigation.cc:53: (style) The function 'view_changed' is never used.
src/wui/waresdisplay.cc:431: (style) The function 'ware_hidden' is never used.
src/logic/productionsite.cc:434: (style) The function 'warp_worker' is never used.
src/graphic/render/minimaprenderer.cc:286: (style) The function 'write_minimap_image' 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.