Bug 2553

Summary: Dead assignment on packet-metadata.cc
Product: ns-3 Reporter: natale.patriciello
Component: networkAssignee: ns-bugs <ns-bugs>
Status: RESOLVED FIXED    
Severity: trivial CC: suryaseetharaman.9, tomh
Priority: P5    
Version: pre-release   
Hardware: PC   
OS: Linux   

Description natale.patriciello 2016-11-11 09:20:20 UTC
If you look at line 192:

191	  uint32_t result = 0;
192	  uint8_t byte;
193	  result = 0; // Value stored to 'result' is never read
194	  byte = buffer[0];
195	  result = (byte & (~0x80));

There is a dead assignment; patch is trivial.
Comment 1 natale.patriciello 2016-11-11 09:42:35 UTC
Another one is at the following lines (266):

254	void
255	PacketMetadata::AppendValueExtra (uint32_t value, uint8_t *buffer)
256	{
257	  NS_LOG_FUNCTION (this << value << &buffer);
258	  if (value < 0x200000)
259	    {
260	      uint8_t byte = value & (~0x80);
261	      buffer[0] = 0x80 | byte;
262	      value >>= 7;
263	      byte = value & (~0x80);
264	      buffer[1] = 0x80 | byte;
265	      value >>= 7;
266	      byte = value & (~0x80); // Value stored to 'byte' is never read
267	      buffer[2] = value;
268	      return;
269	    }


The patch is less simple: should the value of "byte" be stored somewhere?
Comment 2 natale.patriciello 2016-11-11 09:48:33 UTC
Another problem is a use-after-free. I don't open another bug because the patch is trivial:

589 PacketMetadata::Deallocate (data);	
590 NS_LOG_LOGIC ("create dealloc size="<<data->m_size); // use-after-free


We are deallocating data, and then we are printing a field inside that region of memory. Fortunately no use uses LOGIC debug on PacketMetadata :)
Comment 3 tssurya 2017-04-17 10:35:03 UTC
I guess these changes are incorporated already in ns-3-dev? So is there anything else holding this issue open that I could help with ?
Comment 4 Tom Henderson 2017-04-17 20:23:33 UTC
Was fixed a while back in changeset 12697:c034f3634c8c