Bug 2554

Summary: Value is never read in wifi-80211p-helper
Product: ns-3 Reporter: natale.patriciello
Component: wave moduleAssignee: ns-bugs <ns-bugs>
Status: RESOLVED FIXED    
Severity: enhancement CC: tomh
Priority: P5    
Version: pre-release   
Hardware: PC   
OS: Linux   
Attachments: patch

Description natale.patriciello 2016-11-11 09:33:47 UTC
Created attachment 2674 [details]
patch

I should state that I don't understand why the static analyzer says that. Anyway, in the function Install of wifi-80211p-helper, we have the following:

76	NetDeviceContainer
77	Wifi80211pHelper::Install (const WifiPhyHelper &phyHelper, const WifiMacHelper &macHelper, NodeContainer c) const
78	{
79	  bool isWaveMacHelper = false;
80	  try
81	    {
82	      const QosWaveMacHelper& qosMac = dynamic_cast<const QosWaveMacHelper&> (macHelper);
83	      isWaveMacHelper = true; // Value stored to 'isWaveMacHelper' is never read
84	      NS_UNUSED (qosMac);
85	    }
86	  catch (const std::bad_cast &)
87	    {
88	 
89	    }
90	 
91	  try
92	    {
93	      const NqosWaveMacHelper& nqosMac = dynamic_cast<const NqosWaveMacHelper&> (macHelper);
94	      isWaveMacHelper = true;
95	      NS_UNUSED (nqosMac);
96	    }
97	  catch (const std::bad_cast &)
98	    {
99	 
100	    }
101	 
102	  if (!isWaveMacHelper)
103	    {
104	      NS_FATAL_ERROR ("the macHelper should be either QosWaveMacHelper or NqosWaveMacHelper"
105	                      ", or should be the subclass of QosWaveMacHelper or NqosWaveMacHelper");
106	    }
107	 
108	  return WifiHelper::Install (phyHelper, macHelper, c);
109	}

At line 83, the value is never read. Anyway, there is a less expensive way to check if a dynamic cast has been done, and is through pointers. The patch does exactly that, using pointers. The warning goes away.
Comment 1 Tom Henderson 2017-04-07 00:54:55 UTC
pushed in changeset 12809:c7f9d1aa7d9a