Ignore:
Timestamp:
Jul 17, 2011, 2:32:51 PM (10 years ago)
Author:
jordan
Message:

(trunk libT) fix minor compiler warning when compiling with assertions disabled

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/rpc-server.c

    r12545 r12552  
    925925{
    926926    tr_rpc_server * s;
    927     bool found;
    928927    bool boolVal;
    929928    int64_t i;
    930     const char *str;
     929    const char * str;
     930    const char * key;
    931931    tr_address address;
    932932
     
    934934    s->session = session;
    935935
    936     found = tr_bencDictFindBool( settings, TR_PREFS_KEY_RPC_ENABLED, &boolVal );
    937     assert( found );
    938     s->isEnabled = boolVal;
    939 
    940     found = tr_bencDictFindInt( settings, TR_PREFS_KEY_RPC_PORT, &i );
    941     assert( found );
    942     s->port = i;
    943 
    944     found = tr_bencDictFindStr( settings, TR_PREFS_KEY_RPC_URL, &str );
    945     assert( found );
    946     s->url = tr_strdup( str );
    947 
    948     found = tr_bencDictFindBool( settings, TR_PREFS_KEY_RPC_WHITELIST_ENABLED, &boolVal );
    949     assert( found );
    950     tr_rpcSetWhitelistEnabled( s, boolVal );
    951 
    952     found = tr_bencDictFindBool( settings, TR_PREFS_KEY_RPC_AUTH_REQUIRED, &boolVal );
    953     assert( found );
    954     tr_rpcSetPasswordEnabled( s, boolVal );
    955 
    956     found = tr_bencDictFindStr( settings, TR_PREFS_KEY_RPC_WHITELIST, &str );
    957     assert( found );
    958     tr_rpcSetWhitelist( s, str ? str : "127.0.0.1" );
    959 
    960     found = tr_bencDictFindStr( settings, TR_PREFS_KEY_RPC_USERNAME, &str );
    961     assert( found );
    962     tr_rpcSetUsername( s, str );
    963 
    964     found = tr_bencDictFindStr( settings, TR_PREFS_KEY_RPC_PASSWORD, &str );
    965     assert( found );
    966     tr_rpcSetPassword( s, str );
    967 
    968     found = tr_bencDictFindStr( settings, TR_PREFS_KEY_RPC_BIND_ADDRESS, &str );
    969     assert( found );
    970     if( !tr_address_from_string( &address, str ) ) {
    971         tr_err( _( "%s is not a valid address" ), str );
     936    key = TR_PREFS_KEY_RPC_ENABLED;
     937    if( !tr_bencDictFindBool( settings, key, &boolVal ) )
     938        tr_nerr( MY_NAME, _( "Couldn't find settings key \"%s\"" ), key );
     939    else
     940        s->isEnabled = boolVal;
     941
     942    key = TR_PREFS_KEY_RPC_PORT;
     943    if( !tr_bencDictFindInt( settings, key, &i ) )
     944        tr_nerr( MY_NAME, _( "Couldn't find settings key \"%s\"" ), key );
     945    else
     946        s->port = i;
     947
     948    key = TR_PREFS_KEY_RPC_URL;
     949    if( !tr_bencDictFindStr( settings, TR_PREFS_KEY_RPC_URL, &str ) )
     950        tr_nerr( MY_NAME, _( "Couldn't find settings key \"%s\"" ), key );
     951    else
     952        s->url = tr_strdup( str );
     953
     954    key = TR_PREFS_KEY_RPC_WHITELIST_ENABLED;
     955    if( !tr_bencDictFindBool( settings, key, &boolVal ) )
     956        tr_nerr( MY_NAME, _( "Couldn't find settings key \"%s\"" ), key );
     957    else
     958        tr_rpcSetWhitelistEnabled( s, boolVal );
     959
     960    key = TR_PREFS_KEY_RPC_AUTH_REQUIRED;
     961    if( !tr_bencDictFindBool( settings, key, &boolVal ) )
     962        tr_nerr( MY_NAME, _( "Couldn't find settings key \"%s\"" ), key );
     963    else
     964        tr_rpcSetPasswordEnabled( s, boolVal );
     965
     966    key = TR_PREFS_KEY_RPC_WHITELIST;
     967    if( !tr_bencDictFindStr( settings, key, &str ) && str )
     968        tr_nerr( MY_NAME, _( "Couldn't find settings key \"%s\"" ), key );
     969    else
     970        tr_rpcSetWhitelist( s, str );
     971
     972    key = TR_PREFS_KEY_RPC_USERNAME;
     973    if( !tr_bencDictFindStr( settings, key, &str ) )
     974        tr_nerr( MY_NAME, _( "Couldn't find settings key \"%s\"" ), key );
     975    else
     976        tr_rpcSetUsername( s, str );
     977
     978    key = TR_PREFS_KEY_RPC_PASSWORD;
     979    if( !tr_bencDictFindStr( settings, key, &str ) )
     980        tr_nerr( MY_NAME, _( "Couldn't find settings key \"%s\"" ), key );
     981    else
     982        tr_rpcSetPassword( s, str );
     983
     984    key = TR_PREFS_KEY_RPC_BIND_ADDRESS;
     985    if( !tr_bencDictFindStr( settings, TR_PREFS_KEY_RPC_BIND_ADDRESS, &str ) ) {
     986        tr_nerr( MY_NAME, _( "Couldn't find settings key \"%s\"" ), key );
     987        address = tr_inaddr_any;
     988    } else if( !tr_address_from_string( &address, str ) ) {
     989        tr_nerr( MY_NAME, _( "%s is not a valid address" ), str );
    972990        address = tr_inaddr_any;
    973991    } else if( address.type != TR_AF_INET ) {
    974         tr_err( _( "%s is not an IPv4 address. RPC listeners must be IPv4" ),
    975                    str );
     992        tr_nerr( MY_NAME, _( "%s is not an IPv4 address. RPC listeners must be IPv4" ), str );
    976993        address = tr_inaddr_any;
    977994    }
Note: See TracChangeset for help on using the changeset viewer.