anandmudgerikar / tinyos-main

Automatically exported from code.google.com/p/tinyos-main
0 stars 0 forks source link

rfxlink TrafficMonitorLayerP time variable shadows global one when compiling with TOSSIM #62

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Use the traffic monitor layer in tossim

What is the expected output? What do you see instead?

I get:

/home/morten/workspace/tinyos/tos/lib/rfxlink/layers/TrafficMonitorLayerP.nc: 
In function `TrafficMonitor.getActiveTime':
/home/morten/workspace/tinyos/tos/lib/rfxlink/layers/TrafficMonitorLayerP.nc:247
: warning: declaration of `activeTime' shadows global declaration

Changing the local 'time' variable to e.g. 'aTime' will remove the warning:

diff --git a/tos/lib/rfxlink/layers/TrafficMonitorLayerP.nc 
b/tos/lib/rfxlink/layers/TrafficMonitorLayerP.nc
index 705e2ca..a65107e 100644
--- a/tos/lib/rfxlink/layers/TrafficMonitorLayerP.nc
+++ b/tos/lib/rfxlink/layers/TrafficMonitorLayerP.nc
@@ -244,18 +244,18 @@ implementation

        async command uint32_t TrafficMonitor.getActiveTime()
        {
-               uint32_t time, localTime;
+               uint32_t aTime, localTime;

                localTime = call LocalTime.get();

                atomic
                {
-                       time = activeTime;
+                       aTime = activeTime;
                        if( radioState != RADIO_OFF )
-                               time += localTime - radioStart;
+                               aTime += localTime - radioStart;
                }

-               return time;
+               return aTime;
        }

        async command uint32_t TrafficMonitor.getCurrentTime()

Original issue reported on code.google.com by mortenthansen on 6 Sep 2011 at 10:12

GoogleCodeExporter commented 8 years ago
Ops. Incorrect warning message.  I get:

/home/morten/workspace/tinyos/tos/lib/rfxlink/layers/TrafficMonitorLayerP.nc: 
In function `TrafficMonitor.getActiveTime':
/home/morten/workspace/tinyos/tos/lib/rfxlink/layers/TrafficMonitorLayerP.nc:247
: warning: declaration of `time' shadows global declaration

The fix is still the same

Original comment by mortenthansen on 6 Sep 2011 at 10:13

GoogleCodeExporter commented 8 years ago

Original comment by philip.l...@gmail.com on 12 Sep 2011 at 12:37

GoogleCodeExporter commented 8 years ago
patch applied

Original comment by mmar...@gmail.com on 12 Sep 2011 at 12:49