mirror of https://github.com/ARMmbed/mbed-os.git
DNS: Cast void* to intptr_t in nsapi_dns.cpp
This is for portability reasons. If this code was compiled to a 64-bit architecture, then the cast from void* to int would lose precision.pull/11735/head
parent
c018b2bd46
commit
83af4e0b36
|
|
@ -23,6 +23,7 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include "mbed_shared_queues.h"
|
||||
#include "events/EventQueue.h"
|
||||
#include "OnboardNetworkStack.h"
|
||||
|
|
@ -63,7 +64,7 @@ enum dns_state {
|
|||
};
|
||||
|
||||
struct DNS_QUERY {
|
||||
int unique_id;
|
||||
intptr_t unique_id;
|
||||
nsapi_error_t status;
|
||||
NetworkStack *stack;
|
||||
char *host;
|
||||
|
|
@ -94,7 +95,7 @@ static void nsapi_dns_cache_reset();
|
|||
static nsapi_error_t nsapi_dns_get_server_addr(NetworkStack *stack, uint8_t *index, uint8_t *total_attempts, uint8_t *send_success, SocketAddress *dns_addr, const char *interface_name);
|
||||
|
||||
static void nsapi_dns_query_async_create(void *ptr);
|
||||
static nsapi_error_t nsapi_dns_query_async_delete(int unique_id);
|
||||
static nsapi_error_t nsapi_dns_query_async_delete(intptr_t unique_id);
|
||||
static void nsapi_dns_query_async_send(void *ptr);
|
||||
static void nsapi_dns_query_async_timeout(void);
|
||||
static void nsapi_dns_query_async_resp(DNS_QUERY *query, nsapi_error_t status, SocketAddress *address);
|
||||
|
|
@ -122,7 +123,7 @@ static SingletonPtr<PlatformMutex> dns_cache_mutex;
|
|||
#endif
|
||||
|
||||
static uint16_t dns_message_id = 1;
|
||||
static int dns_unique_id = 1;
|
||||
static intptr_t dns_unique_id = 1;
|
||||
static DNS_QUERY *dns_query_queue[DNS_QUERY_QUEUE_SIZE];
|
||||
// Protects from several threads running asynchronous DNS
|
||||
static SingletonPtr<PlatformMutex> dns_mutex;
|
||||
|
|
@ -765,7 +766,7 @@ nsapi_value_or_error_t nsapi_dns_query_multiple_async(NetworkStack *stack, const
|
|||
|
||||
static void nsapi_dns_query_async_initiate_next(void)
|
||||
{
|
||||
int id = INT32_MAX;
|
||||
intptr_t id = INTPTR_MAX;
|
||||
DNS_QUERY *query = NULL;
|
||||
|
||||
// Trigger next query to start, find one that has been on queue longest
|
||||
|
|
@ -842,7 +843,7 @@ static void nsapi_dns_query_async_timeout(void)
|
|||
dns_mutex->unlock();
|
||||
}
|
||||
|
||||
nsapi_error_t nsapi_dns_query_async_cancel(int id)
|
||||
nsapi_error_t nsapi_dns_query_async_cancel(intptr_t id)
|
||||
{
|
||||
dns_mutex->lock();
|
||||
|
||||
|
|
@ -874,7 +875,7 @@ static void nsapi_dns_query_async_create(void *ptr)
|
|||
{
|
||||
dns_mutex->lock();
|
||||
|
||||
int unique_id = reinterpret_cast<int>(ptr);
|
||||
intptr_t unique_id = reinterpret_cast<intptr_t>(ptr);
|
||||
|
||||
DNS_QUERY *query = NULL;
|
||||
|
||||
|
|
@ -940,7 +941,7 @@ static void nsapi_dns_query_async_create(void *ptr)
|
|||
|
||||
}
|
||||
|
||||
static nsapi_error_t nsapi_dns_query_async_delete(int unique_id)
|
||||
static nsapi_error_t nsapi_dns_query_async_delete(intptr_t unique_id)
|
||||
{
|
||||
int index = -1;
|
||||
DNS_QUERY *query = NULL;
|
||||
|
|
@ -1000,7 +1001,7 @@ static void nsapi_dns_query_async_send(void *ptr)
|
|||
{
|
||||
dns_mutex->lock();
|
||||
|
||||
int unique_id = reinterpret_cast<int>(ptr);
|
||||
intptr_t unique_id = reinterpret_cast<intptr_t>(ptr);
|
||||
|
||||
DNS_QUERY *query = NULL;
|
||||
|
||||
|
|
@ -1162,7 +1163,7 @@ static void nsapi_dns_query_async_response(void *ptr)
|
|||
{
|
||||
dns_mutex->lock();
|
||||
|
||||
int unique_id = reinterpret_cast<int>(ptr);
|
||||
intptr_t unique_id = reinterpret_cast<intptr_t>(ptr);
|
||||
|
||||
DNS_QUERY *query = NULL;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue