Skip to content

Commit cb70927

Browse files
authored
NetifSlirp: Fix compiler warnings and errors (#562)
* NetifSlirp: Fix compiler warnings and errors Built on latest gcc, clang, and msvc for x86. * Apply suggestions from code review
1 parent dcd0df7 commit cb70927

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

source/portable/NetworkInterface/libslirp/MBuffNetifBackendLibslirp.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
/* libc */
2929
#include <stdlib.h>
30+
#include <sys/types.h>
3031

3132
/* QEMU Slirp Library */
3233
#include <libslirp.h>
@@ -50,11 +51,11 @@
5051
#include "FreeRTOS_IP.h"
5152

5253
#ifndef IF_MTU_DEFAULT
53-
#define IF_MTU_DEFAULT 1500
54+
#define IF_MTU_DEFAULT 1500U
5455
#endif
5556

5657
#ifndef IF_MRU_DEFAULT
57-
#define IF_MRU_DEFAULT 1500
58+
#define IF_MRU_DEFAULT 1500U
5859
#endif
5960

6061
#define NETWORK_BUFFER_LEN ( ipconfigNETWORK_MTU + ipSIZE_OF_ETH_HEADER )
@@ -77,6 +78,10 @@
7778
#define THREAD_FUNC_DEF
7879
#endif /* if defined( _WIN32 ) */
7980

81+
#if !defined( slirp_ssize_t ) && defined( SSIZE_MAX )
82+
typedef ssize_t slirp_ssize_t;
83+
#endif
84+
8085
typedef struct
8186
{
8287
/* "Hardware" buffers */
@@ -588,10 +593,10 @@ static int lSlirpGetREventsCallback( int lIdx,
588593
configASSERT( pxCtx );
589594

590595
configASSERT( lIdx >= 0 );
591-
configASSERT( lIdx < pxCtx->nfds );
592-
configASSERT( lIdx < pxCtx->xPollFdArraySize );
593596

594597
xIndex = ( nfds_t ) lIdx;
598+
configASSERT( xIndex < pxCtx->nfds );
599+
configASSERT( xIndex < pxCtx->xPollFdArraySize );
595600

596601
rEvents = ( pxCtx->pxPollFdArray[ xIndex ].revents );
597602

0 commit comments

Comments
 (0)