]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
Fix possible overwrite of state changes make in a component's Init.init()
authorR. Steve McKown <rsmckown@gmail.com>
Mon, 19 Apr 2010 22:13:15 +0000 (16:13 -0600)
committerR. Steve McKown <rsmckown@gmail.com>
Mon, 9 Jul 2012 16:34:42 +0000 (10:34 -0600)
If a component using State and providing Init is wired to MainC.SoftwareInit,
the component cannot reliably call State.forceState() inside its Init.init().
If ncc renders MainC.SoftwareInit.Init()'s fanout calling the component's
Init.init() before StateImplP's Init.init(), the latter sets the state[] array
members all to zero (S_IDLE), undoing any state change the component may have
attempted.

The easy fix is to remove the extra initiation of state[] in StateImplP's
Init.init().  Becuase state[] is a static, its elements are guaranteed to have
values of zero (S_IDLE).

tos/system/StateImplP.nc

index 3883ac15012ab47f6dfafc82adbdd9a07bafd477..edcde832a1f86eadcf8921ebe10f2addb29a5b74 100644 (file)
@@ -79,10 +79,6 @@ implementation {
 
   /***************** Init Commands ****************/
   command error_t Init.init() {
-    int i;
-    for(i = 0; i < uniqueCount(UQ_STATE); i++) {
-      state[i] = S_IDLE;
-    }
     return SUCCESS;
   }