Error with CRITICAL_SECTION in SDK

When compiling some USB code, my compiler spits out this error:

../../SDK/15.3.0/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.c: In function 'app_usbd_hid_generic_idle_report_set':
../../SDK/15.3.0/components/libraries/usbd/class/hid/generic/app_usbd_hid_generic.c:257:12: error: 'ret' undeclared (first use in this function); did you mean 'gets'?

referencing this function:

ret_code_t app_usbd_hid_generic_idle_report_set(app_usbd_hid_generic_t const * p_generic,
                                                const void                   * p_buff,
                                                size_t                         size)
{
    app_usbd_class_inst_t const  * p_inst        = (app_usbd_class_inst_t const *)p_generic;
    app_usbd_hid_generic_ctx_t   * p_generic_ctx = hid_generic_ctx_get(p_generic);

    nrf_drv_usbd_ep_t ep_addr = app_usbd_hid_epin_addr_get(p_inst);

    app_usbd_hid_state_flag_clr(&p_generic_ctx->hid_ctx,
                                APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS);

    NRF_DRV_USBD_TRANSFER_IN(transfer, p_buff, size);

    CRITICAL_REGION_ENTER();
    ret_code_t ret = app_usbd_ep_transfer(ep_addr, &transfer);
    if (ret == NRF_SUCCESS)
    {
        app_usbd_hid_state_flag_set(&p_generic_ctx->hid_ctx,
                                    APP_USBD_HID_STATE_FLAG_TRANS_IN_PROGRESS);
    }
    CRITICAL_REGION_EXIT();

    return ret;
}

According to AI, ret gets defined within the CRITICAL_SECTION, so it goes out of scope after the section.

Hence, it cannot be referenced.

How would I fix this?

Thanks!

Related