Bug 2549 - dead assignment on dsr-routing.cc
dead assignment on dsr-routing.cc
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: dsr
unspecified
PC Linux
: P5 enhancement
Assigned To: Yufei Cheng
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-11-08 03:57 UTC by natale.patriciello
Modified: 2017-04-17 20:27 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description natale.patriciello 2016-11-08 03:57:57 UTC
The snippet is the following:

533	std::vector<std::string>
534	DsrRouting::GetElementsFromContext (std::string context)
535	{
536	  std::vector <std::string> elements;
537	  size_t pos1=0, pos2;
538	  while (pos1 != context.npos)
539	  {
540	    pos1 = context.find ("/",pos1);
541	    pos2 = context.find ("/",pos1+1);
542	    elements.push_back (context.substr (pos1+1,pos2-(pos1+1)));
543	    pos1 = pos2;
544	    pos2 = context.npos; // Value stored to 'pos2' is never read
545	  }
546	  return elements;
547	}

At line 544, we have an assignment, but it is dead because at the next iteration it will be overwritten by another search.

Is it safe to remove line 544, or there is room the rewrite the function in a more compact way, without calling two times find ?
Comment 1 Tom Henderson 2017-04-17 20:27:53 UTC
was fixed a while back in changeset 12699:16407cde2596