Bug 2554 - Value is never read in wifi-80211p-helper
Value is never read in wifi-80211p-helper
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: wave module
pre-release
PC Linux
: P5 enhancement
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-11-11 09:33 UTC by natale.patriciello
Modified: 2017-04-07 00:54 UTC (History)
1 user (show)

See Also:


Attachments
patch (1.61 KB, patch)
2016-11-11 09:33 UTC, natale.patriciello
Details | Diff

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