Bug Summary

File:rootdir/src/libs/ec/cpp/ECMuleSocket.cpp
Warning:line 174, column 11
This statement is never executed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name ECMuleSocket.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/src/libs/ec/cpp -fcoverage-compilation-dir=/rootdir/src/libs/ec/cpp -resource-dir /usr/lib/llvm-19/lib/clang/19 -D HAVE_CONFIG_H -I . -I ../../../.. -D USE_WX_EXTENSIONS -I ../../../../src -I ../../../../src/libs -I ../../../../src/include -I /usr/lib/x86_64-linux-gnu/wx/include/gtk3-unicode-3.2 -I /usr/include/wx-3.2 -D _FILE_OFFSET_BITS=64 -D WXUSINGDLL -D __WXGTK__ -D wxUSE_GUI=0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem /usr/lib/llvm-19/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-register -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2025-01-17-081402-14897-1 -x c++ ECMuleSocket.cpp
1//
2// This file is part of the aMule Project.
3//
4// Copyright (c) 2004-2011 aMule Team ( admin@amule.org / http://www.amule.org )
5// Copyright (c) 2004-2011 Angel Vidal ( kry@amule.org )
6//
7// Any parts of this program derived from the xMule, lMule or eMule project,
8// or contributed by third-party developers are copyrighted by their
9// respective authors.
10//
11// This program is free software; you can redistribute it and/or modify
12// it under the terms of the GNU General Public License as published by
13// the Free Software Foundation; either version 2 of the License, or
14// (at your option) any later version.
15//
16// This program is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program; if not, write to the Free Software
23// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24//
25
26#include "ECMuleSocket.h"
27
28#include "../../../amuleIPV4Address.h"
29#include "../../../NetworkFunctions.h"
30
31#ifdef ASIO_SOCKETS
32#include <boost/system/error_code.hpp>
33#else
34
35//-------------------- CECSocketHandler --------------------
36
37#define EC_SOCKET_HANDLER(wxID_HIGHEST + 644) (wxID_HIGHEST + 644)
38
39class CECMuleSocketHandler: public wxEvtHandler {
40 public:
41 CECMuleSocketHandler() {};
42
43 private:
44 void SocketHandler(wxSocketEvent& event);
45
46 DECLARE_EVENT_TABLE()private: static const wxEventTableEntry sm_eventTableEntries[
]; protected: GCC diagnostic push GCC diagnostic ignored "-Wsuggest-override"
GCC diagnostic push GCC diagnostic ignored "-Winconsistent-missing-override"
const wxEventTable* GetEventTable() const ; wxEventHashTable
& GetEventHashTable() const ; GCC diagnostic pop GCC diagnostic
pop static const wxEventTable sm_eventTable; static wxEventHashTable
sm_eventHashTable;
47};
48
49BEGIN_EVENT_TABLE(CECMuleSocketHandler, wxEvtHandler)const wxEventTable CECMuleSocketHandler::sm_eventTable = { &
wxEvtHandler::sm_eventTable, &CECMuleSocketHandler::sm_eventTableEntries
[0] }; const wxEventTable *CECMuleSocketHandler::GetEventTable
() const { return &CECMuleSocketHandler::sm_eventTable; }
wxEventHashTable CECMuleSocketHandler::sm_eventHashTable(CECMuleSocketHandler
::sm_eventTable); wxEventHashTable &CECMuleSocketHandler::
GetEventHashTable() const { return CECMuleSocketHandler::sm_eventHashTable
; } const wxEventTableEntry CECMuleSocketHandler::sm_eventTableEntries
[] = {
50 EVT_SOCKET(EC_SOCKET_HANDLER, CECMuleSocketHandler::SocketHandler)wxEventTableEntry(wxEVT_SOCKET, (wxID_HIGHEST + 644), wxID_ANY
, wxNewEventTableFunctor(wxEVT_SOCKET, wxEventFunctionCast(wxPrivate
::DoCast<wxPrivate::EventArgOf<wxSocketEventFunction>
::type>(&CECMuleSocketHandler::SocketHandler))), __null
),
51END_EVENT_TABLE()wxEventTableEntry(wxEVT_NULL, 0, 0, __null, __null) };
52
53void CECMuleSocketHandler::SocketHandler(wxSocketEvent& event)
54{
55 CECSocket *socket = dynamic_cast<CECSocket *>(event.GetSocket());
56 wxCHECK_RET(socket, wxT("Socket event with a NULL socket!"))if ( socket ) {} else { do { if ( wxTheAssertHandler &&
(wxOnAssert("ECMuleSocket.cpp", 56, __FUNCTION__, "\"socket\""
, L"Socket event with a NULL socket!"), wxTrapInAssert) ) { wxTrapInAssert
= false; asm volatile ("int $3"); } } while ( (void)0, 0 ); return
; } struct wxDummyCheckStruct56
;
57
58 switch(event.GetSocketEvent()) {
59 case wxSOCKET_LOST:
60 socket->OnLost();
61 break;
62 case wxSOCKET_INPUT:
63 socket->OnInput();
64 break;
65 case wxSOCKET_OUTPUT:
66 socket->OnOutput();
67 break;
68 case wxSOCKET_CONNECTION:
69 socket->OnConnect();
70 break;
71
72 default:
73 // Nothing should arrive here...
74 wxFAILdo { if ( wxTheAssertHandler && (wxOnAssert("ECMuleSocket.cpp"
, 74, __FUNCTION__, "\"Assert failure\"", (const char*)__null
), wxTrapInAssert) ) { wxTrapInAssert = false; asm volatile (
"int $3"); } } while ( (void)0, 0 )
;
75 break;
76 }
77}
78
79static CECMuleSocketHandler g_ECSocketHandler;
80
81#endif /* ASIO_SOCKETS */
82
83//
84// CECMuleSocket API - User interface functions
85//
86
87CECMuleSocket::CECMuleSocket(bool use_events)
88:
89CECSocket(use_events)
90{
91#ifdef ASIO_SOCKETS
92 Notify(use_events);
93#else
94 if ( use_events ) {
95 SetEventHandler(g_ECSocketHandler, EC_SOCKET_HANDLER(wxID_HIGHEST + 644));
96 SetNotify(wxSOCKET_CONNECTION_FLAG | wxSOCKET_INPUT_FLAG |
97 wxSOCKET_OUTPUT_FLAG | wxSOCKET_LOST_FLAG);
98 Notify(true);
99 SetFlags(wxSOCKET_NOWAIT);
100 } else {
101 SetFlags(wxSOCKET_WAITALL | wxSOCKET_BLOCK);
102 Notify(false);
103 }
104#endif
105}
106
107CECMuleSocket::~CECMuleSocket()
108{
109}
110
111bool CECMuleSocket::ConnectSocket(amuleIPV4Address& address)
112{
113 return CECSocket::ConnectSocket(StringIPtoUint32(address.IPAddress()),address.Service());
114}
115
116
117bool CECMuleSocket::InternalConnect(uint32_t ip, uint16_t port, bool wait) {
118 amuleIPV4Address addr;
119 addr.Hostname(Uint32toStringIP(ip));
120 addr.Service(port);
121 return CLibSocket::Connect(addr, wait);
122}
123
124int CECMuleSocket::InternalGetLastError()
125{
126 switch (LastError()) {
127#ifdef ASIO_SOCKETS
128 case boost::system::errc::success:
129 return EC_ERROR_NOERROR;
130 case boost::system::errc::address_family_not_supported:
131 case boost::system::errc::address_in_use:
132 case boost::system::errc::address_not_available:
133 case boost::system::errc::bad_address:
134 case boost::system::errc::invalid_argument:
135 return EC_ERROR_INVADDR;
136 case boost::system::errc::already_connected:
137 case boost::system::errc::connection_already_in_progress:
138 case boost::system::errc::not_connected:
139 return EC_ERROR_INVOP;
140 case boost::system::errc::connection_aborted:
141 case boost::system::errc::connection_reset:
142 case boost::system::errc::io_error:
143 case boost::system::errc::network_down:
144 case boost::system::errc::network_reset:
145 case boost::system::errc::network_unreachable:
146 return EC_ERROR_IOERR;
147 case boost::system::errc::connection_refused:
148 case boost::system::errc::host_unreachable:
149 return EC_ERROR_NOHOST;
150 case boost::system::errc::not_a_socket:
151 return EC_ERROR_INVSOCK;
152 case boost::system::errc::not_enough_memory:
153 return EC_ERROR_MEMERR;
154 case boost::system::errc::operation_would_block:
155 return EC_ERROR_WOULDBLOCK;
156 case boost::system::errc::timed_out:
157 return EC_ERROR_TIMEDOUT;
158#else
159 case wxSOCKET_NOERROR:
160 return EC_ERROR_NOERROR;
161 case wxSOCKET_INVOP:
162 return EC_ERROR_INVOP;
163 case wxSOCKET_IOERR:
164 return EC_ERROR_IOERR;
165 case wxSOCKET_INVADDR:
166 return EC_ERROR_INVADDR;
167 case wxSOCKET_INVSOCK:
168 return EC_ERROR_INVSOCK;
169 case wxSOCKET_NOHOST:
170 return EC_ERROR_NOHOST;
171 case wxSOCKET_INVPORT:
172 return EC_ERROR_INVPORT;
173 case wxSOCKET_WOULDBLOCK:
174 return EC_ERROR_WOULDBLOCK;
This statement is never executed
175 case wxSOCKET_TIMEDOUT:
176 return EC_ERROR_TIMEDOUT;
177 case wxSOCKET_MEMERR:
178 return EC_ERROR_MEMERR;
179#endif
180 default:
181 return EC_ERROR_UNKNOWN;
182 }
183}