1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 09:13:06 +00:00

remove TR_NTOHL macro

This commit is contained in:
Charles Kerr 2007-07-19 10:37:30 +00:00
parent 6dd7c2fac2
commit 6d21f2fb16
3 changed files with 12 additions and 13 deletions

View file

@ -87,7 +87,6 @@ int vasprintf( char **, const char *, va_list );
/* Convenient macros to perform uint32_t endian conversions with /* Convenient macros to perform uint32_t endian conversions with
char pointers */ char pointers */
#define TR_NTOHL(p,a) (a) = tr_ntohl((p))
#define TR_HTONL(a,p) tr_htonl((a), ( uint8_t * )(p)) #define TR_HTONL(a,p) tr_htonl((a), ( uint8_t * )(p))
static inline uint32_t tr_ntohl( uint8_t * p ) static inline uint32_t tr_ntohl( uint8_t * p )
{ {

View file

@ -284,7 +284,7 @@ parseAZMessageHeader( tr_peer_t * peer, uint8_t * buf, int len,
return TR_NET_BLOCK; return TR_NET_BLOCK;
} }
/* message length */ /* message length */
TR_NTOHL( buf, msglen ); msglen = tr_ntohl( buf );
msglen += 4; msglen += 4;
off = 4; off = 4;
if( msglen > len ) if( msglen > len )
@ -297,7 +297,7 @@ parseAZMessageHeader( tr_peer_t * peer, uint8_t * buf, int len,
return TR_NET_CLOSE; return TR_NET_CLOSE;
} }
/* name length */ /* name length */
TR_NTOHL( buf + off, namelen ); namelen = tr_ntohl( buf + off );
off += 4; off += 4;
if( off + namelen + 1 > msglen ) if( off + namelen + 1 > msglen )
{ {

View file

@ -113,7 +113,7 @@ static int parseHave( tr_torrent_t * tor, tr_peer_t * peer,
return TR_ERROR_ASSERT; return TR_ERROR_ASSERT;
} }
TR_NTOHL( p, piece ); piece = tr_ntohl( p );
if( ( uint32_t )inf->pieceCount <= piece ) if( ( uint32_t )inf->pieceCount <= piece )
{ {
peer_dbg( "GET have, invalid piece" ); peer_dbg( "GET have, invalid piece" );
@ -214,9 +214,9 @@ static int parseRequest( tr_torrent_t * tor, tr_peer_t * peer,
return TR_OK; return TR_OK;
} }
TR_NTOHL( p, index ); index = tr_ntohl( p );
TR_NTOHL( &p[4], begin ); begin = tr_ntohl( &p[4] );
TR_NTOHL( &p[8], length ); length = tr_ntohl( &p[8] );
if( inf->pieceCount <= index ) if( inf->pieceCount <= index )
{ {
@ -293,8 +293,8 @@ static int parsePiece( tr_torrent_t * tor, tr_peer_t * peer,
return TR_ERROR_ASSERT; return TR_ERROR_ASSERT;
} }
TR_NTOHL( p, index ); index = tr_ntohl( p );
TR_NTOHL( &p[4], begin ); begin = tr_ntohl( &p[4] );
if( inf->pieceCount <= index ) if( inf->pieceCount <= index )
{ {
@ -396,9 +396,9 @@ static int parseCancel( tr_torrent_t * tor, tr_peer_t * peer,
return TR_ERROR_ASSERT; return TR_ERROR_ASSERT;
} }
TR_NTOHL( p, index ); index = tr_ntohl( p );
TR_NTOHL( &p[4], begin ); begin = tr_ntohl( &p[4] );
TR_NTOHL( &p[8], length ); length = tr_ntohl( &p[8] );
if( inf->pieceCount <= index ) if( inf->pieceCount <= index )
{ {
@ -453,7 +453,7 @@ parseMessageHeader( tr_peer_t * peer, uint8_t * buf, int buflen,
} }
/* Get payload size */ /* Get payload size */
TR_NTOHL( buf, *msglen ); *msglen = tr_ntohl( buf );
if( 4 + *msglen > buflen ) if( 4 + *msglen > buflen )
{ {