I have a challenge for you: Can you spot the problem in the following source?
TMOUT1_CounterHandle TMOUT1_GetCounter(TMOUT1_CounterType nofTicks){ TMOUT1_CounterHandle handle; CS1_CriticalVariable(); handle = 0; if (nofTicks==0) { nofTicks = 1; /* wait at least for one tick, otherwise will timeout immediately */ } CS1_EnterCritical(); while (!TMOUT1_FreeCounters[handle] && handle<TMOUT1_NOF_COUNTERS) { handle++; } if (handle<TMOUT1_NOF_COUNTERS) { TMOUT1_FreeCounters[handle]=FALSE; TMOUT1_Counters[handle] = nofTicks; } CS1_ExitCritical(); if (handle==TMOUT1_NOF_COUNTERS) { return TMOUT1_OUT_OF_HANDLE; } return handle;}No? Well, I have not spotted the problem the first time neither. However, a reader of this blog did: he used a cool tool named ‘cppcheck’: that tool reported the following:








