Remove this ad

Lead

Jan 9 14 11:57 PM

Tags : :

More static cpp checker runs - mostly it's picked up minor stuff, but some items stand out

Note that it's picked up a division by zero error in Partfile.cpp

[src/FriendList.h:66]: (performance) Variable 'm_it' is assigned in constructor body. Consider performing initialization in initialization list.
[src/SearchList.h:53] -> [src/SearchFile.h:37]: (style, inconclusive) The typedef 'CSearchResultList' hides a typedef with the same name.
[src/amule-remote-gui.h:623]: (style) The class 'CamuleRemoteGuiApp' does not have a constructor.
[src/Types.h:110] -> [src/Types.h:44]: (style, inconclusive) The typedef 'byte' hides a typedef with the same name.
[src/Preferences.h:348] -> [src/SharedFileList.h:50]: (style, inconclusive) The typedef 'PathList' hides a typedef with the same name.
[src/GapList.h:97]: (performance) Variable 'm_it' is assigned in constructor body. Consider performing initialization in initialization list.
[src/ClientCredits.h:59]: (style) 'class CClientCredits' does not have a copy constructor which is recommended since the class contains a pointer to allocated memory.
[src/ClientDetailDialog.cpp:54]: (performance) Variable 'm_client' is assigned in
constructor body. Consider performing initialization in initialization list.
[src/DownloadClient.cpp:1175]: (style) The scope of the variable 'tAverage' can be reduced.

[snippage]


[src/ExternalConn.cpp:1948]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[src/ExternalConn.cpp:2011]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[src/ExternalConn.cpp:2050]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[src/ExternalConn.cpp:1]: (information) Skipping configuration 'EC_VERSION_ID' because it seems to be invalid. Use -D if you want to check it.

[src/ExternalConnector.cpp:554]: (warning) Possible leak in public function. The pointer 'm_strFullVersion' is not deallocated before it is allocated.

[src/IPFilterScanner.cpp:1531] -> [src/IPFilterScanner.cpp:1528]: (warning, inconclusive) Possible null pointer dereference: b - otherwise it is redundant to check it against null.
[src/IPFilterScanner.cpp:1536] -> [src/IPFilterScanner.cpp:1528]: (warning, inconclusive) Possible null pointer dereference: b - otherwise it is redundant to check it against null.

[src/StateMachine.cpp:77]: (warning) %d in format string (no. 2) requires a signed integer given in the argument list.
[src/StateMachine.cpp:77]: (warning) %d in format string (no. 3) requires a signed integer given in the argument list.
[src/StateMachine.cpp:77]: (warning) %d in format string (no. 4) requires a signed integer given in the argument list.
[src/Statistics.h:216]: (style) 'class CStatistics' does not have a copy constructor which is recommended since the class contains a pointer to allocated memory.

[src/UPnPBase.cpp:90]: (performance) Variable 'm_port' is assigned in constructor body. Consider performing initialization in initialization list.
[src/UPnPBase.cpp:316]: (warning) Redundant code: Found a statement that begins with numeric constant.

[src/UploadClient.cpp:162] -> [src/UploadClient.cpp:171]: (performance) Variable 'last_done_part' is reassigned a value before the old one has been used.
[src/UploadClient.cpp:163] -> [src/UploadClient.cpp:172]: (performance) Variable 'next_requested_part' is reassigned a value before the old one has been used.

[src/kademlia/kademlia/SearchManager.cpp:124]: (performance) Possible inefficient checking for 'm_words' emptiness.
[src/kademlia/net/KademliaUDPListener.cpp:468]: (style) The scope of the variable 'contact' can be reduced.
[src/kademlia/net/KademliaUDPListener.cpp:670]: (style) The scope of the variable 'c' can be reduced.


you get the idea....
Quote    Reply   
Remove this ad
Remove this ad

#2 [url]

Jan 10 14 6:14 PM

Re: cppcheck....

The critical ones:

$ grep error ../errorlist
[src/OtherFunctions.cpp:1223]: (error) fflush() called on input stream 'stdin' results in undefined behaviour.
[src/PartFile.cpp:1140]: (error) Division by zero.
[unittests/tests/CTagTest.cpp:209]: (error) Reference to temporary returned.
[unittests/tests/CTagTest.cpp:222]: (error) Reference to temporary returned.
[unittests/tests/FormatTest.cpp:230]: (error) Division by zero.

Quote    Reply   

#3 [url]

Jan 10 14 6:16 PM

Re: cppcheck....

warnings (mostly unitialised variables)


[src/EMSocket.cpp:44]: (warning) Member variable 'CEMSocket::pendingHeader' is not initialized in the constructor.
[src/ExternalConnector.cpp:554]: (warning) Possible leak in public function. The pointer 'm_strFullVersion' is not deallocated before it is allocated.
[src/LibSocketAsio.cpp:101]: (warning) Member variable 'CAsioSocketImpl::m_readBufferPtr' is not initialized in the constructor.
[src/Preferences.cpp:677]: (warning) Member variable 'Cfg_Lang::m_selection' is not initialized in the constructor.
[src/Preferences.cpp:677]: (warning) Member variable 'Cfg_Lang::m_langSelector' is not initialized in the constructor.
[src/Proxy.cpp:128]: (warning) Member variable 'CProxyStateMachine::m_buffer' is not initialized in the constructor.
[src/Proxy.cpp:128]: (warning) Member variable 'CProxyStateMachine::m_lastError' is not initialized in the constructor.
[src/Proxy.cpp:1345]: (warning) Member variable 'CDatagramSocketProxy::m_lastUDPOverhead' is not initialized in the constructor.
[src/SHA.cpp:68]: (warning) Member variable 'CSHA::m_nBuffer' is not initialized in the constructor.
[src/StateMachine.cpp:77]: (warning) %d in format string (no. 2) requires a signed integer given in the argument list.
[src/StateMachine.cpp:77]: (warning) %d in format string (no. 3) requires a signed integer given in the argument list.
[src/StateMachine.cpp:77]: (warning) %d in format string (no. 4) requires a signed integer given in the argument list.
[src/Timer.cpp:35]: (warning) Member variable 'CTimerThread::m_oneShot' is not initialized in the constructor.
[src/Timer.cpp:35]: (warning) Member variable 'CTimerThread::m_owner' is not initialized in the constructor.
[src/Timer.cpp:35]: (warning) Member variable 'CTimerThread::m_id' is not initialized in the constructor.
[src/Timer.cpp:35]: (warning) Member variable 'CTimerThread::m_period' is not initialized in the constructor.
[src/UPnPBase.cpp:316]: (warning) Redundant code: Found a statement that begins with numeric constant.
[src/amule.cpp:170]: (warning) Member variable 'CamuleApp::m_AsioService' is not initialized in the constructor.
[src/amuleAppCommon.cpp:54]: (warning) Member variable 'CamuleAppCommon::enable_daemon_fork' is not initialized in the constructor.
[src/amuleAppCommon.cpp:54]: (warning) Member variable 'CamuleAppCommon::m_skipConnectionDialog' is not initialized in the constructor.
[src/extern/wxWidgets/listctrl.cpp:1714]: (warning) Member variable 'wxListHeaderWindow::m_column' is not initialized in the constructor.
[src/extern/wxWidgets/listctrl.cpp:1714]: (warning) Member variable 'wxListHeaderWindow::m_currentX' is not initialized in the constructor.
[src/extern/wxWidgets/listctrl.cpp:1714]: (warning) Member variable 'wxListHeaderWindow::m_minX' is not initialized in the constructor.
[src/extern/wxWidgets/listctrl.cpp:1722]: (warning) Member variable 'wxListHeaderWindow::m_column' is not initialized in the constructor.
[src/extern/wxWidgets/listctrl.cpp:1722]: (warning) Member variable 'wxListHeaderWindow::m_currentX' is not initialized in the constructor.
[src/extern/wxWidgets/listctrl.cpp:1722]: (warning) Member variable 'wxListHeaderWindow::m_minX' is not initialized in the constructor.
[src/extern/wxWidgets/listctrl.cpp:2307]: (warning) Member variable 'wxListMainWindow::m_highlightColour' is not initialized in the constructor.
[src/libs/common/TextFile.cpp:35]: (warning) Member variable 'CTextFile::m_mode' is not initialized in the constructor.
[src/utils/plasmamule/plasma-applet-plasmamule.cpp:48]: (warning) Member variable 'PlasmaMuleApplet::m_ed2k_state' is not initialized in the constructor.
[src/utils/plasmamule/plasma-applet-plasmamule.cpp:48]: (warning) Member variable 'PlasmaMuleApplet::m_ed2k_server_port' is not initialized in the constructor.
[src/utils/plasmamule/plasma-applet-plasmamule.cpp:48]: (warning) Member variable 'PlasmaMuleApplet::m_kad_status' is not initialized in the constructor.
[src/utils/plasmamule/plasma-applet-plasmamule.cpp:48]: (warning) Member variable 'PlasmaMuleApplet::m_clients_in_up_queue' is not initialized in the constructor.
[src/utils/plasmamule/plasma-applet-plasmamule.cpp:48]: (warning) Member variable 'PlasmaMuleApplet::m_shared_files_count' is not initialized in the constructor.
[src/utils/plasmamule/plasma-applet-plasmamule.cpp:48]: (warning) Member variable 'PlasmaMuleApplet::m_uptime' is not initialized in the constructor.
[src/utils/plasmamule/plasma-applet-plasmamule.cpp:48]: (warning) Member variable 'PlasmaMuleApplet::m_debugChannel' is not initialized in the constructor.
[src/utils/plasmamule/plasma-applet-plasmamule.cpp:48]: (warning) Member variable 'PlasmaMuleApplet::m_down_speed' is not initialized in the constructor.
[src/utils/plasmamule/plasma-applet-plasmamule.cpp:48]: (warning) Member variable 'PlasmaMuleApplet::m_up_speed' is not initialized in the constructor.
[src/utils/plasmamule/plasma-applet-plasmamule.cpp:48]: (warning) Member variable 'PlasmaMuleApplet::m_os_active' is not initialized in the constructor.
[src/utils/plasmamule/plasma-applet-plasmamule.cpp:48]: (warning) Member variable 'PlasmaMuleApplet::m_config_found' is not initialized in the constructor.
[src/utils/plasmamule/plasma-applet-plasmamule.cpp:48]: (warning) Member variable 'PlasmaMuleApplet::m_aMuleEngine' is not initialized in the constructor.
[src/utils/plasmamule/plasma-engine-plasmamule.cpp:39]: (warning) Member variable 'PlasmaMuleEngine::m_OSActive' is not initialized in the constructor.
[src/utils/plasmamule/plasma-engine-plasmamule.cpp:39]: (warning) Member variable 'PlasmaMuleEngine::m_timer' is not initialized in the constructor.
[src/utils/plasmamule/plasma-engine-plasmamule.cpp:39]: (warning) Member variable 'PlasmaMuleEngine::m_debugChannel' is not initialized in the constructor.
[src/webserver/src/WebServer.cpp:697]: (warning) Member variable 'DownloadFile::lSourceCount' is not initialized in the constructor.
[src/webserver/src/WebServer.cpp:697]: (warning) Member variable 'DownloadFile::lNotCurrentSourceCount' is not initialized in the constructor.
[src/webserver/src/WebServer.cpp:697]: (warning) Member variable 'DownloadFile::lTransferringSourceCount' is not initialized in the constructor.
[src/webserver/src/WebServer.cpp:697]: (warning) Member variable 'DownloadFile::lSourceCountA4AF' is not initialized in the constructor.
[src/webserver/src/WebServer.cpp:697]: (warning) Member variable 'DownloadFile::bFileAutoPriority' is not initialized in the constructor.
[src/webserver/src/WebServer.cpp:697]: (warning) Member variable 'DownloadFile::m_Image' is not initialized in the constructor.
[src/webserver/src/WebServer.cpp:647]: (warning) Member variable 'SharedFile::bFileAutoPriority' is not initialized in the constructor.
[src/webserver/src/WebServer.cpp:770]: (warning) Member variable 'DownloadFileInfo::m_width' is not initialized in the constructor.
[src/webserver/src/WebServer.cpp:770]: (warning) Member variable 'DownloadFileInfo::m_height' is not initialized in the constructor.
[src/webserver/src/WebServer.cpp:896]: (warning) Member variable 'CAnyImage::m_width' is not initialized in the constructor.
[src/webserver/src/WebServer.cpp:896]: (warning) Member variable 'CAnyImage::m_height' is not initialized in the constructor.
[src/webserver/src/WebServer.cpp:219]: (warning) Member variable 'CWebServerBase::m_webserver_socket' is not initialized in the constructor.
[src/webserver/src/WebServer.cpp:219]: (warning) Member variable 'CWebServerBase::m_upnp' is not initialized in the constructor.
[src/webserver/src/php_amule_lib_standalone.cpp:129]: (warning) %d in format string (no. 2) requires a signed integer given in the argument list.
[src/webserver/src/php_core_lib.cpp:531]: (warning) Member variable 'CPhPLibContext::m_curr_str_buffer' is not initialized in the constructor.
[src/webserver/src/php_core_lib.cpp:549]: (warning) Member variable 'CPhPLibContext::m_curr_str_buffer' is not initialized in the constructor.

Quote    Reply   

#4 [url]

Jan 10 14 6:19 PM

Re: cppcheck....

Performance items (inconclusives ones removed)

[src/FriendList.h:66]: (performance) Variable 'm_it' is assigned in constructor body. Consider performing initialization in initialization list.
[src/GapList.h:97]: (performance) Variable 'm_it' is assigned in constructor body. Consider performing initialization in initialization list.
[src/ClientDetailDialog.cpp:54]: (performance) Variable 'm_client' is assigned in constructor body. Consider performing initialization in initialization list.
[src/ExternalConn.cpp:1948]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[src/ExternalConn.cpp:2011]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[src/ExternalConn.cpp:2050]: (performance) Prefer prefix ++/-- operators for non-primitive types.
[src/Friend.cpp:47]: (performance) Variable 'm_UserHash' is assigned in constructor body. Consider performing initialization in initialization list.
[src/IPFilter.cpp:66]: (performance) Variable 'm_rangeIPs' is assigned in constructor body. Consider performing initialization in initialization list.
[src/IPFilter.cpp:67]: (performance) Variable 'm_rangeLengths' is assigned in constructor body. Consider performing initialization in initialization list.
[src/SharedFileList.cpp:66]: (performance) Variable 'm_strKeyword' is assigned in constructor body. Consider performing initialization in initialization list.
[src/TextClient.cpp:118]: (performance) Variable 'nHash' is assigned in constructor body. Consider performing initialization in initialization list.
[src/UPnPBase.cpp:90]: (performance) Variable 'm_port' is assigned in constructor body. Consider performing initialization in initialization list.
[src/UploadClient.cpp:162] -> [src/UploadClient.cpp:171]: (performance) Variable 'last_done_part' is reassigned a value before the old one has been used.
[src/UploadClient.cpp:163] -> [src/UploadClient.cpp:172]: (performance) Variable 'next_requested_part' is reassigned a value before the old one has been used.
[src/kademlia/kademlia/SearchManager.cpp:124]: (performance) Possible inefficient checking for 'm_words' emptiness.
[src/libs/ec/cpp/ECSpecialTags.h:86]: (performance) Variable 'm_map_uint8' is assigned in constructor body. Consider performing initialization in initialization list.
[src/libs/ec/cpp/ECSpecialTags.h:87]: (performance) Variable 'm_map_uint16' is assigned in constructor body. Consider performing initialization in initialization list.
[src/libs/ec/cpp/ECSpecialTags.h:88]: (performance) Variable 'm_map_uint32' is assigned in constructor body. Consider performing initialization in initialization list.
[src/libs/ec/cpp/ECSpecialTags.h:89]: (performance) Variable 'm_map_uint64' is assigned in constructor body. Consider performing initialization in initialization list.
[src/libs/ec/cpp/ECSpecialTags.h:90]: (performance) Variable 'm_map_md4' is assigned in constructor body. Consider performing initialization in initialization list.
[src/libs/ec/cpp/ECSpecialTags.h:91]: (performance) Variable 'm_map_string' is assigned in constructor body. Consider performing initialization in initialization list.
[src/libs/ec/cpp/ECSpecialTags.h:92]: (performance) Variable 'm_map_tag' is assigned in constructor body. Consider performing initialization in initialization list.
[src/webserver/src/WebServer.cpp:699]: (performance) Variable 'nHash' is assigned in constructor body. Consider performing initialization in initialization list.
[src/webserver/src/WebServer.cpp:855]: (performance) Variable 'nHash' is assigned in constructor body. Consider performing initialization in initialization list.
[src/webserver/src/php_syntree.cpp:531]: (performance) Possible inefficient checking for 'scope_stack' emptiness.
[src/webserver/src/php_syntree.cpp:1947]: (performance) Prefer prefix ++/-- operators for non-primitive types.

Quote    Reply   

#5 [url]

Jan 10 14 9:55 PM

Re: cppcheck....

GonoszTopi already ran a cppcheck recently and cluttered up the source with silly keep-the-dumb-checker-happy comments. I doubt there is anything interesting left.
The Division by zero errors come from our overloaded CFormat '%' operator when it gets passed a 0 like in
[code] // cppcheck-suppress zerodiv
AddLogLineN(CFormat(wxPLURAL(
"Found corrupted part (%d) in %d part file %s - FileResultHash |%s| FileHash |%s|",
"Found corrupted part (%d) in %d parts file %s - FileResultHash |%s| FileHash |%s|",
0)
)
% 1
% 0
% GetFileName()
% result->GetFileHash().Encode()
% GetFileHash().Encode() );
[/code]
This is one of the "criticals". The stdin is explained in the source (win only), and the others are unittests.

Quote    Reply   
Add Reply

Quick Reply

bbcode help