This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C language warning in SafeTI Library

Other Parts Discussed in Thread: TMS570LS0332

Hi,

I am using TMS570LS0332 in my design. I am using the SafeTI library along with the application. I could port the safeTI library and use the application. But i have the following warning in my software due to SafeTI library.

 #548-D transfer of control bypasses initialization of: sl_selftest.c /MonacoSC/BSP/SafetyLibrary/source line 162 C/C++ Problem

The warning is caused by a switch case in the following function. (in sl_selftest.c file).

boolean SL_SelfTest_SRAM(SL_SelfTestType testType, boolean bMode, SL_SelfTest_Result * sram_stResult)

There is a comment in the function specifying It is a False warning.

/* False warning */

switch(testType) {

}

I would like to remove this warning. 

Thanks & Best ragards,

Sreekanth challa

  • Sreekanth,

    Ok, but what exactly do you want to do? Change the code to remove the warning? Or instruct the compiler to not emit the warning?
  • Hi Anthony,

    I would like to remove the warning by chnaging the code.

    Thanks & Best regards,
    Sreekanth challa
  • Hi Sreekanth,

    Ok that's fine. What is the question though?

    -Anthony
  • Hi Anthony,

    I am not sure how to change the code to remove that warning, since the variable is passed as parameter from other function.

    Thanks & Best regards,
    sreekanth challa
  • Sreekanth,

    So I think we need to get support from the compiler team and also the author of the code on this.

    Are you compiling the file as C++? I'm not sure this applies to compiling as a C file so that may be why the comment says false warning.

    -Anthony
  • Sreekanth,

    I opened a thread on the compiler forum to get some expert advice related to this error, please see:
    e2e.ti.com/.../2044032

    George answered that he gets a more specific error indicating the line that has the variable declaration in question.

    Would you please let us know if you are using the more recent compiler and if so did you get this additional diagnostic line #?

    Then would you please tell me what the code is on that line. And anyway try including the code under that 'case' in {}.

    I think the idea of the warning is that unless the variable declared is in the { } then it is in the scope of the other cases where it is not declared and not initialized... so you might be bypassing the initialization of the variable but then using it somewhere else in a different case without being initialized. Whereas if you use {} to reduce the scope of that variable then if you did access it outside the particular case you would get an error and if you don't access outside the {} I think the warning can go away. Anyway I'm no expert on this but try those things and let us know what you see and we can sync up tomorrow.

    -Anthony
  • Hi Anthony,

    Thanks for prompt response.  I am using TI v5.2.4 compiler.  Thanks for the explanation regarding warning. I have sen George resonse. I can not see the  name of the variable in the the warning (In goerge case, the warning shows the variable name). 

    The exact line of the warning is::   switch(testType)      (C switch statement)

    The variable testType is one of the aragument passed to the function during funtion call. The function prototype is as follows.

    boolean SL_SelfTest_SRAM(SL_SelfTestType testType, boolean bMode, SL_SelfTest_Result * sram_stResult)

    Thanks & Best regards,

    sreekanth challa

  • Hi Sreekanth,

    I don't think the culprit is testType just based on what i could find about this warning. I think this is the switch() statement that causes the problem but the problem itself would be in one of the cases where a variable is declared and auto-initialized.

    Try putting {} blocks in each of the case statements to see if you can eliminate the warning.
  • Hi Anthony,

    Thanks for your support. The problem is solved.

    Best regards,
    Sreekanth Challa