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.

TMS320F2809: Static analysis errors in SYS/BIOS generated file

Part Number: TMS320F2809

Hello,

I am using SYS/BIOS [6.83.0.18] and XDCtools [3.62.0.08] in my CCS project [10.4.0.00006]. 

We use Cppcheck [2.9] for static analysis and I keep getting errors -> [..\..\src\source\Debug\configPkg\package\cfg\app_p28L.c:2018] (error) va_list 'va' used before va_start() was called. [va_list_usedBeforeStarted]

This error is present on multiple lines in function "xdc_Int xdc_runtime_System_printfExtend__I(xdc_Char **pbuf, xdc_CString *pfmt, xdc_VaList *pva, xdc_runtime_System_ParseData *parse)"

As this file is generated I cannot find out how to fix this. Could anyone please assist?

Thank you,

Milan

  • If you can find the template file used to generate this code, you could try editing that? It looks like this one is in <xdctools install>\packages\xdc\runtime\System.xdt.

    Whitney

  • Thank you for this suggestion. I can technically alter this file but this is quite undesirable solution. I am basically changing a file that comes with XDC tools and will need to be changed (by anyone working on my project) on every update in his own installation.
    Also I am not entirely clear on how to modify this correctly. "va_start" is not called anywhere in this file and I am not able to find where is this actually called from and what parameters are passed to this function. As far as I can see this gets assigned to "xdc_runtime_System_extendFxn__C" but I do not get any other references to that in my project.

  • I played with the Swi example a bit since I knew it called System_printf, and found that calls to va_start showed up in the generated .c file.

    I'm a little surprised that you aren't seeing it in your generated file. Do you do System_printf (or similar function) calls in your project?

    Whitney

  • I am not using "System_printf" in my project. I found it in some unused library, but my problem persists even after removing that.

    There are some calls to "va_start" in the "app_p28L.c" file but I am not able to find the connection between these and the "xdc_runtime_System_printfExtend__I" to prove that "va_start" is indeed called.

    /*
     *  ======== System_printfExtend__I ========
     *  This function processes optional extended formats of printf.
     *
     *  It returns the number of characters added to the result.
     *
     *  Precision (maximum string length) is not supported for %$S.
     *
     *  Right-justified (which is default) minimum width is not supported
     *  for %$L, %$S, or %$F.
     */
    /* REQ_TAG(SYSBIOS-1072) */
    xdc_Int xdc_runtime_System_printfExtend__I(xdc_Char **pbuf, xdc_CString *pfmt,
        xdc_VaList *pva, xdc_runtime_System_ParseData *parse)

    /*
     * ======== xdc.runtime.System FUNCTION STUBS ========
     */
    
    /* printf_va__E */
    xdc_Int xdc_runtime_System_printf_va__E( xdc_CString fmt, va_list arg__va)
    {
        return xdc_runtime_System_printf_va__F(fmt, arg__va);
    }
    
    /* printf__E */
    xdc_Int xdc_runtime_System_printf__E( xdc_CString fmt, ...)
    {
        xdc_Int retval;
    
        va_list arg__va;
        (void)va_start(arg__va, fmt);
        retval = xdc_runtime_System_printf_va__F(fmt, arg__va);
    
        va_end(arg__va);
        return retval;
    }
    
    /* aprintf_va__E */
    xdc_Int xdc_runtime_System_aprintf_va__E( xdc_CString fmt, va_list arg__va)
    {
        return xdc_runtime_System_aprintf_va__F(fmt, arg__va);
    }
    
    /* aprintf__E */
    xdc_Int xdc_runtime_System_aprintf__E( xdc_CString fmt, ...)
    {
        xdc_Int retval;
    
        va_list arg__va;
        (void)va_start(arg__va, fmt);
        retval = xdc_runtime_System_aprintf_va__F(fmt, arg__va);
    
        va_end(arg__va);
        return retval;
    }
    
    /* sprintf_va__E */
    xdc_Int xdc_runtime_System_sprintf_va__E( xdc_Char buf[], xdc_CString fmt, va_list arg__va)
    {
        return xdc_runtime_System_sprintf_va__F(buf, fmt, arg__va);
    }
    
    /* sprintf__E */
    xdc_Int xdc_runtime_System_sprintf__E( xdc_Char buf[], xdc_CString fmt, ...)
    {
        xdc_Int retval;
    
        va_list arg__va;
        (void)va_start(arg__va, fmt);
        retval = xdc_runtime_System_sprintf_va__F(buf, fmt, arg__va);
    
        va_end(arg__va);
        return retval;
    }
    
    /* asprintf_va__E */
    xdc_Int xdc_runtime_System_asprintf_va__E( xdc_Char buf[], xdc_CString fmt, va_list arg__va)
    {
        return xdc_runtime_System_asprintf_va__F(buf, fmt, arg__va);
    }
    
    /* asprintf__E */
    xdc_Int xdc_runtime_System_asprintf__E( xdc_Char buf[], xdc_CString fmt, ...)
    {
        xdc_Int retval;
    
        va_list arg__va;
        (void)va_start(arg__va, fmt);
        retval = xdc_runtime_System_asprintf_va__F(buf, fmt, arg__va);
    
        va_end(arg__va);
        return retval;
    }
    
    /* snprintf_va__E */
    xdc_Int xdc_runtime_System_snprintf_va__E( xdc_Char buf[], xdc_SizeT n, xdc_CString fmt, va_list arg__va)
    {
        return xdc_runtime_System_snprintf_va__F(buf, n, fmt, arg__va);
    }
    
    /* snprintf__E */
    xdc_Int xdc_runtime_System_snprintf__E( xdc_Char buf[], xdc_SizeT n, xdc_CString fmt, ...)
    {
        xdc_Int retval;
    
        va_list arg__va;
        (void)va_start(arg__va, fmt);
        retval = xdc_runtime_System_snprintf_va__F(buf, n, fmt, arg__va);
    
        va_end(arg__va);
        return retval;
    }

  • Are these functions showing up in your .map file? Are you able to use the CCS debugger to place breakpoints in these functions to see if they're ever called? To my knowledge they're only relevant to print calls. The System module is used for the abort function as well as printf, so it may be generating all the functions for the System module even if you're only using the abort/exit functionality.

    Whitney

  • There is not a single mention of "print" in my .map file (fun fact, with hex utility enabled .map file gets re-written by its output). I am also not able to place breakpoint. I get this message:

    Looks like I am just going to pronounce this unused generated code and hope our security team lets it go.

    Thank you very much for your help. I have never went this deep into background foundations of our projects.