Changeset 6489


Ignore:
Timestamp:
Aug 11, 2008, 7:05:00 PM (13 years ago)
Author:
charles
Message:

(1.3x) lots of C correctness tweaks suggested by sparse/cgcc

Location:
branches/1.3x
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • branches/1.3x/cli/cli.c

    r6408 r6489  
    6666static void sigHandler       ( int signal );
    6767
    68 char*
     68static char*
    6969tr_strlratio( char * buf, double ratio, size_t buflen )
    7070{
     
    438438}
    439439
    440 const struct tr_option options[] = {
     440static const struct tr_option options[] = {
    441441    { 'a', "announce", "Set the new torrent's announce URL", "a", 1, "<url>" },
    442442    { 'b', "blocklist", "Enable peer blocklists", "b", 0, NULL },
  • branches/1.3x/daemon/daemon.c

    r6409 r6489  
    232232}
    233233
    234 const struct tr_option options[] = {
     234static const struct tr_option options[] = {
    235235    { 'a', "acl",       "Access Control List.  (Default: "TR_DEFAULT_RPC_ACL")", "a", 1, "<list>" },
    236236    { 'b', "blocklist", "Enable peer blocklists",             "b", 0, NULL },
  • branches/1.3x/daemon/remote.c

    r6482 r6489  
    683683                        char sizestr[64];
    684684                        double percent = (double)have / length;
     685                        const char * pristr;
    685686                        strlsize( sizestr, length, sizeof( sizestr ) );
    686                         const char * pristr;
    687687                        switch( priority ) {
    688688                            case TR_PRI_LOW:    pristr = "Low"; break;
  • branches/1.3x/gtk/actions.c

    r6358 r6489  
    1515#include <gtk/gtk.h>
    1616#include <libtransmission/transmission.h>
     17#include "actions.h"
    1718#include "conf.h"
    1819#include "tr-core.h"
     
    2324#define UNUSED G_GNUC_UNUSED
    2425
    25 extern void doAction (const char * action_name, gpointer user_data );
    26 
    27 static TrCore * myCore = 0;
    28 
    29 static GtkActionGroup * myGroup = 0;
     26static TrCore * myCore = NULL;
     27
     28static GtkActionGroup * myGroup = NULL;
    3029
    3130static void
     
    141140BuiltinIconInfo;
    142141
    143 const BuiltinIconInfo my_fallback_icons [] =
     142static const BuiltinIconInfo my_fallback_icons [] =
    144143{
    145144    { tr_icon_logo, "transmission" },
     
    166165            GtkIconSet * icon_set;
    167166
    168             p = gdk_pixbuf_new_from_inline( -1, my_fallback_icons[i].raw, FALSE, 0 );
     167            p = gdk_pixbuf_new_from_inline( -1, my_fallback_icons[i].raw, FALSE, NULL );
    169168            width = gdk_pixbuf_get_width( p );
    170169            icon_set = gtk_icon_set_new_from_pixbuf( p );
  • branches/1.3x/gtk/actions.h

    r5122 r6489  
    2929GtkWidget* action_get_widget ( const char * path );
    3030
     31void doAction( const char * action_name, gpointer user_data );
     32
    3133#endif
  • branches/1.3x/gtk/details.c

    r6402 r6489  
    11661166};
    11671167
    1168 GtkWidget*
     1168static GtkWidget*
    11691169tracker_page_new( TrTorrent * gtor )
    11701170{
  • branches/1.3x/gtk/main.c

    r6413 r6489  
    411411    if( didlock && ( didinit || cf_init( configDir, &err ) ) )
    412412    {
     413        GtkWindow * win;
     414
    413415        tr_handle * h = tr_sessionInitFull(
    414416                            configDir,
     
    445447
    446448        /* create main window now to be a parent to any error dialogs */
    447         GtkWindow * win = GTK_WINDOW( tr_window_new( myUIManager, cbdata->core ) );
     449        win = GTK_WINDOW( tr_window_new( myUIManager, cbdata->core ) );
    448450        g_signal_connect( win, "window-state-event", G_CALLBACK(windowStateChanged), cbdata );
    449451        g_signal_connect( win, "size-allocate", G_CALLBACK(onMainWindowSizeAllocated), cbdata );
     
    10481050}
    10491051
    1050 gboolean
     1052static gboolean
    10511053updatemodel( gpointer gdata )
    10521054{
  • branches/1.3x/gtk/tr-core.c

    r6344 r6489  
    10401040    gboolean allowHibernation;
    10411041    tr_handle * session = tr_core_handle( core );
     1042    tr_torrent * tor = NULL;
    10421043
    10431044    /* allow hibernation unless we have active torrents */
    10441045    allowHibernation = TRUE;
    1045     tr_torrent * tor = NULL;
    10461046    while(( tor = tr_torrentNext( session, tor ))) {
    10471047        if( tr_torrentGetStatus( tor ) != TR_STATUS_STOPPED ) {
  • branches/1.3x/gtk/tr-prefs.c

    r6369 r6489  
    271271testing_port_cb( GtkWidget * unused UNUSED, gpointer l )
    272272{
     273    struct test_port_data * data;
     274
    273275    gtk_label_set_markup( GTK_LABEL( l ), _( "<i>Testing port...</i>" ) );
     276
    274277    /* wait three seconds to give the port forwarding time to kick in */
    275     struct test_port_data * data = g_new0( struct test_port_data, 1 );
     278    data = g_new0( struct test_port_data, 1 );
    276279    data->label = l;
    277280    data->alive = g_object_get_data( G_OBJECT( l ), "alive" );
     
    419422    if( ok && !data->abortFlag )
    420423    {
     424        char * cmd;
    421425        filename2 = g_strdup_printf( "%s.txt", filename );
    422426        g_snprintf( data->secondary, sizeof( data->secondary ),
    423427                    _( "Uncompressing blocklist..." ) );
    424428        g_idle_add( blocklistDialogSetSecondary, data );
    425         char * cmd = g_strdup_printf( "zcat %s > %s ", filename, filename2 );
     429        cmd = g_strdup_printf( "zcat %s > %s ", filename, filename2 );
    426430        tr_dbg( "%s", cmd );
    427431        system( cmd );
  • branches/1.3x/gtk/tr-torrent.c

    r6344 r6489  
    228228tr_torrent_status_str ( TrTorrent * gtor )
    229229{
    230     char * top = 0;
     230    char * top = NULL;
    231231
    232232    const tr_stat * st = tr_torrent_stat( gtor );
  • branches/1.3x/gtk/tr-window.c

    r6358 r6489  
    102102#define FILTER_TOGGLES_KEY "tr-filter-toggles"
    103103
    104 PrivateData*
     104static PrivateData*
    105105get_private_data( TrWindow * w )
    106106{
     
    225225{
    226226    PrivateData * p = vprivate;
    227     gtk_menu_popup( GTK_MENU( p->status_menu ), 0, 0, 0, 0, 0, gtk_get_current_event_time( ) );
     227    gtk_menu_popup( GTK_MENU( p->status_menu ), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time( ) );
    228228}
    229229
     
    402402{
    403403    if ( icon_pos == SEXY_ICON_ENTRY_PRIMARY )
    404         gtk_menu_popup ( GTK_MENU( menu ), 0, 0, 0, 0, 0, gtk_get_current_event_time( ) );
     404        gtk_menu_popup ( GTK_MENU( menu ), NULL, NULL, NULL, NULL, 0, gtk_get_current_event_time( ) );
    405405}
    406406
  • branches/1.3x/gtk/ui.h

    r6118 r6489  
    1 const char * fallback_ui_file =
     1static const char * fallback_ui_file =
    22"<ui>\n"
    33"  <menubar name='main-window-menu'>\n"
  • branches/1.3x/libtransmission/bencode-test.c

    r6483 r6489  
    88#define VERBOSE 0
    99
    10 int test = 0;
     10static int test = 0;
    1111
    1212#define check(A) { \
  • branches/1.3x/libtransmission/bencode.c

    r6483 r6489  
    318318              const uint8_t ** setme_end )
    319319{
     320    int err;
    320321    tr_ptrArray * parentStack = tr_ptrArrayNew( );
     322
    321323    top->type = 0; /* not initialized yet */
    322     const int err = tr_bencParseImpl( buf, end, top, parentStack, setme_end );
     324    err = tr_bencParseImpl( buf, end, top, parentStack, setme_end );
    323325    if( err )
    324326        tr_bencFree( top );
     327
    325328    tr_ptrArrayFree( parentStack, NULL );
    326329    return err;
  • branches/1.3x/libtransmission/blocklist.c

    r6323 r6489  
    8181    }
    8282
    83     b->rules = mmap( 0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0 );
     83    b->rules = mmap( NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0 );
    8484    if( !b->rules ) {
    8585        tr_err( err_fmt, b->filename, tr_strerror(errno) );
  • branches/1.3x/libtransmission/clients.c

    r6395 r6489  
    2121
    2222#include "transmission.h"
     23#include "clients.h"
    2324#include "utils.h"
    2425
  • branches/1.3x/libtransmission/fdlimit.c

    r6425 r6489  
    4848
    4949#include "transmission.h"
     50#include "fdlimit.h"
    5051#include "list.h"
    5152#include "net.h"
  • branches/1.3x/libtransmission/handshake.c

    r6425 r6489  
    970970}
    971971
    972 void
     972static void
    973973tr_handshakeDone( tr_handshake * handshake, int isOK )
    974974{
  • branches/1.3x/libtransmission/json-test.c

    r5843 r6489  
    77#define VERBOSE 0
    88
    9 int test = 0;
     9static int test = 0;
    1010
    1111#define check(A) { \
  • branches/1.3x/libtransmission/json.c

    r6334 r6489  
    2222#include "transmission.h"
    2323#include "bencode.h"
     24#include "json.h"
    2425#include "ptrarray.h"
    2526#include "utils.h"
  • branches/1.3x/libtransmission/makemeta.c

    r6485 r6489  
    383383            tr_bencDictAddStr( &top, "comment", builder->comment );
    384384        tr_bencDictAddStr( &top, "created by", TR_NAME "/" LONG_VERSION_STRING );
    385         tr_bencDictAddInt( &top, "creation date", time(0) );
     385        tr_bencDictAddInt( &top, "creation date", time(NULL) );
    386386        tr_bencDictAddStr( &top, "encoding", "UTF-8" );
    387387        makeInfoDict( tr_bencDictAddDict( &top, "info", 666 ), builder );
  • branches/1.3x/libtransmission/peer-msgs.c

    r6469 r6489  
    19751975}
    19761976
    1977 tr_publisher_tag
    1978 tr_peerMsgsSubscribe( tr_peermsgs       * peer,
    1979                       tr_delivery_func    func,
    1980                       void              * userData )
    1981 {
    1982     return tr_publisherSubscribe( peer->publisher, func, userData );
    1983 }
    1984 
    19851977void
    19861978tr_peerMsgsUnsubscribe( tr_peermsgs       * peer,
  • branches/1.3x/libtransmission/ptrarray.c

    r6425 r6489  
    183183**/
    184184
    185 int
     185static int
    186186tr_ptrArrayLowerBound( const tr_ptrArray * t,
    187187                       const void        * ptr,
  • branches/1.3x/libtransmission/rpc-test.c

    r6376 r6489  
    88#define VERBOSE 0
    99
    10 int test = 0;
     10static int test = 0;
    1111
    1212#define check(A) { \
  • branches/1.3x/libtransmission/rpc.c

    r6425 r6489  
    643643typedef const char* (handler)( tr_handle*, tr_benc*, tr_benc* );
    644644
    645 struct method {
     645static struct method {
    646646    const char * name;
    647647    handler * func;
  • branches/1.3x/libtransmission/stats.c

    r6425 r6489  
    1616#include "bencode.h"
    1717#include "platform.h" /* tr_sessionGetConfigDir() */
     18#include "stats.h"
    1819#include "utils.h" /* tr_buildPath */
    1920
     
    170171{
    171172    const struct tr_stats_handle * stats = getStats( handle );
     173    tr_session_stats current;
    172174    assert( stats );
    173     tr_session_stats current;
    174175    tr_sessionGetStats( handle, &current );
    175176    addStats( setme, &stats->old, &current );
  • branches/1.3x/libtransmission/tracker.c

    r6421 r6489  
    155155***/
    156156
    157 tr_tracker *
     157static tr_tracker *
    158158findTracker( tr_session * session, const uint8_t * hash )
    159159{
     
    323323    {
    324324        tr_benc benc;
    325         const int bencLoaded = !tr_bencLoad( response, responseLen, &benc, 0 );
     325        const int bencLoaded = !tr_bencLoad( response, responseLen,
     326                                             &benc, NULL );
    326327        publishErrorClear( t );
    327328        if( bencLoaded && tr_bencIsDict( &benc ) )
     
    467468    {
    468469        tr_benc benc, *files;
    469         const int bencLoaded = !tr_bencLoad( response, responseLen, &benc, 0 );
     470        const int bencLoaded = !tr_bencLoad( response, responseLen,
     471                                             &benc, NULL );
    470472        if( bencLoaded && tr_bencDictFindDict( &benc, "files", &files ) )
    471473        {
  • branches/1.3x/libtransmission/transmission.h

    r6329 r6489  
    433433int           tr_sessionGetProxyPort         ( const tr_session * );
    434434tr_proxy_type tr_sessionGetProxyType         ( const tr_session * );
     435const char*   tr_sessionGetProxyUsername     ( const tr_session * );
    435436const char*   tr_sessionGetProxyPassword     ( const tr_session * );
    436437void          tr_sessionSetProxyEnabled      ( tr_session *, int isEnabled );
  • branches/1.3x/libtransmission/utils-test.c

    r6140 r6489  
    1515#endif
    1616
    17 int test = 0;
     17static int test = 0;
    1818
    1919#define check(A) { \
Note: See TracChangeset for help on using the changeset viewer.