SRC\file.c:163: warning: [#549-D] variable <name> is used before its value is set Reason:
Example 1: void func(void) { int var1; /* "var1" is not assigned any value */ int var2; var2 = var1; /* because "var1" has no value it is suspicious that it's value is assigned to other variable */ } Example 2: int varr1 = 10; /* varr1 has a value */ void func(void) { int var1; /*similarly named var1 has no value yet*/ int var2; var2 = var1; /* you intended to assign varr1 value, but typo turned it into var1 */ } Example 3: void func(uint8* param) { param = 3; /* The assignment is to the pointer, not to it's value*/ } Problems: 1&2: Normally compiler assigned all unassigned variables to zero. But this is not always the case. You should check from your compiler manual. On the other hand it is a good habit to initialise all variables manually, so there is no doubt. In both cases it is not safe to let this problem stay. In fact either 0 or completely random value is assigned, which would lead to wrong code behaviour. 3: Make sure you have a statically declared container for this pointer or allocated the memory from the heap. NB! Also keep in mind:
0 Comments
Your comment will be posted after it is approved.
Leave a Reply. |
AuthorWarnings are important! Archives
May 2017
Categories |