Skip to content

Commit

Permalink
Check for return value
Browse files Browse the repository at this point in the history
  • Loading branch information
moninom1 committed Nov 1, 2023
1 parent e57fc31 commit 45d8e48
Showing 1 changed file with 32 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -938,32 +938,38 @@ static void dns_test( const char * pcHostName )
uint32_t ulID;
BaseType_t rc;

( void ) xApplicationGetRandomNumber( &ulID );
FreeRTOS_dnsclear();

struct freertos_addrinfo xHints;
struct freertos_addrinfo * pxResult = NULL;

memset( &xHints, 0, sizeof xHints );
xHints.ai_family = FREERTOS_AF_INET6;

rc = FreeRTOS_getaddrinfo( pcHostName, NULL, &xHints, &pxResult );

FreeRTOS_printf( ( "Lookup '%s': %d\n", pcHostName, rc ) );

FreeRTOS_dnsclear();
xDNSResult = -2;
rc = FreeRTOS_getaddrinfo_a( pcHostName,
NULL,
&xHints,
&pxResult, /* An allocated struct, containing the results. */
vDNSEvent,
( void * ) ulID,
pdMS_TO_TICKS( 1000U ) );
vTaskDelay( pdMS_TO_TICKS( 1000U ) );
rc = xDNSResult;
FreeRTOS_printf( ( "Lookup '%s': %d\n", pcHostName, rc ) );
/* FreeRTOS_gethostbyname( pcHostName ); */
if( xApplicationGetRandomNumber( &( ulID ) ) != pdFALSE )
{
FreeRTOS_dnsclear();

struct freertos_addrinfo xHints;
struct freertos_addrinfo * pxResult = NULL;

memset( &xHints, 0, sizeof xHints );
xHints.ai_family = FREERTOS_AF_INET6;

rc = FreeRTOS_getaddrinfo( pcHostName, NULL, &xHints, &pxResult );

FreeRTOS_printf( ( "Lookup '%s': %d\n", pcHostName, rc ) );

FreeRTOS_dnsclear();
xDNSResult = -2;
rc = FreeRTOS_getaddrinfo_a( pcHostName,
NULL,
&xHints,
&pxResult, /* An allocated struct, containing the results. */
vDNSEvent,
( void * ) ulID,
pdMS_TO_TICKS( 1000U ) );
vTaskDelay( pdMS_TO_TICKS( 1000U ) );
rc = xDNSResult;
FreeRTOS_printf( ( "Lookup '%s': %d\n", pcHostName, rc ) );
/* FreeRTOS_gethostbyname( pcHostName ); */
}
else
{
FreeRTOS_printf( ( "dns_test: Failed to generate a random Search ID\n" ) );
}
}

void showAddressInfo( struct freertos_addrinfo * pxAddrInfo )
Expand Down

0 comments on commit 45d8e48

Please sign in to comment.