Bug 263

Summary: XxxAddress::ConvertFrom are prone to subtle bugs
Product: ns-3 Reporter: Gustavo J. A. M. Carneiro <gjcarneiro>
Component: networkAssignee: Craig Dowell <craigdo>
Status: RESOLVED WONTFIX    
Severity: minor CC: ns-bugs
Priority: P1    
Version: pre-release   
Hardware: All   
OS: All   
Attachments: proof of concept patch

Description Gustavo J. A. M. Carneiro 2008-07-28 14:32:07 EDT
Example:

void foo (Address dst)
{
  Mac48Address dst48;
  dst48.ConvertFrom (dst);
}

This code compiles, but in the end dst48 is just uninitialized.  The correct code would be:

void foo (Address dst)
{
  Mac48Address dst48 = Mac48Address::ConvertFrom (dst);
}

Mathieu's idea to avoid the problem is to turn the static method into a function.  Code would look like this:

void foo (Address dst)
{
  Mac48Address dst48 = Mac48AddressConvertFrom (dst);
}
Comment 1 Gustavo J. A. M. Carneiro 2008-07-28 14:33:40 EDT
Created attachment 213 [details]
proof of concept patch

Something along these lines.  If accepted, I would do the same thing for all the other ConvertFrom methods and adapt existing ns-3-dev code to use the new API instead of the deprecated one.
Comment 2 Tom Henderson 2008-08-26 00:30:55 EDT
(In reply to comment #1)
> Created an attachment (id=213) [details]
> proof of concept patch
> 
> Something along these lines.  If accepted, I would do the same thing for all
> the other ConvertFrom methods and adapt existing ns-3-dev code to use the new
> API instead of the deprecated one.
> 

+1
Comment 3 Mathieu Lacage 2008-10-20 07:47:18 EDT
-1