Bug 2549

Summary: dead assignment on dsr-routing.cc
Product: ns-3 Reporter: natale.patriciello
Component: dsrAssignee: Yufei Cheng <michaelcheng1943>
Status: RESOLVED FIXED    
Severity: enhancement CC: ns-bugs, tomh
Priority: P5    
Version: unspecified   
Hardware: PC   
OS: Linux   

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