Skip to content

Commit

Permalink
Fix code review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
kar-rahul-aws committed Apr 26, 2024
1 parent 5c2c988 commit d4ed6ec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions FreeRTOS-Plus/Demo/coreSNTP_Windows_Simulator/SNTPClientTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ static SntpStatus_t addClientAuthCode( SntpAuthContext_t * pAuthContext,
static SntpStatus_t validateServerAuth( SntpAuthContext_t * pAuthContext,
const SntpServerInfo_t * pTimeServer,
const void * pResponseData,
size_t responseSize );
uint16_t responseSize );

/**
* @brief Generates a random number using PKCS#11.
Expand Down Expand Up @@ -667,7 +667,7 @@ void calculateCurrentTime( UTCTime_t * pBaseTime,
uint64_t slewRate,
UTCTime_t * pCurrentTime )
{
uint32_t msElapsedSinceLastSync = 0;
uint64_t msElapsedSinceLastSync = 0;
TickType_t ticksElapsedSinceLastSync = xTaskGetTickCount() - lastSyncTickCount;

/* Calculate time elapsed since last synchronization according to the number
Expand All @@ -680,19 +680,19 @@ void calculateCurrentTime( UTCTime_t * pBaseTime,
/* Slew Adjustment = Slew Rate ( Milliseconds/seconds )
* x
* No. of seconds since last synchronization. */
msElapsedSinceLastSync = msElapsedSinceLastSync + ( uint32_t ) ( slewRate * ( msElapsedSinceLastSync / 1000 ) );
msElapsedSinceLastSync += slewRate * ( msElapsedSinceLastSync / 1000 );
}

/* Set the current UTC time in the output parameter. */
if( msElapsedSinceLastSync >= 1000 )
{
pCurrentTime->secs = pBaseTime->secs + msElapsedSinceLastSync / 1000;
pCurrentTime->secs = ( uint32_t ) ( pBaseTime->secs + msElapsedSinceLastSync / 1000 );
pCurrentTime->msecs = msElapsedSinceLastSync % 1000;
}
else
{
pCurrentTime->secs = pBaseTime->secs;
pCurrentTime->msecs = msElapsedSinceLastSync;
pCurrentTime->msecs = ( uint32_t )( msElapsedSinceLastSync );
}
}

Expand Down Expand Up @@ -842,7 +842,7 @@ static int32_t UdpTransport_Recv( NetworkContext_t * pNetworkContext,
static void sntpClient_GetTime( SntpTimestamp_t * pCurrentTime )
{
UTCTime_t currentTime;
uint32_t ntpSecs;
uint64_t ntpSecs;

/* Obtain mutex for accessing system clock variables */
xSemaphoreTake( xMutex, portMAX_DELAY );
Expand All @@ -856,19 +856,19 @@ static void sntpClient_GetTime( SntpTimestamp_t * pCurrentTime )
xSemaphoreGive( xMutex );

/* Convert UTC time from UNIX timescale to SNTP timestamp format. */
ntpSecs = currentTime.secs + SNTP_TIME_AT_UNIX_EPOCH_SECS;
ntpSecs = ( uint64_t ) ( currentTime.secs + SNTP_TIME_AT_UNIX_EPOCH_SECS );

/* Support case of SNTP timestamp rollover on 7 February 2036 when
* converting from UNIX time to SNTP timestamp. */
if( ntpSecs > UINT32_MAX )
{
/* Subtract an extra second as timestamp 0 represents the epoch for
* NTP era 1. */
pCurrentTime->seconds = ntpSecs - UINT32_MAX - 1;
pCurrentTime->seconds = ( uint32_t ) ( ntpSecs - UINT32_MAX - 1 );
}
else
{
pCurrentTime->seconds = ntpSecs;
pCurrentTime->seconds = ( uint32_t ) ( ntpSecs );
}

pCurrentTime->fractions = MILLISECONDS_TO_SNTP_FRACTIONS( currentTime.msecs );
Expand Down Expand Up @@ -1158,7 +1158,7 @@ SntpStatus_t addClientAuthCode( SntpAuthContext_t * pAuthContext,
SntpStatus_t validateServerAuth( SntpAuthContext_t * pAuthContext,
const SntpServerInfo_t * pTimeServer,
const void * pResponseData,
size_t responseSize )
uint16_t responseSize )
{
CK_RV result = CKR_OK;
CK_FUNCTION_LIST_PTR functionList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
Expand Down

0 comments on commit d4ed6ec

Please sign in to comment.