Changeset 7797


Ignore:
Timestamp:
Jan 25, 2009, 4:14:11 PM (12 years ago)
Author:
charles
Message:

(trunk libT) new macro, tr_assert(). use it to help smoke out #1749

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/completion.c

    r7796 r7797  
    327327    const tr_block_index_t lastBlock = file->length ? ( ( file->offset + file->length - 1 ) / tor->blockSize ) : firstBlock;
    328328
    329     assert( tr_torBlockPiece( tor, firstBlock ) == file->firstPiece );
    330     assert( tr_torBlockPiece( tor, lastBlock ) == file->lastPiece );
     329    tr_assert( tr_torBlockPiece( tor, firstBlock ) == file->firstPiece,
     330               "file->offset %"PRIu64"; file->length %"PRIu64"; "
     331               "pieceSize %"PRIu32"; blockSize %"PRIu32"; "
     332               "firstBlock %"PRIu64"; lastBlock %"PRIu64,
     333               file->offset, file->length,
     334               tor->info.pieceSize, tor->blockSize,
     335               firstBlock, lastBlock );
     336
     337    tr_assert( tr_torBlockPiece( tor, lastBlock ) == file->lastPiece,
     338               "file->offset %"PRIu64"; file->length %"PRIu64"; "
     339               "pieceSize %"PRIu32"; blockSize %"PRIu32"; "
     340               "firstBlock %"PRIu64"; lastBlock %"PRIu64,
     341               file->offset, file->length,
     342               tor->info.pieceSize, tor->blockSize,
     343               firstBlock, lastBlock );
    331344
    332345    for( block=firstBlock; block<=lastBlock; ++block )
  • trunk/libtransmission/utils.c

    r7748 r7797  
    3737#include "utils.h"
    3838#include "platform.h"
     39#include "version.h"
    3940
    4041static tr_lock *      messageLock = NULL;
     
    192193
    193194char*
    194 tr_getLogTimeStr( char * buf,
    195                   int    buflen )
     195tr_getLogTimeStr( char * buf, int buflen )
    196196{
    197197    char           tmp[64];
     
    211211    return buf;
    212212}
     213
     214void
     215tr_assertImpl( const char * file, int line, const char * test, const char * fmt, ... )
     216{
     217    char buf[64];
     218    fprintf( stderr, "[%s] Transmission %s Assertion \"%s\" failed at %s:%d.  ",
     219                     tr_getLogTimeStr( buf, sizeof( buf ) ),
     220                      LONG_VERSION_STRING, test, file, line );
     221    if( fmt && *fmt ) {
     222        va_list args;
     223        fputc( '(', stderr );
     224        va_start( args, fmt );
     225        vfprintf( stderr, fmt, args );
     226        va_end( args );
     227        fputs( ")  ", stderr );
     228    }
     229    fputs( "Please report this bug at <http://trac.transmissionbt.com/newticket>; Thank you.\n", stderr );
     230    abort( );
     231}
     232
    213233
    214234tr_bool
  • trunk/libtransmission/utils.h

    r7748 r7797  
    104104****/
    105105
     106void tr_assertImpl( const char * file, int line, const char * test, const char * fmt, ... ) TR_GNUC_PRINTF( 4, 5 );
     107
     108#ifdef NDEBUG
     109 #define tr_assert( test, fmt, ... )
     110#else
     111 #define tr_assert( test, fmt, ... ) \
     112    do { if( ! ( test ) ) tr_assertImpl( __FILE__, __LINE__, #test, fmt, __VA_ARGS__ ); } while( 0 )
     113#endif
     114       
    106115int            tr_msgLoggingIsActive( int level );
    107116
Note: See TracChangeset for help on using the changeset viewer.