(trunk) fix warnings found by the clang static analyzer, reported & patched by wereHamster

This commit is contained in:
Charles Kerr 2009-12-07 04:06:14 +00:00
parent 907c67ba78
commit 4e252aa106
7 changed files with 24 additions and 26 deletions

View File

@ -1174,11 +1174,8 @@ printDetails( tr_benc * top )
char buf[512];
char buf2[512];
int64_t i, j, k;
tr_bool isStopped;
tr_bool boolVal;
isStopped = tr_bencDictFindInt( t, "status", &i ) && (i==TR_STATUS_STOPPED);
printf( "NAME\n" );
if( tr_bencDictFindInt( t, "id", &i ) )
printf( " Id: %" PRId64 "\n", i );
@ -1876,14 +1873,13 @@ main( int argc,
if( host == NULL )
host = tr_strdup( DEFAULT_HOST );
exit_status |= readargs( argc, (const char**)argv );
if( reqCount )
exit_status = processRequests( host, port, (const char**)reqs, reqCount );
else {
readargs( argc, (const char**)argv );
if( reqCount == 0 ) {
showUsage( );
return EXIT_FAILURE;
}
exit_status = processRequests( host, port, (const char**)reqs, reqCount );
for( i=0; i<reqCount; ++i )
tr_free( reqs[i] );

View File

@ -1192,9 +1192,9 @@ refreshPeerList( struct DetailsImpl * di, tr_torrent ** torrents, int n )
int i;
int * peerCount;
GtkTreeIter iter;
GtkTreeModel * model;
GHashTable * hash = di->peer_hash;
GtkListStore * store = di->peer_store;
GtkTreeModel * model = GTK_TREE_MODEL( store );
struct tr_peer_stat ** peers;
/* step 1: get all the peers */

View File

@ -250,7 +250,7 @@ refreshActions( struct cbdata * data )
static void
refreshDetailsDialog( struct cbdata * data, GtkWidget * details )
{
GtkTreeSelection * s = tr_window_get_selection( data->wind );
GtkTreeSelection * s;
GtkTreeModel * model;
GSList * ids = NULL;
GList * selrows = NULL;

View File

@ -59,7 +59,7 @@ freeMetaUI( gpointer p )
static gboolean
onProgressDialogRefresh( gpointer data )
{
char * str;
char * str = NULL;
MakeMetaUI * ui = data;
const tr_metainfo_builder * b = ui->builder;
GtkDialog * d = GTK_DIALOG( ui->progress_dialog );
@ -80,8 +80,13 @@ onProgressDialogRefresh( gpointer data )
str = g_strdup_printf( _( "Error reading \"%s\": %s" ), b->errfile, g_strerror( b->my_errno ) );
else if( b->result == TR_MAKEMETA_IO_WRITE )
str = g_strdup_printf( _( "Error writing \"%s\": %s" ), b->errfile, g_strerror( b->my_errno ) );
gtk_label_set_text( GTK_LABEL( ui->progress_label ), str );
g_free( str );
else
g_assert_not_reached( );
if( str != NULL ) {
gtk_label_set_text( GTK_LABEL( ui->progress_label ), str );
g_free( str );
}
/* progress bar */
if( !b->pieceIndex )

View File

@ -955,23 +955,22 @@ tr_core_add_ctor( TrCore * core, tr_ctor * ctor )
gboolean
tr_core_add_metainfo( TrCore * core,
const char * payload,
gboolean * setme_success,
gboolean * setme_handled,
GError ** gerr UNUSED )
{
tr_session * session = tr_core_session( core );
if( !session )
{
*setme_success = FALSE;
*setme_handled = FALSE;
}
else if( gtr_is_supported_url( payload ) || gtr_is_magnet_link( payload ) )
{
tr_core_add_from_url( core, payload );
*setme_success = TRUE;
*setme_handled = TRUE;
}
else /* base64-encoded metainfo */
{
int err;
int file_length;
tr_ctor * ctor;
char * file_contents;
@ -981,14 +980,12 @@ tr_core_add_metainfo( TrCore * core,
tr_core_apply_defaults( ctor );
file_contents = tr_base64_decode( payload, -1, &file_length );
err = tr_ctorSetMetainfo( ctor, (const uint8_t*)file_contents, file_length );
if( !err )
err = add_ctor( core, ctor, do_prompt, TRUE );
tr_ctorSetMetainfo( ctor, (const uint8_t*)file_contents, file_length );
add_ctor( core, ctor, do_prompt, TRUE );
tr_free( file_contents );
tr_core_torrents_added( core );
*setme_success = TRUE;
*setme_handled = TRUE;
}
return TRUE;

View File

@ -880,7 +880,7 @@ tr_window_new( GtkUIManager * ui_mgr, TrCore * core )
gtk_container_add ( GTK_CONTAINER( self ), vbox );
/* main menu */
w = mainmenu = action_get_widget( "/main-window-menu" );
mainmenu = action_get_widget( "/main-window-menu" );
w = action_get_widget( "/main-window-menu/torrent-menu/update-tracker" );
#if GTK_CHECK_VERSION( 2, 12, 0 )
g_signal_connect( w, "query-tooltip",
@ -888,7 +888,7 @@ tr_window_new( GtkUIManager * ui_mgr, TrCore * core )
#endif
/* toolbar */
w = toolbar = p->toolbar = action_get_widget( "/main-window-toolbar" );
toolbar = p->toolbar = action_get_widget( "/main-window-toolbar" );
action_set_important( "add-torrent-toolbar", TRUE );
action_set_important( "show-torrent-properties", TRUE );

View File

@ -563,7 +563,7 @@ gboolean
gtr_dbus_add_torrent( const char * filename )
{
/* FIXME: why is this static? */
static gboolean success = FALSE;
static gboolean handled = FALSE;
#ifdef HAVE_DBUS_GLIB
char * payload;
@ -596,7 +596,7 @@ gtr_dbus_add_torrent( const char * filename )
dbus_g_proxy_call( proxy, "AddMetainfo", &err,
G_TYPE_STRING, payload,
G_TYPE_INVALID,
G_TYPE_BOOLEAN, &success,
G_TYPE_BOOLEAN, &handled,
G_TYPE_INVALID );
if( err )
g_message( "err: %s", err->message );
@ -612,7 +612,7 @@ gtr_dbus_add_torrent( const char * filename )
g_free( file_contents );
#endif
return success;
return handled;
}
gboolean