This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Bug in WDT firmware in SDK 16.0.0 ?

I am trying to use the NRFX_WDT design in SDK 16.0.0 on a board using the nRF52832.

In the file nrfx_wdt.c, the allocation index is declared/defined as:

static uint8_t m_alloc_index;

However, this variable is not initialized before being used e.g. tested for equality to 0 or as the terminating condition in a for loop.
In fact, I do not see any possible source code that could be assigning to this variable (this being a static variable, the assignment must be in this very file).
Is this a bug?

RMV

Parents
  • Hi RMV,

    Static or global variables are never uninitialized in C. Unless explicitly initialized to another value, they are implicitly initialized to zero. (Personally I prefer to explicitly set to zero to avoid confusion, but it is not required.) Local variables on the other hand are not implicitly initialized, so if this was a local variable, then it would have been a bug.

    Einar

  • Hi Einar,

    Can you point to a specific portion of say the C11 standard where your claim is listed?

    I have done a quick word search for 'initial' and 'initialized' but other than the fact that the standard says that static global values are 'initialized once at program start' I do not see where it says it must be the value '0' (at least for an integer class variable).

    Cheers

    RMV

Reply
  • Hi Einar,

    Can you point to a specific portion of say the C11 standard where your claim is listed?

    I have done a quick word search for 'initial' and 'initialized' but other than the fact that the standard says that static global values are 'initialized once at program start' I do not see where it says it must be the value '0' (at least for an integer class variable).

    Cheers

    RMV

Children
Related