Changeset 6699


Ignore:
Timestamp:
Sep 4, 2008, 2:42:32 PM (13 years ago)
Author:
charles
Message:

(libT) change benc's integral type from int to size_t, squashing a couple of minor warnings

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr-prefs.c

    r6698 r6699  
    12741274                              gtk_label_new (_("Peers")) );
    12751275    gtk_notebook_append_page( GTK_NOTEBOOK( n ),
     1276                              networkPage( core ),
     1277                              gtk_label_new (_("Network")) );
     1278    gtk_notebook_append_page( GTK_NOTEBOOK( n ),
    12761279                              trackerPage( core ),
    12771280                              gtk_label_new (_("Trackers")) );
     
    12801283                              gtk_label_new (_("Bandwidth")) );
    12811284    gtk_notebook_append_page( GTK_NOTEBOOK( n ),
    1282                               networkPage( core ),
    1283                               gtk_label_new (_("Network")) );
    1284     gtk_notebook_append_page( GTK_NOTEBOOK( n ),
    12851285                              webPage( core ),
    12861286                              gtk_label_new (_("Web")) );
  • trunk/libtransmission/bencode.c

    r6625 r6699  
    154154
    155155static int
    156 makeroom( tr_benc * val, int count )
     156makeroom( tr_benc * val, size_t count )
    157157{
    158158    assert( TYPE_LIST == val->type || TYPE_DICT == val->type );
     
    332332int
    333333tr_bencLoad( const void  * buf_in,
    334              int           buflen,
     334             size_t        buflen,
    335335             tr_benc     * setme_benc,
    336336             char       ** setme_end )
     
    353353    if( tr_bencIsDict( val ) )
    354354    {
    355         int i;
    356         const int len = strlen( key );
     355        size_t i;
     356        const size_t len = strlen( key );
    357357
    358358        for( i=0; (i+1)<val->val.l.count; i+=2 )
     
    384384}
    385385
    386 int
     386size_t
    387387tr_bencListSize( const tr_benc * list )
    388388{
     
    391391
    392392tr_benc*
    393 tr_bencListChild( tr_benc * val, int i )
     393tr_bencListChild( tr_benc * val, size_t i )
    394394{
    395395    tr_benc * ret = NULL;
    396     if( tr_bencIsList( val ) && ( i >= 0 ) && ( i < val->val.l.count ) )
     396    if( tr_bencIsList( val ) && ( i < val->val.l.count ) )
    397397        ret = val->val.l.vals + i;
    398398    return ret;
     
    525525
    526526int
    527 tr_bencInitList( tr_benc * val, int reserveCount )
     527tr_bencInitList( tr_benc * val, size_t reserveCount )
    528528{
    529529    tr_bencInit( val, TYPE_LIST );
     
    532532
    533533int
    534 tr_bencListReserve( tr_benc * val, int count )
     534tr_bencListReserve( tr_benc * val, size_t count )
    535535{
    536536    assert( tr_bencIsList( val ) );
     
    539539
    540540int
    541 tr_bencInitDict( tr_benc * val, int reserveCount )
     541tr_bencInitDict( tr_benc * val, size_t reserveCount )
    542542{
    543543    tr_bencInit( val, TYPE_DICT );
     
    546546
    547547int
    548 tr_bencDictReserve( tr_benc * val, int count )
     548tr_bencDictReserve( tr_benc * val, size_t reserveCount )
    549549{
    550550    assert( tr_bencIsDict( val ) );
    551     return makeroom( val, count * 2 );
     551    return makeroom( val, reserveCount * 2 );
    552552}
    553553
     
    585585}
    586586tr_benc*
    587 tr_bencListAddList( tr_benc * list, int reserveCount )
     587tr_bencListAddList( tr_benc * list, size_t reserveCount )
    588588{
    589589    tr_benc * child = tr_bencListAdd( list );
     
    592592}
    593593tr_benc*
    594 tr_bencListAddDict( tr_benc * list, int reserveCount )
     594tr_bencListAddDict( tr_benc * list, size_t reserveCount )
    595595{
    596596    tr_benc * child = tr_bencListAdd( list );
     
    639639}
    640640tr_benc*
    641 tr_bencDictAddList( tr_benc * dict, const char * key, int reserveCount )
     641tr_bencDictAddList( tr_benc * dict, const char * key, size_t reserveCount )
    642642{
    643643    tr_benc * child = tr_bencDictAdd( dict, key );
     
    646646}
    647647tr_benc*
    648 tr_bencDictAddDict( tr_benc * dict, const char * key, int reserveCount )
     648tr_bencDictAddDict( tr_benc * dict, const char * key, size_t reserveCount )
    649649{
    650650    tr_benc * child = tr_bencDictAdd( dict, key );
     
    882882{
    883883    struct evbuffer * evbuf = vevbuf;
    884     evbuffer_add_printf( evbuf, "%d:", val->val.s.i );
     884    evbuffer_add_printf( evbuf, "%lu:", (unsigned long)val->val.s.i );
    885885    evbuffer_add( evbuf, val->val.s.s, val->val.s.i );
    886886}
     
    11681168jsonListBeginFunc( const tr_benc * val, void * vdata )
    11691169{
    1170     const int nChildren = tr_bencListSize( val );
     1170    const size_t nChildren = tr_bencListSize( val );
    11711171    struct jsonWalk * data = vdata;
    11721172    jsonPushParent( data, val );
  • trunk/libtransmission/bencode.h

    r6615 r6699  
    3232        struct
    3333        {
    34             int    i;
     34            size_t i;
    3535            char * s;
    3636        } s;
    3737        struct
    3838        {
    39             int alloc;
    40             int count;
     39            size_t alloc;
     40            size_t count;
    4141            struct tr_benc * vals;
    4242        } l;
     
    5454
    5555int tr_bencLoad( const void  * buf,
    56                  int           buflen,
     56                 size_t        buflen,
    5757                 tr_benc     * setme_benc,
    5858                 char       ** setme_end );
     
    7575void  tr_bencInitRaw( tr_benc *, const void * raw, size_t raw_len );
    7676void  tr_bencInitInt( tr_benc *, int64_t num );
    77 int   tr_bencInitDict( tr_benc *, int reserveCount );
    78 int   tr_bencInitList( tr_benc *, int reserveCount );
     77int   tr_bencInitDict( tr_benc *, size_t reserveCount );
     78int   tr_bencInitList( tr_benc *, size_t reserveCount );
    7979
    8080/***
     
    8282***/
    8383
    84 int tr_bencListReserve( tr_benc *, int count );
     84int tr_bencListReserve( tr_benc *, size_t reserveCount );
    8585tr_benc * tr_bencListAdd( tr_benc * );
    8686tr_benc * tr_bencListAddInt( tr_benc *, int64_t val );
    8787tr_benc * tr_bencListAddStr( tr_benc *, const char * val );
    88 tr_benc * tr_bencListAddList( tr_benc *, int reserveCount );
    89 tr_benc * tr_bencListAddDict( tr_benc *, int reserveCount );
     88tr_benc * tr_bencListAddList( tr_benc *, size_t reserveCount );
     89tr_benc * tr_bencListAddDict( tr_benc *, size_t reserveCount );
    9090
    91 int tr_bencListSize( const tr_benc * list );
    92 tr_benc * tr_bencListChild( tr_benc * list, int n );
     91size_t tr_bencListSize( const tr_benc * list );
     92tr_benc * tr_bencListChild( tr_benc * list, size_t n );
    9393
    9494/***
     
    9696***/
    9797
    98 int tr_bencDictReserve( tr_benc *, int count );
     98int tr_bencDictReserve( tr_benc *, size_t reserveCount );
    9999int tr_bencDictRemove( tr_benc *, const char * key );
    100100tr_benc * tr_bencDictAdd( tr_benc *, const char * key );
     
    102102tr_benc * tr_bencDictAddInt( tr_benc *, const char * key, int64_t val );
    103103tr_benc * tr_bencDictAddStr( tr_benc *, const char * key, const char * val );
    104 tr_benc * tr_bencDictAddList( tr_benc *, const char * key, int reserveCount );
    105 tr_benc * tr_bencDictAddDict( tr_benc *, const char * key, int reserveCount );
     104tr_benc * tr_bencDictAddList( tr_benc *, const char * key, size_t reserve );
     105tr_benc * tr_bencDictAddDict( tr_benc *, const char * key, size_t reserve );
    106106tr_benc * tr_bencDictAddRaw( tr_benc *, const char * key,
    107107                             const void *, size_t len );
  • trunk/libtransmission/ptrarray.c

    r6490 r6699  
    169169    assert( begin >= 0 );
    170170    if( end < 0 ) end = t->n_items;
    171     assert( end > begin );
     171    assert( end - begin > 0 );
    172172    assert( end <= t->n_items );
    173173
  • trunk/libtransmission/resume.c

    r6601 r6699  
    123123
    124124    if( tr_bencDictFindList( dict, KEY_DND, &list )
    125         && ( list->val.l.count == (int)n ) )
     125        && ( tr_bencListSize( list ) == n ) )
    126126    {
    127127        int64_t tmp;
     
    131131
    132132        for( i=0; i<n; ++i ) {
    133             if( tr_bencGetInt( &list->val.l.vals[i], &tmp ) && tmp )
     133            if( tr_bencGetInt( tr_bencListChild( list, i ), &tmp ) && tmp )
    134134                dnd[dndCount++] = i;
    135135            else
     
    152152    else
    153153    {
    154         tr_tordbg( tor, "Couldn't load DND flags.  dnd list (%p) has %d children; torrent has %d files",
    155                    list, ( list ? list->val.l.count : -1 ), (int)n );
     154        tr_tordbg( tor, "Couldn't load DND flags.  dnd list (%p) has %zu children; torrent has %d files",
     155                   list, tr_bencListSize( list ), (int)n );
    156156    }
    157157
     
    185185
    186186    if( tr_bencDictFindList( dict, KEY_PRIORITY, &list )
    187         && ( list->val.l.count == (int)n ) )
     187        && ( tr_bencListSize( list ) == n ) )
    188188    {
    189189        int64_t tmp;
    190190        tr_file_index_t i;
    191191        for( i=0; i<n; ++i )
    192             if( tr_bencGetInt( &list->val.l.vals[i], &tmp ) )
     192            if( tr_bencGetInt( tr_bencListChild( list, i ), &tmp ) )
    193193                inf->files[i].priority = tmp;
    194194        ret = TR_FR_PRIORITY;
     
    246246saveProgress( tr_benc * dict, const tr_torrent * tor )
    247247{
    248     int i;
    249     int n;
     248    size_t i, n;
    250249    time_t * mtimes;
    251250    tr_benc * p;
     
    285284        size_t rawlen;
    286285        tr_benc * m;
    287         int n;
     286        size_t n;
    288287        time_t * curMTimes = tr_torrentGetMTimes( tor, &n );
    289288
    290289        if( tr_bencDictFindList( p, KEY_PROGRESS_MTIMES, &m )
    291             && ( m->val.l.count == (int64_t)tor->info.fileCount )
    292             && ( m->val.l.count == n ) )
     290            && ( n == tor->info.fileCount )
     291            && ( n == tr_bencListSize( m ) ) )
    293292        {
    294             int i;
     293            size_t i;
    295294            for( i=0; i<n; ++i )
    296295            {
    297296                int64_t tmp;
    298                 if( !tr_bencGetInt( &m->val.l.vals[i], &tmp ) ) {
    299                     tr_tordbg( tor, "File #%d needs to be verified - couldn't find benc entry", i );
     297                if( !tr_bencGetInt( tr_bencListChild( m, i ), &tmp ) ) {
     298                    tr_tordbg( tor, "File #%zu needs to be verified - couldn't find benc entry", i );
    300299                    tr_torrentSetFileChecked( tor, i, FALSE );
    301300                } else {
     
    304303                        tr_torrentSetFileChecked( tor, i, TRUE );
    305304                    else {
    306                         tr_tordbg( tor, "File #%d needs to be verified - times %lu and %lu don't match", i, t, curMTimes[i] );
     305                        tr_tordbg( tor, "File #%zu needs to be verified - times %lu and %lu don't match", i, t, curMTimes[i] );
    307306                        tr_torrentSetFileChecked( tor, i, FALSE );
    308307                    }
  • trunk/libtransmission/torrent.c

    r6517 r6699  
    15351535
    15361536time_t*
    1537 tr_torrentGetMTimes( const tr_torrent * tor, int * setme_n )
    1538 {
    1539     int i;
    1540     const int n = tor->info.fileCount;
     1537tr_torrentGetMTimes( const tr_torrent * tor, size_t * setme_n )
     1538{
     1539    size_t i;
     1540    const size_t n = tor->info.fileCount;
    15411541    time_t * m = tr_new0( time_t, n );
    15421542
  • trunk/libtransmission/torrent.h

    r6016 r6699  
    106106int tr_torrentPromoteTracker       ( tr_torrent *, int trackerIndex );
    107107
    108 time_t* tr_torrentGetMTimes        ( const tr_torrent *, int * setmeCount );
     108time_t* tr_torrentGetMTimes        ( const tr_torrent *, size_t * setmeCount );
    109109
    110110typedef enum
  • trunk/libtransmission/tracker.c

    r6617 r6699  
    475475        if( bencLoaded && tr_bencDictFindDict( &benc, "files", &files ) )
    476476        {
    477             int i;
     477            size_t i;
    478478            for( i=0; i<files->val.l.count; i+=2 )
    479479            {
  • trunk/libtransmission/web.c

    r6696 r6699  
    7474            struct tr_web_task * task;
    7575            long response_code;
    76             curl_easy_getinfo( easy, CURLINFO_PRIVATE, &task );
     76            curl_easy_getinfo( easy, CURLINFO_PRIVATE, (void*)&task );
    7777            curl_easy_getinfo( easy, CURLINFO_RESPONSE_CODE, &response_code );
    7878            --web->remain;
Note: See TracChangeset for help on using the changeset viewer.