diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index efcaa1d1..dcaaebdd 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -97,9 +97,8 @@ jobs:
- name: Run Coverage
run: |
make -C build/ coverage
- declare -a EXCLUDE=("\*test\*" "\*CMakeCCompilerId.c")
- echo ${EXCLUDE[@]} | xargs lcov --rc branch_coverage=1 --ignore-errors empty --ignore-errors source -r build/coverage.info -o build/coverage.info
- lcov --rc branch_coverage=1 --ignore-errors empty --ignore-errors source --list build/coverage.info
+ lcov --rc branch_coverage=1 -r build/coverage.info -o build/coverage.info
+ lcov --rc branch_coverage=1 --summary build/coverage.info
- name: Check Coverage
uses: FreeRTOS/CI-CD-Github-Actions/coverage-cop@main
@@ -126,14 +125,14 @@ jobs:
path: ./
formatting:
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check formatting
uses: FreeRTOS/CI-CD-Github-Actions/formatting@main
with:
path: ./
- exclude-dirs: .git
+ exclude-dirs: .git, test/unit-test/CMock
git-secrets:
runs-on: ubuntu-latest
@@ -207,7 +206,7 @@ jobs:
proof_ci:
if: ${{ github.event.pull_request }} || ${{ github.event.workflow }}
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-latest
steps:
- name: Set up CBMC runner
uses: FreeRTOS/CI-CD-Github-Actions/set_up_cbmc_runner@main
diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml
index 04786bad..707ca352 100644
--- a/.github/workflows/formatting.yml
+++ b/.github/workflows/formatting.yml
@@ -16,7 +16,7 @@ jobs:
if: ${{ github.event.issue.pull_request &&
( ( github.event.comment.body == '/bot run uncrustify' ) ||
( github.event.comment.body == '/bot run formatting' ) ) }}
- runs-on: ubuntu-20.04
+ runs-on: ubuntu-latest
steps:
- name: Apply Formatting Fix
uses: FreeRTOS/CI-CD-Github-Actions/formatting-bot@main
diff --git a/docs/doxygen/code_examples/example_sntp_client_posix.c b/docs/doxygen/code_examples/example_sntp_client_posix.c
index d7f74b7a..802b471b 100644
--- a/docs/doxygen/code_examples/example_sntp_client_posix.c
+++ b/docs/doxygen/code_examples/example_sntp_client_posix.c
@@ -139,7 +139,7 @@ static void sntpClient_SetTime( const SntpServerInfo_t * pTimeServer,
SntpLeapSecondInfo_t leapSecondInfo )
{
/* @[code_example_sntp_converttounixtime] */
- UnixTime_t unixSecs;
+ uint32_t unixSecs;
uint32_t unixMs;
SntpStatus_t status = Sntp_ConvertToUnixTime( pServerTime, &unixSecs, &unixMs );
diff --git a/docs/doxygen/images/Ntp_To_Unix_Time.png b/docs/doxygen/images/Ntp_To_Unix_Time.png
new file mode 100644
index 00000000..7d6d98e7
Binary files /dev/null and b/docs/doxygen/images/Ntp_To_Unix_Time.png differ
diff --git a/docs/doxygen/include/size_table.md b/docs/doxygen/include/size_table.md
index 76263e22..66c39dce 100644
--- a/docs/doxygen/include/size_table.md
+++ b/docs/doxygen/include/size_table.md
@@ -15,11 +15,11 @@
| core_sntp_serializer.c |
1.0K |
- 0.8K |
+ 0.7K |
| Total estimates |
2.7K |
- 2.1K |
+ 2.0K |
diff --git a/source/core_sntp_serializer.c b/source/core_sntp_serializer.c
index 3269130d..bb7823a3 100644
--- a/source/core_sntp_serializer.c
+++ b/source/core_sntp_serializer.c
@@ -812,7 +812,7 @@ SntpStatus_t Sntp_CalculatePollInterval( uint16_t clockFreqTolerance,
}
SntpStatus_t Sntp_ConvertToUnixTime( const SntpTimestamp_t * pSntpTime,
- UnixTime_t * pUnixTimeSecs,
+ uint32_t * pUnixTimeSecs,
uint32_t * pUnixTimeMicrosecs )
{
SntpStatus_t status = SntpSuccess;
@@ -821,24 +821,20 @@ SntpStatus_t Sntp_ConvertToUnixTime( const SntpTimestamp_t * pSntpTime,
{
status = SntpErrorBadParameter;
}
- else
+
+ if( status == SntpSuccess )
{
- /* Handle case when timestamp represents date in SNTP era 1
- * (i.e. time from 7 Feb 2036 6:28:16 UTC onwards). */
- if( pSntpTime->seconds <= SNTP_TIME_AT_LARGEST_UNIX_TIME_SECS )
+ /* Handle case when SNTP timestamp is in SNTP era 0 time range
+ * (i.e. time before 7 Feb 2036 6:28:15 UTC). */
+ if( pSntpTime->seconds >= SNTP_TIME_AT_UNIX_EPOCH_SECS )
{
- /* Unix Time ( seconds ) = Seconds Duration in
- * [UNIX epoch, SNTP Era 1 Epoch Time]
- * +
- * Sntp Time since Era 1 Epoch
- */
- *pUnixTimeSecs = ( UnixTime_t ) ( UNIX_TIME_SECS_AT_SNTP_ERA_1_SMALLEST_TIME + ( UnixTime_t ) ( pSntpTime->seconds ) );
+ *pUnixTimeSecs = pSntpTime->seconds - SNTP_TIME_AT_UNIX_EPOCH_SECS;
}
-
- /* Handle case when SNTP timestamp is in SNTP era 1 time range. */
- if( pSntpTime->seconds >= SNTP_TIME_AT_UNIX_EPOCH_SECS )
+ else
{
- *pUnixTimeSecs = ( UnixTime_t ) ( ( UnixTime_t ) ( pSntpTime->seconds ) - SNTP_TIME_AT_UNIX_EPOCH_SECS );
+ /* Handle case when timestamp represents date in SNTP era 1
+ * (i.e. time from 7 Feb 2036 6:28:16 UTC onwards). */
+ *pUnixTimeSecs = UNIX_TIME_SECS_AT_SNTP_ERA_1_SMALLEST_TIME + pSntpTime->seconds;
}
/* Convert SNTP fractions to microseconds for UNIX time. */
diff --git a/source/include/core_sntp_serializer.h b/source/include/core_sntp_serializer.h
index 64295f85..b0869bbe 100644
--- a/source/include/core_sntp_serializer.h
+++ b/source/include/core_sntp_serializer.h
@@ -43,20 +43,6 @@
#endif
/* *INDENT-ON* */
-/**
- * @brief Type representing seconds since Unix epoch (January 1, 1970 UTC).
- *
- * The width of this type depends on the configuration macro USE_LEGACY_TIME_API:
- * - If USE_LEGACY_TIME_API is defined, a 32-bit unsigned integer is used.
- * This limits date representation to the year 2038 (Y2038 limitation).
- * - Otherwise, a 64-bit unsigned integer is used for Y2038 compliance.
- */
-#ifdef USE_LEGACY_TIME_API
- typedef uint32_t UnixTime_t; /**< 32-bit Unix time for legacy systems. */
-#else
- typedef uint64_t UnixTime_t; /**< 64-bit Unix time for Y2038 compliance. */
-#endif
-
/**
* @ingroup sntp_constants
* @brief The base packet size of request and response of the (S)NTP protocol.
@@ -504,15 +490,7 @@ SntpStatus_t Sntp_CalculatePollInterval( uint16_t clockFreqTolerance,
* @brief Utility to convert SNTP timestamp (that uses 1st Jan 1900 as the epoch) to
* UNIX timestamp (that uses 1st Jan 1970 as the epoch).
*
- * @note This function converts SNTP timestamps to UNIX time supporting both 32-bit and
- * 64-bit representations based on the configuration macro USE_LEGACY_TIME_API.
- *
- * - If USE_LEGACY_TIME_API is defined, the conversion is limited to the date range
- * from 1st Jan 1970 0h 0m 0s (UNIX epoch) to 19th Jan 2038 3h 14m 7s, due to the
- * 32-bit width limitation.
- *
- * - If USE_LEGACY_TIME_API is not defined, 64-bit UNIX time representation is used,
- * allowing conversion of SNTP timestamps beyond the year 2038 (Y2038 problem mitigated).
+ * Refer to (this image)[docs/doxygen/images/Ntp_To_Unix_Time.png].
*
* @note The function also correctly handles SNTP era overflow (from 7 Feb 2036 6h 28m 16s,
* i.e., SNTP era 1) to ensure accurate conversion across SNTP eras.
@@ -529,7 +507,7 @@ SntpStatus_t Sntp_CalculatePollInterval( uint16_t clockFreqTolerance,
*/
/* @[define_sntp_converttounixtime] */
SntpStatus_t Sntp_ConvertToUnixTime( const SntpTimestamp_t * pSntpTime,
- UnixTime_t * pUnixTimeSecs,
+ uint32_t * pUnixTimeSecs,
uint32_t * pUnixTimeMicrosecs );
/* @[define_sntp_converttounixtime] */
diff --git a/test/cbmc/proofs/Sntp_ConvertToUnixTime/Sntp_ConvertToUnixTime_harness.c b/test/cbmc/proofs/Sntp_ConvertToUnixTime/Sntp_ConvertToUnixTime_harness.c
index 797bab90..c3bb62b5 100644
--- a/test/cbmc/proofs/Sntp_ConvertToUnixTime/Sntp_ConvertToUnixTime_harness.c
+++ b/test/cbmc/proofs/Sntp_ConvertToUnixTime/Sntp_ConvertToUnixTime_harness.c
@@ -32,12 +32,12 @@
void harness()
{
SntpTimestamp_t * pSntpTime;
- UnixTime_t * pUnixTimeSecs;
+ uint32_t * pUnixTimeSecs;
uint32_t * pUnixTimeMicrosecs;
SntpStatus_t sntpStatus;
pSntpTime = malloc( sizeof( SntpTimestamp_t ) );
- pUnixTimeSecs = malloc( sizeof( UnixTime_t ) );
+ pUnixTimeSecs = malloc( sizeof( uint32_t ) );
pUnixTimeMicrosecs = malloc( sizeof( uint32_t ) );
sntpStatus = Sntp_ConvertToUnixTime( pSntpTime, pUnixTimeSecs, pUnixTimeMicrosecs );
diff --git a/test/unit-test/core_sntp_serializer_utest.c b/test/unit-test/core_sntp_serializer_utest.c
index 90b5bd5c..621f5db6 100644
--- a/test/unit-test/core_sntp_serializer_utest.c
+++ b/test/unit-test/core_sntp_serializer_utest.c
@@ -877,7 +877,7 @@ void test_ConvertToUnixTime_InvalidParams( void )
/* Use same memory for UNIX seconds and microseconds as we are not
* testing those values. */
- UnixTime_t unixTime;
+ uint32_t unixTime;
uint32_t unixTimeMs;
/* Test with NULL SNTP time. */
@@ -900,7 +900,7 @@ void test_ConvertToUnixTime_InvalidParams( void )
void test_ConvertToUnixTime_Nominal( void )
{
SntpTimestamp_t sntpTime = TEST_TIMESTAMP;
- UnixTime_t unixTimeSecs;
+ uint32_t unixTimeSecs;
uint32_t unixTimeMs;
#define TEST_SNTP_TO_UNIX_CONVERSION( sntpTimeSecs, sntpTimeFracs, \
diff --git a/tools/cmock/coverage.cmake b/tools/cmock/coverage.cmake
index 500aab22..53970df4 100644
--- a/tools/cmock/coverage.cmake
+++ b/tools/cmock/coverage.cmake
@@ -15,11 +15,9 @@ execute_process( COMMAND lcov --directory ${CMAKE_BINARY_DIR}
--initial
--capture
--rc branch_coverage=1
- --ignore-errors empty
- --ignore-errors source
--rc genhtml_branch_coverage=1
--output-file=${CMAKE_BINARY_DIR}/base_coverage.info
- --quiet
+ --include "*source*"
)
file(GLOB files "${CMAKE_BINARY_DIR}/bin/tests/*")
@@ -49,13 +47,11 @@ execute_process(COMMAND ruby
execute_process(
COMMAND lcov --capture
--rc branch_coverage=1
- --ignore-errors empty
- --ignore-errors source
--rc genhtml_branch_coverage=1
--base-directory ${CMAKE_BINARY_DIR}
--directory ${CMAKE_BINARY_DIR}
--output-file ${CMAKE_BINARY_DIR}/second_coverage.info
- --quiet
+ --include "*source*"
)
# combile baseline results (zeros) with the one after running the tests
@@ -67,16 +63,10 @@ execute_process(
--output-file ${CMAKE_BINARY_DIR}/coverage.info
--no-external
--rc branch_coverage=1
- --ignore-errors empty
- --ignore-errors source
- --quiet
)
execute_process(
COMMAND genhtml --rc branch_coverage=1
- --ignore-errors empty
- --ignore-errors source
--branch-coverage
--output-directory ${CMAKE_BINARY_DIR}/coverage
${CMAKE_BINARY_DIR}/coverage.info
- --quiet
- )
+ )