From: R. Steve McKown Date: Mon, 19 Apr 2010 22:13:15 +0000 (-0600) Subject: Fix possible overwrite of state changes make in a component's Init.init() X-Git-Tag: patchset/2.1.1-4.3rc0~3 X-Git-Url: https://oss.titaniummirror.com/gitweb/?p=tinyos-2.x.git;a=commitdiff_plain;h=09a66a693c4a8e0bb070381703975120ed22d14b Fix possible overwrite of state changes make in a component's Init.init() 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). --- diff --git a/tos/system/StateImplP.nc b/tos/system/StateImplP.nc index 3883ac15..edcde832 100644 --- a/tos/system/StateImplP.nc +++ b/tos/system/StateImplP.nc @@ -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; }