Skip to content

Conversation

@rirfha948
Copy link

Reason for change: Fixes for CcspCommonLibrary
Coverity Fixes
Test Procedure:

  • TBD Risks: None
    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

Reason for change: Fixes for CcspCommonLibrary Coverity Fixes
Test Procedure:
  - TBD
Risks: None
Priority: P3

Signed-off-by: rirfha948 <[email protected]>
@rirfha948 rirfha948 requested review from a team as code owners October 28, 2025 09:10
@rirfha948 rirfha948 requested a review from snayak002c October 28, 2025 09:11
@rirfha948 rirfha948 changed the title RDKB-61923: Coverity Cleanup for CcspCommonLibrary RDKB-61923: Coverity Cleanup -Y2K38_SAFETY Oct 28, 2025
@snayak002c snayak002c requested a review from Copilot October 29, 2025 17:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_t usage 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.

Comment on lines +396 to 400
int64_t timeNow;

UserGetNtpTime(&timeNow);
UserGetNtpTime((time_t*)&timeNow);

return timeNow;
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
UserGetNtpTime(&timeNow);
UserGetNtpTime((time_t*)&timeNow);

return timeNow;
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants