Changeset 7423


Ignore:
Timestamp:
Dec 16, 2008, 11:31:05 PM (12 years ago)
Author:
charles
Message:

(trunk libT) more runtime safety checks

File:
1 edited

Legend:

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

    r7422 r7423  
    13371337}
    13381338
     1339static int
     1340tr_isPex( const tr_pex * pex )
     1341{
     1342    return pex && tr_isAddress( &pex->addr );
     1343}
     1344
    13391345void
    13401346tr_peerMgrAddPex( tr_peerMgr *    manager,
     
    13441350{
    13451351    Torrent * t;
    1346 
    13471352    managerLock( manager );
     1353
     1354    assert( tr_isPex( pex ) );
    13481355
    13491356    t = getExistingTorrent( manager, torrentHash );
     
    14641471    const tr_pex * a = va;
    14651472    const tr_pex * b = vb;
    1466     int i = tr_compareAddresses( &a->addr, &b->addr );
    1467 
    1468     if( i ) return i;
    1469     if( a->port < b->port ) return -1;
    1470     if( a->port > b->port ) return 1;
     1473    int i;
     1474
     1475    assert( tr_isPex( a ) );
     1476    assert( tr_isPex( b ) );
     1477
     1478    if(( i = tr_compareAddresses( &a->addr, &b->addr )))
     1479        return i;
     1480
     1481    if( a->port != b->port )
     1482        return a->port < b->port ? -1 : 1;
     1483
    14711484    return 0;
    14721485}
     
    15301543        }
    15311544
    1532 #warning this for loop can be removed when we're sure the bug is fixed
     1545#warning this for loop can be removed when we are sure the bug is fixed
    15331546        for( i=0; i<peersReturning; ++i )
    15341547            assert( tr_isAddress( &pex[i].addr ) );
     
    15371550        qsort( pex, peersReturning, sizeof( tr_pex ), tr_pexCompare );
    15381551
    1539 #warning this for loop can be removed when we're sure the bug is fixed
     1552#warning this for loop can be removed when we are sure the bug is fixed
    15401553        for( i=0; i<peersReturning; ++i )
    15411554            assert( tr_isAddress( &pex[i].addr ) );
Note: See TracChangeset for help on using the changeset viewer.