Fix errors/warnings reported by valgrind
This commit is contained in:
parent
6bd15247f9
commit
eadde1e741
@ -125,7 +125,7 @@ std::list<SharedBuffer<u8> > makeSplitPacket(
|
|||||||
{
|
{
|
||||||
// Chunk packets, containing the TYPE_SPLIT header
|
// Chunk packets, containing the TYPE_SPLIT header
|
||||||
std::list<SharedBuffer<u8> > chunks;
|
std::list<SharedBuffer<u8> > chunks;
|
||||||
|
|
||||||
u32 chunk_header_size = 7;
|
u32 chunk_header_size = 7;
|
||||||
u32 maximum_data_size = chunksize_max - chunk_header_size;
|
u32 maximum_data_size = chunksize_max - chunk_header_size;
|
||||||
u32 start = 0;
|
u32 start = 0;
|
||||||
@ -136,12 +136,12 @@ std::list<SharedBuffer<u8> > makeSplitPacket(
|
|||||||
end = start + maximum_data_size - 1;
|
end = start + maximum_data_size - 1;
|
||||||
if(end > data.getSize() - 1)
|
if(end > data.getSize() - 1)
|
||||||
end = data.getSize() - 1;
|
end = data.getSize() - 1;
|
||||||
|
|
||||||
u32 payload_size = end - start + 1;
|
u32 payload_size = end - start + 1;
|
||||||
u32 packet_size = chunk_header_size + payload_size;
|
u32 packet_size = chunk_header_size + payload_size;
|
||||||
|
|
||||||
SharedBuffer<u8> chunk(packet_size);
|
SharedBuffer<u8> chunk(packet_size);
|
||||||
|
|
||||||
writeU8(&chunk[0], TYPE_SPLIT);
|
writeU8(&chunk[0], TYPE_SPLIT);
|
||||||
writeU16(&chunk[1], seqnum);
|
writeU16(&chunk[1], seqnum);
|
||||||
// [3] u16 chunk_count is written at next stage
|
// [3] u16 chunk_count is written at next stage
|
||||||
@ -150,7 +150,7 @@ std::list<SharedBuffer<u8> > makeSplitPacket(
|
|||||||
|
|
||||||
chunks.push_back(chunk);
|
chunks.push_back(chunk);
|
||||||
chunk_count++;
|
chunk_count++;
|
||||||
|
|
||||||
start = end + 1;
|
start = end + 1;
|
||||||
chunk_num++;
|
chunk_num++;
|
||||||
}
|
}
|
||||||
@ -465,9 +465,9 @@ SharedBuffer<u8> IncomingSplitBuffer::insert(BufferedPacket &p, bool reliable)
|
|||||||
sp->reliable = reliable;
|
sp->reliable = reliable;
|
||||||
m_buf[seqnum] = sp;
|
m_buf[seqnum] = sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
IncomingSplitPacket *sp = m_buf[seqnum];
|
IncomingSplitPacket *sp = m_buf[seqnum];
|
||||||
|
|
||||||
// TODO: These errors should be thrown or something? Dunno.
|
// TODO: These errors should be thrown or something? Dunno.
|
||||||
if(chunk_count != sp->chunk_count)
|
if(chunk_count != sp->chunk_count)
|
||||||
LOG(derr_con<<"Connection: WARNING: chunk_count="<<chunk_count
|
LOG(derr_con<<"Connection: WARNING: chunk_count="<<chunk_count
|
||||||
@ -483,15 +483,15 @@ SharedBuffer<u8> IncomingSplitBuffer::insert(BufferedPacket &p, bool reliable)
|
|||||||
// lag and the server re-sends stuff.
|
// lag and the server re-sends stuff.
|
||||||
if(sp->chunks.find(chunk_num) != sp->chunks.end())
|
if(sp->chunks.find(chunk_num) != sp->chunks.end())
|
||||||
return SharedBuffer<u8>();
|
return SharedBuffer<u8>();
|
||||||
|
|
||||||
// Cut chunk data out of packet
|
// Cut chunk data out of packet
|
||||||
u32 chunkdatasize = p.data.getSize() - headersize;
|
u32 chunkdatasize = p.data.getSize() - headersize;
|
||||||
SharedBuffer<u8> chunkdata(chunkdatasize);
|
SharedBuffer<u8> chunkdata(chunkdatasize);
|
||||||
memcpy(*chunkdata, &(p.data[headersize]), chunkdatasize);
|
memcpy(*chunkdata, &(p.data[headersize]), chunkdatasize);
|
||||||
|
|
||||||
// Set chunk data in buffer
|
// Set chunk data in buffer
|
||||||
sp->chunks[chunk_num] = chunkdata;
|
sp->chunks[chunk_num] = chunkdata;
|
||||||
|
|
||||||
// If not all chunks are received, return empty buffer
|
// If not all chunks are received, return empty buffer
|
||||||
if(sp->allReceived() == false)
|
if(sp->allReceived() == false)
|
||||||
return SharedBuffer<u8>();
|
return SharedBuffer<u8>();
|
||||||
@ -503,7 +503,7 @@ SharedBuffer<u8> IncomingSplitBuffer::insert(BufferedPacket &p, bool reliable)
|
|||||||
{
|
{
|
||||||
totalsize += i->second.getSize();
|
totalsize += i->second.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedBuffer<u8> fulldata(totalsize);
|
SharedBuffer<u8> fulldata(totalsize);
|
||||||
|
|
||||||
// Copy chunks to data buffer
|
// Copy chunks to data buffer
|
||||||
@ -561,6 +561,7 @@ Channel::Channel() :
|
|||||||
next_outgoing_split_seqnum(SEQNUM_INITIAL),
|
next_outgoing_split_seqnum(SEQNUM_INITIAL),
|
||||||
current_packet_loss(0),
|
current_packet_loss(0),
|
||||||
current_packet_too_late(0),
|
current_packet_too_late(0),
|
||||||
|
current_packet_successfull(0),
|
||||||
packet_loss_counter(0),
|
packet_loss_counter(0),
|
||||||
current_bytes_transfered(0),
|
current_bytes_transfered(0),
|
||||||
current_bytes_received(0),
|
current_bytes_received(0),
|
||||||
@ -2096,7 +2097,7 @@ void ConnectionReceiveThread::receive()
|
|||||||
// infrastructure
|
// infrastructure
|
||||||
unsigned int packet_maxsize = 1500;
|
unsigned int packet_maxsize = 1500;
|
||||||
SharedBuffer<u8> packetdata(packet_maxsize);
|
SharedBuffer<u8> packetdata(packet_maxsize);
|
||||||
|
|
||||||
bool packet_queued = true;
|
bool packet_queued = true;
|
||||||
|
|
||||||
unsigned int loop_count = 0;
|
unsigned int loop_count = 0;
|
||||||
@ -2146,13 +2147,13 @@ void ConnectionReceiveThread::receive()
|
|||||||
|
|
||||||
u16 peer_id = readPeerId(*packetdata);
|
u16 peer_id = readPeerId(*packetdata);
|
||||||
u8 channelnum = readChannel(*packetdata);
|
u8 channelnum = readChannel(*packetdata);
|
||||||
|
|
||||||
if(channelnum > CHANNEL_COUNT-1){
|
if(channelnum > CHANNEL_COUNT-1){
|
||||||
LOG(derr_con<<m_connection->getDesc()
|
LOG(derr_con<<m_connection->getDesc()
|
||||||
<<"Receive(): Invalid channel "<<channelnum<<std::endl);
|
<<"Receive(): Invalid channel "<<channelnum<<std::endl);
|
||||||
throw InvalidIncomingDataException("Channel doesn't exist");
|
throw InvalidIncomingDataException("Channel doesn't exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* preserve original peer_id for later usage */
|
/* preserve original peer_id for later usage */
|
||||||
u16 packet_peer_id = peer_id;
|
u16 packet_peer_id = peer_id;
|
||||||
|
|
||||||
@ -2202,7 +2203,7 @@ void ConnectionReceiveThread::receive()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* mark peer as seen with id */
|
/* mark peer as seen with id */
|
||||||
if (!(packet_peer_id == PEER_ID_INEXISTENT))
|
if (!(packet_peer_id == PEER_ID_INEXISTENT))
|
||||||
peer->setSentWithID();
|
peer->setSentWithID();
|
||||||
@ -2215,7 +2216,7 @@ void ConnectionReceiveThread::receive()
|
|||||||
{
|
{
|
||||||
channel = &(dynamic_cast<UDPPeer*>(&peer)->channels[channelnum]);
|
channel = &(dynamic_cast<UDPPeer*>(&peer)->channels[channelnum]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel != 0) {
|
if (channel != 0) {
|
||||||
channel->UpdateBytesReceived(received_size);
|
channel->UpdateBytesReceived(received_size);
|
||||||
}
|
}
|
||||||
@ -2226,17 +2227,17 @@ void ConnectionReceiveThread::receive()
|
|||||||
SharedBuffer<u8> strippeddata(received_size - BASE_HEADER_SIZE);
|
SharedBuffer<u8> strippeddata(received_size - BASE_HEADER_SIZE);
|
||||||
memcpy(*strippeddata, &packetdata[BASE_HEADER_SIZE],
|
memcpy(*strippeddata, &packetdata[BASE_HEADER_SIZE],
|
||||||
strippeddata.getSize());
|
strippeddata.getSize());
|
||||||
|
|
||||||
try{
|
try{
|
||||||
// Process it (the result is some data with no headers made by us)
|
// Process it (the result is some data with no headers made by us)
|
||||||
SharedBuffer<u8> resultdata = processPacket
|
SharedBuffer<u8> resultdata = processPacket
|
||||||
(channel, strippeddata, peer_id, channelnum, false);
|
(channel, strippeddata, peer_id, channelnum, false);
|
||||||
|
|
||||||
LOG(dout_con<<m_connection->getDesc()
|
LOG(dout_con<<m_connection->getDesc()
|
||||||
<<" ProcessPacket from peer_id: " << peer_id
|
<<" ProcessPacket from peer_id: " << peer_id
|
||||||
<< ",channel: " << (channelnum & 0xFF) << ", returned "
|
<< ",channel: " << (channelnum & 0xFF) << ", returned "
|
||||||
<< resultdata.getSize() << " bytes" <<std::endl);
|
<< resultdata.getSize() << " bytes" <<std::endl);
|
||||||
|
|
||||||
ConnectionEvent e;
|
ConnectionEvent e;
|
||||||
e.dataReceived(peer_id, resultdata);
|
e.dataReceived(peer_id, resultdata);
|
||||||
m_connection->putEvent(e);
|
m_connection->putEvent(e);
|
||||||
@ -2854,11 +2855,11 @@ bool Connection::Connected()
|
|||||||
|
|
||||||
if(m_peers.size() != 1)
|
if(m_peers.size() != 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::map<u16, Peer*>::iterator node = m_peers.find(PEER_ID_SERVER);
|
std::map<u16, Peer*>::iterator node = m_peers.find(PEER_ID_SERVER);
|
||||||
if(node == m_peers.end())
|
if(node == m_peers.end())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(m_peer_id == PEER_ID_INEXISTENT)
|
if(m_peer_id == PEER_ID_INEXISTENT)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -3114,4 +3115,3 @@ std::list<u16> Connection::getPeerIDs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -68,12 +68,12 @@ inline wchar_t* chartowchar_t(const char *str)
|
|||||||
MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) str, -1, (WCHAR *) nstr, nResult );
|
MultiByteToWideChar( CP_UTF8, 0, (LPCSTR) str, -1, (WCHAR *) nstr, nResult );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
size_t l = strlen(str)+1;
|
size_t l = strlen(str);
|
||||||
nstr = new wchar_t[l];
|
nstr = new wchar_t[l+1];
|
||||||
|
|
||||||
std::wstring intermediate = narrow_to_wide(str);
|
std::wstring intermediate = narrow_to_wide(str);
|
||||||
memset(nstr,0,l);
|
memset(nstr, 0, (l+1)*sizeof(wchar_t));
|
||||||
memcpy(nstr,intermediate.c_str(),l*sizeof(wchar_t));
|
memcpy(nstr, intermediate.c_str(), l*sizeof(wchar_t));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return nstr;
|
return nstr;
|
||||||
|
@ -81,6 +81,7 @@ GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
|
|||||||
m_selected_amount(0),
|
m_selected_amount(0),
|
||||||
m_selected_dragging(false),
|
m_selected_dragging(false),
|
||||||
m_tooltip_element(NULL),
|
m_tooltip_element(NULL),
|
||||||
|
m_old_tooltip_id(-1),
|
||||||
m_allowclose(true),
|
m_allowclose(true),
|
||||||
m_lock(false),
|
m_lock(false),
|
||||||
m_form_src(fsrc),
|
m_form_src(fsrc),
|
||||||
@ -1301,7 +1302,7 @@ void GUIFormSpecMenu::parseImageButton(parserData* data,std::string element,
|
|||||||
if (spec.fname == data->focused_fieldname) {
|
if (spec.fname == data->focused_fieldname) {
|
||||||
Environment->setFocus(e);
|
Environment->setFocus(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
e->setUseAlphaChannel(true);
|
e->setUseAlphaChannel(true);
|
||||||
e->setImage(texture);
|
e->setImage(texture);
|
||||||
e->setPressedImage(pressed_texture);
|
e->setPressedImage(pressed_texture);
|
||||||
@ -1800,7 +1801,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||||||
m_fields.clear();
|
m_fields.clear();
|
||||||
m_boxes.clear();
|
m_boxes.clear();
|
||||||
m_tooltips.clear();
|
m_tooltips.clear();
|
||||||
|
|
||||||
// Set default values (fits old formspec values)
|
// Set default values (fits old formspec values)
|
||||||
m_bgcolor = video::SColor(140,0,0,0);
|
m_bgcolor = video::SColor(140,0,0,0);
|
||||||
m_bgfullscreen = false;
|
m_bgfullscreen = false;
|
||||||
@ -1810,7 +1811,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
|
|||||||
|
|
||||||
m_default_tooltip_bgcolor = video::SColor(255,110,130,60);
|
m_default_tooltip_bgcolor = video::SColor(255,110,130,60);
|
||||||
m_default_tooltip_color = video::SColor(255,255,255,255);
|
m_default_tooltip_color = video::SColor(255,255,255,255);
|
||||||
|
|
||||||
m_slotbordercolor = video::SColor(200,0,0,0);
|
m_slotbordercolor = video::SColor(200,0,0,0);
|
||||||
m_slotborder = false;
|
m_slotborder = false;
|
||||||
|
|
||||||
@ -2828,7 +2829,7 @@ bool GUIFormSpecMenu::OnEvent(const SEvent& event)
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event.EventType==EET_MOUSE_INPUT_EVENT
|
if(event.EventType==EET_MOUSE_INPUT_EVENT
|
||||||
&& event.MouseInput.Event != EMIE_MOUSE_MOVED) {
|
&& event.MouseInput.Event != EMIE_MOUSE_MOVED) {
|
||||||
// Mouse event other than movement
|
// Mouse event other than movement
|
||||||
|
@ -117,7 +117,7 @@ void NodeBox::deSerialize(std::istream &is)
|
|||||||
void TileDef::serialize(std::ostream &os, u16 protocol_version) const
|
void TileDef::serialize(std::ostream &os, u16 protocol_version) const
|
||||||
{
|
{
|
||||||
if(protocol_version >= 17)
|
if(protocol_version >= 17)
|
||||||
writeU8(os, 1);
|
writeU8(os, 1);
|
||||||
else
|
else
|
||||||
writeU8(os, 0);
|
writeU8(os, 0);
|
||||||
os<<serializeString(name);
|
os<<serializeString(name);
|
||||||
@ -560,7 +560,7 @@ public:
|
|||||||
for (ItemGroupList::const_iterator i = def.groups.begin();
|
for (ItemGroupList::const_iterator i = def.groups.begin();
|
||||||
i != def.groups.end(); ++i) {
|
i != def.groups.end(); ++i) {
|
||||||
std::string group_name = i->first;
|
std::string group_name = i->first;
|
||||||
|
|
||||||
std::map<std::string, GroupItems>::iterator
|
std::map<std::string, GroupItems>::iterator
|
||||||
j = m_group_to_items.find(group_name);
|
j = m_group_to_items.find(group_name);
|
||||||
if (j == m_group_to_items.end()) {
|
if (j == m_group_to_items.end()) {
|
||||||
@ -1018,4 +1018,3 @@ void ContentFeatures::deSerializeOld(std::istream &is, int version)
|
|||||||
throw SerializationError("unsupported ContentFeatures version");
|
throw SerializationError("unsupported ContentFeatures version");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user