|
Bugzilla – Full Text Bug Listing |
| Summary: | XxxAddress::ConvertFrom are prone to subtle bugs | ||
|---|---|---|---|
| Product: | ns-3 | Reporter: | Gustavo J. A. M. Carneiro <gjcarneiro> |
| Component: | network | Assignee: | 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 | ||
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.
(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 -1 |
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); }