Ignore:
Timestamp:
Dec 21, 2008, 6:15:00 PM (13 years ago)
Author:
charles
Message:

(trunk libT) comments, tr_bool correctness, better runtime tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-io.c

    r7442 r7446  
    195195#define _isBool(b) (((b)==0 || (b)==1))
    196196
    197 static int
    198 isPeerIo( const tr_peerIo * io )
     197tr_bool
     198tr_isPeerIo( const tr_peerIo * io )
    199199{
    200200    return ( io != NULL )
     
    217217    const tr_direction dir = TR_DOWN;
    218218
    219     assert( isPeerIo( io ) );
     219    assert( tr_isPeerIo( io ) );
    220220
    221221    dbgmsg( io, "libevent says this peer is ready to read" );
     
    288288    const tr_direction dir = TR_UP;
    289289
    290     assert( isPeerIo( io ) );
     290    assert( tr_isPeerIo( io ) );
    291291
    292292    dbgmsg( io, "libevent says this peer is ready to write" );
     
    447447tr_peerIoGetSession( tr_peerIo * io )
    448448{
    449     assert( isPeerIo( io ) );
     449    assert( tr_isPeerIo( io ) );
    450450    assert( io->session );
    451451
     
    457457                           tr_port   * port )
    458458{
    459     assert( isPeerIo( io ) );
     459    assert( tr_isPeerIo( io ) );
    460460
    461461    if( port )
     
    538538                         const uint8_t * hash )
    539539{
    540     assert( isPeerIo( io ) );
     540    assert( tr_isPeerIo( io ) );
    541541
    542542    tr_cryptoSetTorrentHash( io->crypto, hash );
     
    546546tr_peerIoGetTorrentHash( tr_peerIo * io )
    547547{
    548     assert( isPeerIo( io ) );
     548    assert( tr_isPeerIo( io ) );
    549549    assert( io->crypto );
    550550
     
    555555tr_peerIoHasTorrentHash( const tr_peerIo * io )
    556556{
    557     assert( isPeerIo( io ) );
     557    assert( tr_isPeerIo( io ) );
    558558    assert( io->crypto );
    559559
     
    569569                     const uint8_t * peer_id )
    570570{
    571     assert( isPeerIo( io ) );
     571    assert( tr_isPeerIo( io ) );
    572572
    573573    if( ( io->peerIdIsSet = peer_id != NULL ) )
     
    580580tr_peerIoGetPeersId( const tr_peerIo * io )
    581581{
    582     assert( isPeerIo( io ) );
     582    assert( tr_isPeerIo( io ) );
    583583    assert( io->peerIdIsSet );
    584584
     
    594594                     tr_bool     flag )
    595595{
    596     assert( isPeerIo( io ) );
     596    assert( tr_isPeerIo( io ) );
    597597    assert( isFlag( flag ) );
    598598
     
    604604tr_peerIoSupportsFEXT( const tr_peerIo * io )
    605605{
    606     assert( isPeerIo( io ) );
     606    assert( tr_isPeerIo( io ) );
    607607
    608608    return io->fastExtensionSupported;
     
    617617                     tr_bool      flag )
    618618{
    619     assert( isPeerIo( io ) );
     619    assert( tr_isPeerIo( io ) );
    620620    assert( isFlag( flag ) );
    621621
     
    627627tr_peerIoSupportsLTEP( const tr_peerIo * io )
    628628{
    629     assert( isPeerIo( io ) );
     629    assert( tr_isPeerIo( io ) );
    630630
    631631    return io->extendedProtocolSupported;
     
    667667                       tr_bandwidth  * bandwidth )
    668668{
    669     assert( isPeerIo( io ) );
     669    assert( tr_isPeerIo( io ) );
    670670
    671671    if( io->bandwidth )
     
    692692                        int         encryptionMode )
    693693{
    694     assert( isPeerIo( io ) );
     694    assert( tr_isPeerIo( io ) );
    695695    assert( encryptionMode == PEER_ENCRYPTION_NONE
    696696          || encryptionMode == PEER_ENCRYPTION_RC4 );
     
    839839    uint16_t tmp;
    840840
     841    assert( tr_isPeerIo( io ) );
     842
    841843    tr_peerIoReadBytes( io, inbuf, &tmp, sizeof( uint16_t ) );
    842844    *setme = ntohs( tmp );
     
    850852    uint32_t tmp;
    851853
     854    assert( tr_isPeerIo( io ) );
     855
    852856    tr_peerIoReadBytes( io, inbuf, &tmp, sizeof( uint32_t ) );
    853857    *setme = ntohl( tmp );
     
    859863                size_t            byteCount )
    860864{
    861     uint8_t * tmp = tr_new( uint8_t, byteCount );
    862 
     865    uint8_t * tmp;
     866
     867    assert( tr_isPeerIo( io ) );
     868
     869    tmp = tr_new( uint8_t, byteCount );
    863870    tr_peerIoReadBytes( io, inbuf, tmp, byteCount );
    864871    tr_free( tmp );
     
    880887    int res;
    881888
    882     assert( isPeerIo( io ) );
     889    assert( tr_isPeerIo( io ) );
    883890
    884891    howmuch = tr_bandwidthClamp( io->bandwidth, TR_DOWN, howmuch );
     
    907914    int n;
    908915
    909     assert( isPeerIo( io ) );
     916    assert( tr_isPeerIo( io ) );
    910917
    911918    howmuch = tr_bandwidthClamp( io->bandwidth, TR_UP, howmuch );
     
    929936    int ret;
    930937
    931     assert( isPeerIo( io ) );
    932     assert( dir==TR_UP || dir==TR_DOWN );
     938    assert( tr_isPeerIo( io ) );
     939    assert( tr_isDirection( dir ) );
    933940
    934941    if( dir==TR_DOWN )
     
    943950tr_peerIoGetReadBuffer( tr_peerIo * io )
    944951{
    945     assert( isPeerIo( io ) );
     952    assert( tr_isPeerIo( io ) );
    946953
    947954    return io->inbuf;
     
    951958tr_peerIoHasBandwidthLeft( const tr_peerIo * io, tr_direction dir )
    952959{
    953     assert( isPeerIo( io ) );
    954     assert( dir==TR_UP || dir==TR_DOWN );
     960    assert( tr_isPeerIo( io ) );
     961    assert( tr_isDirection( dir ) );
    955962
    956963    return tr_bandwidthClamp( io->bandwidth, dir, 1024 ) > 0;
     
    964971event_enable( tr_peerIo * io, short event )
    965972{
    966     assert( isPeerIo( io ) );
     973    assert( tr_isPeerIo( io ) );
    967974
    968975    if( event & EV_READ )
     
    976983event_disable( struct tr_peerIo * io, short event )
    977984{
    978     assert( isPeerIo( io ) );
     985    assert( tr_isPeerIo( io ) );
    979986
    980987    if( event & EV_READ )
     
    991998                     tr_bool        isEnabled )
    992999{
    993     const short event = dir == TR_UP ? EV_WRITE : EV_READ;
     1000    short event;
     1001
     1002    assert( tr_isPeerIo( io ) );
     1003    assert( tr_isDirection( dir ) );
     1004
     1005    event = dir == TR_UP ? EV_WRITE : EV_READ;
    9941006
    9951007    if( isEnabled )
Note: See TracChangeset for help on using the changeset viewer.