Ignore:
Timestamp:
Aug 5, 2009, 1:59:16 AM (13 years ago)
Author:
charles
Message:

(trunk) clean up the return value of tr_torrentParse()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r8869 r8871  
    671671}
    672672
    673 int
    674 tr_torrentParse( const tr_ctor     * ctor,
    675                  tr_info           * setmeInfo )
    676 {
    677     int             err = 0;
     673tr_parse_result
     674tr_torrentParse( const tr_ctor * ctor, tr_info * setmeInfo )
     675{
    678676    int             doFree;
     677    tr_bool         didParse;
     678    tr_parse_result result;
    679679    tr_info         tmp;
    680680    const tr_benc * metainfo;
     
    685685    memset( setmeInfo, 0, sizeof( tr_info ) );
    686686
    687     if( !err && tr_ctorGetMetainfo( ctor, &metainfo ) )
    688         return TR_EINVALID;
    689 
    690     err = tr_metainfoParse( session, setmeInfo, metainfo );
    691     doFree = !err && ( setmeInfo == &tmp );
    692 
    693     if( !err && !getBlockSize( setmeInfo->pieceSize ) )
    694         err = TR_EINVALID;
    695 
    696     if( !err && session && tr_torrentExists( session, setmeInfo->hash ) )
    697         err = TR_EDUPLICATE;
     687    if( tr_ctorGetMetainfo( ctor, &metainfo ) )
     688        return TR_PARSE_ERR;
     689
     690    didParse = tr_metainfoParse( session, setmeInfo, metainfo );
     691    doFree = didParse && ( setmeInfo == &tmp );
     692
     693    if( didParse && !getBlockSize( setmeInfo->pieceSize ) )
     694        result = TR_PARSE_ERR;
     695
     696    if( didParse && session && tr_torrentExists( session, setmeInfo->hash ) )
     697        result = TR_PARSE_DUPLICATE;
    698698
    699699    if( doFree )
    700700        tr_metainfoFree( setmeInfo );
    701701
    702     return err;
     702    return result;
    703703}
    704704
     
    19611961        /* try to parse it back again, to make sure it's good */
    19621962        memset( &tmpInfo, 0, sizeof( tr_info ) );
    1963         if( !tr_metainfoParse( tor->session, &tmpInfo, &metainfo ) )
     1963        if( tr_metainfoParse( tor->session, &tmpInfo, &metainfo ) )
    19641964        {
    19651965            /* it's good, so keep these new trackers and free the old ones */
Note: See TracChangeset for help on using the changeset viewer.