Skip to content

Commit 9a50c10

Browse files
aescolarhenrikbrixandersen
authored andcommitted
drivers/wifi/winc1500: Fix build warnings with 64bit targets
Fix a set of warnings like: drivers/wifi/winc1500/wifi_winc1500.c:332:25: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast] 332 | SOCKET socket = (int)context->offload_context; when int and void* do not have the same size, by casting the content of context->offload_context to intptr_t which is whichever integer size matches the pointer size. Signed-off-by: Alberto Escolar Piedras <[email protected]>
1 parent 4a8a035 commit 9a50c10

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

drivers/wifi/winc1500/wifi_winc1500.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -329,16 +329,15 @@ static int winc1500_bind(struct net_context *context,
329329
const struct sockaddr *addr,
330330
socklen_t addrlen)
331331
{
332-
SOCKET socket = (int)context->offload_context;
332+
SOCKET socket = (intptr_t)context->offload_context;
333333
int ret;
334334

335335
/* FIXME atmel winc1500 don't support bind on null port */
336336
if (net_sin(addr)->sin_port == 0U) {
337337
return 0;
338338
}
339339

340-
ret = bind((int)context->offload_context, (struct sockaddr *)addr,
341-
addrlen);
340+
ret = bind((intptr_t)context->offload_context, (struct sockaddr *)addr, addrlen);
342341
if (ret) {
343342
LOG_ERR("bind error %d %s!",
344343
ret, socket_message_to_string(ret));
@@ -360,10 +359,10 @@ static int winc1500_bind(struct net_context *context,
360359
*/
361360
static int winc1500_listen(struct net_context *context, int backlog)
362361
{
363-
SOCKET socket = (int)context->offload_context;
362+
SOCKET socket = (intptr_t)context->offload_context;
364363
int ret;
365364

366-
ret = listen((int)context->offload_context, backlog);
365+
ret = listen((intptr_t)context->offload_context, backlog);
367366
if (ret) {
368367
LOG_ERR("listen error %d %s!",
369368
ret, socket_error_string(ret));
@@ -389,7 +388,7 @@ static int winc1500_connect(struct net_context *context,
389388
int32_t timeout,
390389
void *user_data)
391390
{
392-
SOCKET socket = (int)context->offload_context;
391+
SOCKET socket = (intptr_t)context->offload_context;
393392
int ret;
394393

395394
w1500_data.socket_data[socket].connect_cb = cb;
@@ -420,7 +419,7 @@ static int winc1500_accept(struct net_context *context,
420419
int32_t timeout,
421420
void *user_data)
422421
{
423-
SOCKET socket = (int)context->offload_context;
422+
SOCKET socket = (intptr_t)context->offload_context;
424423
int ret;
425424

426425
w1500_data.socket_data[socket].accept_cb = cb;
@@ -452,7 +451,7 @@ static int winc1500_send(struct net_pkt *pkt,
452451
void *user_data)
453452
{
454453
struct net_context *context = pkt->context;
455-
SOCKET socket = (int)context->offload_context;
454+
SOCKET socket = (intptr_t)context->offload_context;
456455
int ret = 0;
457456
struct net_buf *buf;
458457

@@ -492,7 +491,7 @@ static int winc1500_sendto(struct net_pkt *pkt,
492491
void *user_data)
493492
{
494493
struct net_context *context = pkt->context;
495-
SOCKET socket = (int)context->offload_context;
494+
SOCKET socket = (intptr_t)context->offload_context;
496495
int ret = 0;
497496
struct net_buf *buf;
498497

@@ -556,7 +555,7 @@ static int winc1500_recv(struct net_context *context,
556555
int32_t timeout,
557556
void *user_data)
558557
{
559-
SOCKET socket = (int) context->offload_context;
558+
SOCKET socket = (intptr_t)context->offload_context;
560559
int ret;
561560

562561
w1500_data.socket_data[socket].recv_cb = cb;
@@ -588,7 +587,7 @@ static int winc1500_recv(struct net_context *context,
588587
*/
589588
static int winc1500_put(struct net_context *context)
590589
{
591-
SOCKET sock = (int) context->offload_context;
590+
SOCKET sock = (intptr_t)context->offload_context;
592591
struct socket_data *sd = &w1500_data.socket_data[sock];
593592
int ret;
594593

@@ -899,10 +898,9 @@ static void handle_socket_msg_accept(struct socket_data *sd, void *pvMsg)
899898
* context as well. The new context gives us another socket
900899
* so we have to close that one first.
901900
*/
902-
winc1500_close((int)a_sd->context->offload_context);
901+
winc1500_close((intptr_t)a_sd->context->offload_context);
903902

904-
a_sd->context->offload_context =
905-
(void *)((int)accept_msg->sock);
903+
a_sd->context->offload_context = (void *)((intptr_t)accept_msg->sock);
906904
/** The iface is reset when getting a new context. */
907905
a_sd->context->iface = sd->context->iface;
908906

0 commit comments

Comments
 (0)