From 2d757fc3219cb8bc5b8a6b34b8acc3d6ae6af250 Mon Sep 17 00:00:00 2001 From: Ryan Morse Date: Thu, 10 Oct 2019 10:28:34 -0700 Subject: [PATCH] Fixed issue with integer overflow when converting time units --- .../psoc6csp/abstraction/rtos/include/cyabs_rtos.h | 3 ++- .../abstraction/rtos/source/COMPONENT_RTX/cyabs_rtos_rtxv5.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6csp/abstraction/rtos/include/cyabs_rtos.h b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6csp/abstraction/rtos/include/cyabs_rtos.h index ec15a39b4f..a65bcc62c4 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6csp/abstraction/rtos/include/cyabs_rtos.h +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6csp/abstraction/rtos/include/cyabs_rtos.h @@ -167,7 +167,8 @@ extern cy_rtos_error_t cy_rtos_last_error(); * @param[in] entry_function Function pointer which points to the main function for the new thread * @param[in] name String thread name used for a debugger * @param[in] stack The buffer to use for the thread stack. This must be aligned to - CY_RTOS_ALIGNMENT with a size of at least CY_RTOS_MIN_STACK_SIZE + * CY_RTOS_ALIGNMENT with a size of at least CY_RTOS_MIN_STACK_SIZE. + * If stack is null, cy_rtos_create_thread will allocate a stack from the heap. * @param[in] stack_size The size of the thread stack in bytes * @param[in] priority The priority of the thread. Values are operating system specific, but some * common priority levels are defined: diff --git a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6csp/abstraction/rtos/source/COMPONENT_RTX/cyabs_rtos_rtxv5.c b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6csp/abstraction/rtos/source/COMPONENT_RTX/cyabs_rtos_rtxv5.c index 3bdf7d04c6..37de65f971 100644 --- a/targets/TARGET_Cypress/TARGET_PSOC6/psoc6csp/abstraction/rtos/source/COMPONENT_RTX/cyabs_rtos_rtxv5.c +++ b/targets/TARGET_Cypress/TARGET_PSOC6/psoc6csp/abstraction/rtos/source/COMPONENT_RTX/cyabs_rtos_rtxv5.c @@ -803,7 +803,7 @@ cy_rslt_t cy_rtos_get_time(cy_time_t *tval) /* Convert ticks count to time in milliseconds */ if (tick_freq != 0) - *tval = ((osKernelGetTickCount() * 1000) / tick_freq); + *tval = (cy_time_t)((osKernelGetTickCount() * 1000LL) / tick_freq); else status = CY_RTOS_GENERAL_ERROR; }