(trunk libT) fix some code that the newly-added gcc warnings didn't like

This commit is contained in:
Charles Kerr
2009-01-23 18:44:15 +00:00
parent 0e072e7c25
commit 13c22f88ff
12 changed files with 147 additions and 82 deletions

View File

@@ -10,23 +10,31 @@
#include "json.h" #include "json.h"
#include "utils.h" /* tr_free */ #include "utils.h" /* tr_free */
#define VERBOSE 0 #undef VERBOSE
static int test = 0; static int test = 0;
#ifdef VERBOSE
#define check( A ) \ #define check( A ) \
{ \ { \
++test; \ ++test; \
if( A ){ \ if( A ){ \
if( VERBOSE ) \ fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__,\
__LINE__ );\
} else { \ } else { \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__,\ fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
__LINE__ ); \
return test; \ return test; \
} \ } \
} }
#else
#define check( A ) \
{ \
++test; \
if( !( A ) ){ \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
return test; \
} \
}
#endif
static int static int
testInt( void ) testInt( void )

View File

@@ -6,22 +6,29 @@
#include "net.h" #include "net.h"
#include "utils.h" #include "utils.h"
#define VERBOSE 0 #undef VERBOSE
#ifdef VERBOSE
#define check( A ) \ #define check( A ) \
{ \ { \
++test; \ ++test; \
if( A ){ \ if( A ){ \
if( VERBOSE ) \ fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__,\
__LINE__ );\
} else { \ } else { \
if( VERBOSE ) \ fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__,\
__LINE__ );\
return test; \ return test; \
} \ } \
} }
#else
#define check( A )\
{ \
++test; \
if( !( A ) ){ \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
return test; \
} \
}
#endif
static void static void
createTestBlocklist( const char * tmpfile ) createTestBlocklist( const char * tmpfile )
@@ -45,11 +52,11 @@ int
main( void ) main( void )
{ {
#ifndef WIN32 #ifndef WIN32
char * tmpfile_txt = "/tmp/transmission-blocklist-test.txt"; const char * tmpfile_txt = "/tmp/transmission-blocklist-test.txt";
char * tmpfile_bin = "/tmp/transmission-blocklist-test.bin"; const char * tmpfile_bin = "/tmp/transmission-blocklist-test.bin";
#else #else
char * tmpfile_txt = "transmission-blocklist-test.txt"; const char * tmpfile_txt = "transmission-blocklist-test.txt";
char * tmpfile_bin = "transmission-blocklist-test.bin"; const char * tmpfile_bin = "transmission-blocklist-test.bin";
#endif #endif
struct tr_address addr; struct tr_address addr;
int test = 0; int test = 0;

View File

@@ -4,22 +4,29 @@
#include "transmission.h" #include "transmission.h"
#include "clients.h" #include "clients.h"
#define VERBOSE 0 #undef VERBOSE
#ifdef VERBOSE
#define check( A ) \ #define check( A ) \
{ \ { \
++test; \ ++test; \
if( A ){ \ if( A ){ \
if( VERBOSE ) \ fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__,\
__LINE__ );\
} else { \ } else { \
if( VERBOSE ) \ fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__,\
__LINE__ );\
return test; \ return test; \
} \ } \
} }
#else
#define check( A ) \
{ \
++test; \
if( !( A ) ){ \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
return test; \
} \
}
#endif
#define TEST_CLIENT( A, B ) \ #define TEST_CLIENT( A, B ) \
tr_clientForId( buf, sizeof( buf ), A ); \ tr_clientForId( buf, sizeof( buf ), A ); \

View File

@@ -5,23 +5,31 @@
#include "json.h" #include "json.h"
#include "utils.h" /* tr_free */ #include "utils.h" /* tr_free */
#define VERBOSE 0 #undef VERBOSE
static int test = 0; static int test = 0;
#ifdef VERBOSE
#define check( A ) \ #define check( A ) \
{ \ { \
++test; \ ++test; \
if( A ){ \ if( A ){ \
if( VERBOSE ) \ fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__,\
__LINE__ );\
} else { \ } else { \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__,\ fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
__LINE__ ); \
return test; \ return test; \
} \ } \
} }
#else
#define check( A ) \
{ \
++test; \
if( !( A ) ){ \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
return test; \
} \
}
#endif
#include "ConvertUTF.h" #include "ConvertUTF.h"

View File

@@ -4,22 +4,29 @@
#include "peer-msgs.h" #include "peer-msgs.h"
#include "utils.h" #include "utils.h"
#define VERBOSE 0 #undef VERBOSE
#ifdef VERBOSE
#define check( A ) \ #define check( A ) \
{ \ { \
++test; \ ++test; \
if( A ){ \ if( A ){ \
if( VERBOSE ) \ fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__,\
__LINE__ );\
} else { \ } else { \
if( VERBOSE ) \ fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__,\
__LINE__ );\
return test; \ return test; \
} \ } \
} }
#else
#define check( A ) \
{ \
++test; \
if( !( A ) ){ \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
return test; \
} \
}
#endif
int int
main( void ) main( void )

View File

@@ -2,23 +2,31 @@
#include "transmission.h" #include "transmission.h"
#include "request-list.h" #include "request-list.h"
#define VERBOSE 0 #undef VERBOSE
static int test = 0; static int test = 0;
#ifdef VERBOSE
#define check( A ) \ #define check( A ) \
{ \ { \
++test; \ ++test; \
if( A ){ \ if( A ){ \
if( VERBOSE ) \ fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__,\
__LINE__ );\
} else { \ } else { \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__,\ fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
__LINE__ ); \
return test; \ return test; \
} \ } \
} }
#else
#define check( A ) \
{ \
++test; \
if( !( A ) ){ \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
return test; \
} \
}
#endif
static int static int
testFoo( void ) testFoo( void )

View File

@@ -5,24 +5,31 @@
#include "rpcimpl.h" #include "rpcimpl.h"
#include "utils.h" #include "utils.h"
#define VERBOSE 0 #undef VERBOSE
static int test = 0; static int test = 0;
#ifdef VERBOSE
#define check( A ) \ #define check( A ) \
{ \ { \
++test; \ ++test; \
if( A ){ \ if( A ){ \
if( VERBOSE ) \ fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__,\
__LINE__ );\
} else { \ } else { \
if( VERBOSE ) \ fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__,\
__LINE__ );\
return test; \ return test; \
} \ } \
} }
#else
#define check( A ) \
{ \
++test; \
if( !( A ) ){ \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
return test; \
} \
}
#endif
static int static int
test_list( void ) test_list( void )

View File

@@ -510,7 +510,7 @@ torrentGet( tr_session * session,
tr_torrent ** torrents = getTorrents( session, args_in, &torrentCount ); tr_torrent ** torrents = getTorrents( session, args_in, &torrentCount );
tr_benc * list = tr_bencDictAddList( args_out, "torrents", torrentCount ); tr_benc * list = tr_bencDictAddList( args_out, "torrents", torrentCount );
tr_benc * fields; tr_benc * fields;
char * msg = NULL; const char * msg = NULL;
assert( idle_data == NULL ); assert( idle_data == NULL );

View File

@@ -5,22 +5,29 @@
#include "session.h" #include "session.h"
#include "utils.h" #include "utils.h"
#define VERBOSE 0 #undef VERBOSE
#ifdef VERBOSE
#define check( A ) \ #define check( A ) \
{ \ { \
++test; \ ++test; \
if( A ){ \ if( A ){ \
if( VERBOSE ) \ fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__,\
__LINE__ );\
} else { \ } else { \
if( VERBOSE ) \ fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__,\
__LINE__ );\
return test; \ return test; \
} \ } \
} }
#else
#define check( A ) \
{ \
++test; \
if( !( A ) ){ \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
return test; \
} \
}
#endif
int int
main( void ) main( void )

View File

@@ -25,7 +25,7 @@ int tr_optind = 1;
static const char* static const char*
getArgName( const tr_option * opt ) getArgName( const tr_option * opt )
{ {
char * arg; const char * arg;
if( !opt->has_arg ) if( !opt->has_arg )
arg = ""; arg = "";

View File

@@ -30,11 +30,11 @@ extern int tr_optind;
typedef struct tr_option typedef struct tr_option
{ {
int val; /* the value to return from tr_getopt() */ int val; /* the value to return from tr_getopt() */
char * longName; /* --long-form */ const char * longName; /* --long-form */
char * description; /* option's description for tr_getopt_usage() */ const char * description; /* option's description for tr_getopt_usage() */
char * shortName; /* short form */ const char * shortName; /* short form */
int has_arg; /* 0 for no argument, 1 for argument */ int has_arg; /* 0 for no argument, 1 for argument */
char * argName; /* argument's description for tr_getopt_usage() */ const char * argName; /* argument's description for tr_getopt_usage() */
} }
tr_option; tr_option;

View File

@@ -6,32 +6,39 @@
#include "utils.h" #include "utils.h"
#include "crypto.h" #include "crypto.h"
#define VERBOSE 0 #undef VERBOSE
#define NUM_LOOPS 1 #define NUM_LOOPS 1
#define SPEED_TEST 0 #define SPEED_TEST 0
#if SPEED_TEST #if SPEED_TEST
#undef VERBOSE #define VERBOSE
#define VERBOSE 0
#undef NUM_LOOPS #undef NUM_LOOPS
#define NUM_LOOPS 200 #define NUM_LOOPS 200
#endif #endif
static int test = 0; static int test = 0;
#ifdef VERBOSE
#define check( A ) \ #define check( A ) \
{ \ { \
++test; \ ++test; \
if( A ){ \ if( A ){ \
if( VERBOSE ) \ fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
fprintf( stderr, "PASS test #%d (%s, %d)\n", test, __FILE__,\
__LINE__ );\
} else { \ } else { \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__,\ fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
__LINE__ ); \
return test; \ return test; \
} \ } \
} }
#else
#define check( A ) \
{ \
++test; \
if( !( A ) ){ \
fprintf( stderr, "FAIL test #%d (%s, %d)\n", test, __FILE__, __LINE__ ); \
return test; \
} \
}
#endif
static int static int
test_bitfields( void ) test_bitfields( void )
@@ -187,8 +194,7 @@ main( void )
int l; int l;
/* base64 */ /* base64 */
in = "YOYO!"; out = tr_base64_encode( "YOYO!", -1, &len );
out = tr_base64_encode( in, -1, &len );
check( out ); check( out );
check( !strcmp( out, "WU9ZTyE=\n" ) ); check( !strcmp( out, "WU9ZTyE=\n" ) );
check( len == 9 ); check( len == 9 );