Bug 263 - XxxAddress::ConvertFrom are prone to subtle bugs
XxxAddress::ConvertFrom are prone to subtle bugs
Status: RESOLVED WONTFIX
Product: ns-3
Classification: Unclassified
Component: network
pre-release
All All
: P1 minor
Assigned To: Craig Dowell
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-07-28 14:32 EDT by Gustavo J. A. M. Carneiro
Modified: 2008-12-06 03:11 EST (History)
1 user (show)

See Also:


Attachments
proof of concept patch (1.66 KB, patch)
2008-07-28 14:33 EDT, Gustavo J. A. M. Carneiro
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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