Conversation
Reason for change: Fixes for CcspCommonLibrary Coverity Fixes Test Procedure: - TBD Risks: None Priority: P3 Signed-off-by: rirfha948 <rasina_irfhan@comcast.com>
There was a problem hiding this comment.
Pull Request Overview
This PR implements support for 64-bit time types to prepare for the year 2038 problem on 32-bit systems. The changes enable _TIME_BITS 64 and _FILE_OFFSET_BITS 64 to ensure proper handling of timestamps beyond 2038.
- Changed
time_tusage to handle 64-bit timestamps - Updated format specifiers for time-related logging
- Modified time conversion functions to use explicit 64-bit types
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| source/util_api/ccsp_msg_bus/ccsp_base_api_srv.c | Enabled 64-bit time support and updated currentTime variable type and format specifier |
| source/util_api/ansc/AnscPlatform/user_time_priv.c | Enabled 64-bit time support, changed newTime to int64_t with explicit casting |
| source/util_api/ansc/AnscPlatform/user_time.c | Enabled 64-bit time support and modified UserGetUtcSeconds to use int64_t |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| int64_t timeNow; | ||
|
|
||
| UserGetNtpTime(&timeNow); | ||
| UserGetNtpTime((time_t*)&timeNow); | ||
|
|
||
| return timeNow; |
There was a problem hiding this comment.
Casting a pointer to int64_t to time_t* is unsafe. With _TIME_BITS 64 enabled, time_t should already be 64-bit, so a local time_t variable should be used instead. This avoids potential aliasing issues and undefined behavior. Consider: time_t timeNow; UserGetNtpTime(&timeNow); return (unsigned long)timeNow; or change the return type to match the actual data type.
| UserGetNtpTime(&timeNow); | ||
| UserGetNtpTime((time_t*)&timeNow); | ||
|
|
||
| return timeNow; |
There was a problem hiding this comment.
The function UserGetUtcSeconds returns unsigned long but timeNow is int64_t. On 32-bit systems, this will truncate the 64-bit value to 32 bits, defeating the purpose of using 64-bit time types. The function signature should be updated to return uint64_t or time_t to properly handle 64-bit timestamps.
Reason for change: Fixes for CcspCommonLibrary
Coverity Fixes
Test Procedure:
Priority: P3
Before Analysis summary report:
Files analyzed : 1395 Total
C : 1395
Total LoC input to cov-analyze : 449133
Functions analyzed : 7353
Classes/structs analyzed : 909
Paths analyzed : 558951
Time taken by analysis : 00:00:14
Defect occurrences found : 415 Total
3 ATOMICITY
2 BAD_CHECK_OF_WAIT_COND
11 CHECKED_RETURN
2 CONSTANT_EXPRESSION_RESULT
2 COPY_PASTE_ERROR
87 DEADCODE
24 FORWARD_NULL
2 IDENTICAL_BRANCHES
43 INTEGER_OVERFLOW
1 LOCK
1 LOCK_EVASION
24 MISSING_LOCK
1 NEGATIVE_RETURNS
3 NO_EFFECT
5 NULL_RETURNS
3 PW.INCLUDE_RECURSION
1 PW.PARAMETER_HIDDEN
24 RESOURCE_LEAK
7 REVERSE_INULL
3 SIZEOF_MISMATCH
2 SLEEP
8 STRING_OVERFLOW
17 TAINTED_SCALAR
4 UNREACHABLE
80 UNUSED_VALUE
1 USELESS_CALL
39 USE_AFTER_FREE
15 Y2K38_SAFETY
after:
Analysis summary report:
Files analyzed : 1395 Total
C : 1395
Total LoC input to cov-analyze : 449179
Functions analyzed : 7353
Classes/structs analyzed : 911
Paths analyzed : 557995
Time taken by analysis : 00:00:28
Defect occurrences found : 395 Total
3 ATOMICITY
2 BAD_CHECK_OF_WAIT_COND
11 CHECKED_RETURN
2 CONSTANT_EXPRESSION_RESULT
2 COPY_PASTE_ERROR
87 DEADCODE
28 FORWARD_NULL
2 IDENTICAL_BRANCHES
33 INTEGER_OVERFLOW
1 LOCK_EVASION
24 MISSING_LOCK
1 NEGATIVE_RETURNS
3 NO_EFFECT
5 NULL_RETURNS
3 PW.INCLUDE_RECURSION
1 PW.PARAMETER_HIDDEN
24 RESOURCE_LEAK
7 REVERSE_INULL
3 SIZEOF_MISMATCH
2 SLEEP
8 STRING_OVERFLOW
17 TAINTED_SCALAR
4 UNREACHABLE
80 UNUSED_VALUE
1 USELESS_CALL
39 USE_AFTER_FREE
2 Y2K38_SAFETY