From c11c71ca1a117874d2d8d97103e1e25eba82aa7a Mon Sep 17 00:00:00 2001 From: rirfha948 Date: Tue, 28 Oct 2025 09:05:13 +0000 Subject: [PATCH] RDKB-00: Coverity Cleanup for CcspCommonLibrary Reason for change: Fixes for CcspCommonLibrary Coverity Fixes Test Procedure: - TBD Risks: None Priority: P3 Signed-off-by: rirfha948 --- source/util_api/ansc/AnscPlatform/user_time.c | 9 +++++++-- .../util_api/ansc/AnscPlatform/user_time_priv.c | 15 +++++++++------ source/util_api/ccsp_msg_bus/ccsp_base_api_srv.c | 7 ++++--- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/source/util_api/ansc/AnscPlatform/user_time.c b/source/util_api/ansc/AnscPlatform/user_time.c index 2049c74e4..872b84c9c 100644 --- a/source/util_api/ansc/AnscPlatform/user_time.c +++ b/source/util_api/ansc/AnscPlatform/user_time.c @@ -71,6 +71,11 @@ 04/03/02 adapted to linux user by Ying Lou **********************************************************************/ +#define _TIME_BITS 64 +#define _FILE_OFFSET_BITS 64 +#include +#include "time.h" + #include "user_base.h" #include "user_time.h" #include "safec_lib_common.h" @@ -388,9 +393,9 @@ UserGetTzOffset( void ) unsigned long UserGetUtcSeconds( void ) { - time_t timeNow; + int64_t timeNow; - UserGetNtpTime(&timeNow); + UserGetNtpTime((time_t*)&timeNow); return timeNow; } diff --git a/source/util_api/ansc/AnscPlatform/user_time_priv.c b/source/util_api/ansc/AnscPlatform/user_time_priv.c index ed05cb4a3..5dc11c686 100644 --- a/source/util_api/ansc/AnscPlatform/user_time_priv.c +++ b/source/util_api/ansc/AnscPlatform/user_time_priv.c @@ -67,6 +67,11 @@ 05/01/14 initial revision. **********************************************************************/ +#define _TIME_BITS 64 +#define _FILE_OFFSET_BITS 64 +#include +#include "time.h" + #include "user_base.h" #include "user_time.h" @@ -297,7 +302,6 @@ UserGetTickInMilliSeconds() void UserSetSystemTime(USER_SYSTEM_TIME* pSystemTime) { - time_t newTime; struct tm newtm; struct timeval newtv; union semun semopts; @@ -317,7 +321,7 @@ UserSetSystemTime(USER_SYSTEM_TIME* pSystemTime) newtm.tm_isdst = 1; #if !defined(_ANSC_LINUX_NO_TM_GMT) - newTime = timegm(&newtm); + int64_t newTime = (int64_t)timegm(&newtm); /*CID: 62026 Argument cannot be negative*/ if (newTime < 0) { printf("newTime cant be negative\n"); @@ -330,7 +334,7 @@ UserSetSystemTime(USER_SYSTEM_TIME* pSystemTime) newtm.tm_min, newtm.tm_sec, newtm.tm_isdst); */ - newtv.tv_sec = (long)newTime; + newtv.tv_sec = newTime; newtv.tv_usec = 0; if ( sid == -1 ) @@ -367,7 +371,6 @@ UserGetTimeNow(time_t *timeNow, struct tm *Tm) void UserSetLocalTime(USER_SYSTEM_TIME* pSystemTime) { - time_t newTime; struct tm newtm; struct timeval newtv; union semun semopts; @@ -390,14 +393,14 @@ UserSetLocalTime(USER_SYSTEM_TIME* pSystemTime) newtm.tm_min, newtm.tm_sec, newtm.tm_isdst); - newTime = mktime(&newtm); + int64_t newTime = (int64_t)mktime(&newtm); /*CID:55942 Argument cannot be negative*/ if (newTime < 0) { printf("newTime cant be negative\n"); return; } - newtv.tv_sec = (long)newTime; + newtv.tv_sec = newTime; newtv.tv_usec = 0; if ( sid == -1 ) { diff --git a/source/util_api/ccsp_msg_bus/ccsp_base_api_srv.c b/source/util_api/ccsp_msg_bus/ccsp_base_api_srv.c index 57627c9e8..6606f66dd 100644 --- a/source/util_api/ccsp_msg_bus/ccsp_base_api_srv.c +++ b/source/util_api/ccsp_msg_bus/ccsp_base_api_srv.c @@ -32,7 +32,8 @@ See the License for the specific language governing permissions and limitations under the License. **********************************************************************/ - +#define _TIME_BITS 64 +#define _FILE_OFFSET_BITS 64 #include #include #include @@ -725,7 +726,7 @@ CcspBaseIf_Deadlock_Detection_Thread FILE * fd = NULL; struct timespec time1 = {0}; - unsigned long currentTime = 0; + time_t currentTime = 0; unsigned long deadLockHappen = 0; time1.tv_sec = 3; @@ -747,7 +748,7 @@ CcspBaseIf_Deadlock_Detection_Thread info->enterTime = currentTime - info->timepassed ; CcspTraceWarning((" **** info->timepassed %lu ******\n",info->timepassed)); CcspTraceWarning((" **** info->enterTime %lu ******\n",info->enterTime)); - CcspTraceWarning((" **** currentTime %lu ******\n",currentTime)); + CcspTraceWarning((" **** currentTime %llu ******\n",currentTime)); } else {