Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Variable "sec_mode" is used uninitialized at this location in the sourcecode

With IAR (EWARM) 8.50.9 the UART project in the SDK compiles fine.

After upgrading to IAR (EWARM) 9.10.1 or 9.10.2 I get compiler error:

 Error[Go029]: Variable "sec_mode" is used uninitialized at this location in the sourcecode. D:\2\IAR\nRF5_SDK_17.0.2_d674dde\examples\ble_peripheral\ble_app_uart\main.c 156 

Any help on what the problem is?

Parents
  • Karl,

    This the fix from IAR

    This is a bug in EWARM 9.10.2.

    1. It was reported as bug EWARM-8754.It has been fixed but not incorporated into
    any release yet. Than it was reported again as bug EWARM-8834 in NordicSemi nRF5_SDK.

    2. The Work around is to initilaize the variable in the  gap_params_init(void) function
    as below:

    static void gap_params_init(void)
    {
        uint32_t                err_code;
        ble_gap_conn_params_t   gap_conn_params;
        ble_gap_conn_sec_mode_t sec_mode = {0};

    I tried it and it works.

    3. Another work around is to disable the error with #Pragma as below:

    ble_gap_conn_sec_mode_t sec_mode;
    #pragma diag_suppress=Go029
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);

    I hope this help.
    *****************************************************************************************
    The Error explanation:

    The problem is with struct variables with bifields:
    If the struct variable as a whole is uninitialized, then you incorrectly get Go029 when setting the first bifield.

    ble_gap_conn_sec_mode_t sec_mode;
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); // Error[Go029]: Variable "sec_mode" is used uninitialized

    *********************************************************************************************
    All the best,
    /Ori.

Reply
  • Karl,

    This the fix from IAR

    This is a bug in EWARM 9.10.2.

    1. It was reported as bug EWARM-8754.It has been fixed but not incorporated into
    any release yet. Than it was reported again as bug EWARM-8834 in NordicSemi nRF5_SDK.

    2. The Work around is to initilaize the variable in the  gap_params_init(void) function
    as below:

    static void gap_params_init(void)
    {
        uint32_t                err_code;
        ble_gap_conn_params_t   gap_conn_params;
        ble_gap_conn_sec_mode_t sec_mode = {0};

    I tried it and it works.

    3. Another work around is to disable the error with #Pragma as below:

    ble_gap_conn_sec_mode_t sec_mode;
    #pragma diag_suppress=Go029
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode);

    I hope this help.
    *****************************************************************************************
    The Error explanation:

    The problem is with struct variables with bifields:
    If the struct variable as a whole is uninitialized, then you incorrectly get Go029 when setting the first bifield.

    ble_gap_conn_sec_mode_t sec_mode;
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); // Error[Go029]: Variable "sec_mode" is used uninitialized

    *********************************************************************************************
    All the best,
    /Ori.

Children
  • Hello again Ori,

    Renix said:

    This the fix from IAR

    This is a bug in EWARM 9.10.2.

    Thank you for reaching out to IAR about this, and for forwarding me their reply on the matter.
    This is very helpful for me to have seen.

    Renix said:
    I tried it and it works.

    I am happy to hear that they provided a workaround that has resolved the issue you were facing.

    Renix said:
    All the best,

    And to you as well! :) 

    Please do not hesitate to open another ticket if you encounter any issues or questions in the future.

    Good luck with your development!

    Best regards,
    Karl

Related