(trunk libT) prefer `int' over `ssize_t'

This commit is contained in:
Charles Kerr 2009-01-19 14:05:43 +00:00
parent 69f59b423a
commit 4d228289ce
10 changed files with 34 additions and 40 deletions

View File

@ -43,7 +43,6 @@
#include <stdio.h>
#endif
#include <string.h> /* strlen() */
#include <unistd.h> /* ssize_t */
#include "ConvertUTF.h"
static const int halfShift = 10; /* used for shifting by 10 bits */
@ -351,7 +350,7 @@ Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) {
* In addition to knowing if the sequence is legal, it also tells you the last good character.
*/
Boolean
tr_utf8_validate( const char * str, ssize_t max_len, const char ** end )
tr_utf8_validate( const char * str, int max_len, const char ** end )
{
const UTF8* source = (const UTF8*) str;
const UTF8* sourceEnd = source;

View File

@ -5,8 +5,6 @@
#error only libtransmission should #include this header.
#endif
#include <unistd.h> /* ssize_t */
/*
* Copyright 2001-2004 Unicode, Inc.
*
@ -153,7 +151,7 @@ Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd);
/* intended to work the same as g_utf8_validate */
Boolean tr_utf8_validate( const char * str, ssize_t max_len, const char ** end );
Boolean tr_utf8_validate( const char * str, int max_len, const char ** end );
#ifdef __cplusplus

View File

@ -223,11 +223,11 @@ tr_bandwidthAllocate( tr_bandwidth * b,
while( n > 1 )
{
const size_t increment = 1024;
const ssize_t bytesUsed = tr_peerIoFlush( peers[i], dir, increment );
const int bytesUsed = tr_peerIoFlush( peers[i], dir, increment );
dbgmsg( "peer #%d of %d used %zd bytes in this pass", i, n, bytesUsed );
dbgmsg( "peer #%d of %d used %d bytes in this pass", i, n, bytesUsed );
if( bytesUsed == (ssize_t)increment )
if( bytesUsed == (int)increment )
++i;
else {
/* peer is done writing for now; move it to the end of the list */

View File

@ -236,23 +236,23 @@ event_read_cb( int fd, short event UNUSED, void * vio )
}
}
static ssize_t
static int
tr_evbuffer_write( tr_peerIo * io, int fd, size_t howmuch )
{
int e;
ssize_t n;
int n;
struct evbuffer * buffer = io->outbuf;
howmuch = MIN( EVBUFFER_LENGTH( buffer ), howmuch );
errno = 0;
#ifdef WIN32
n = send(fd, buffer->buffer, howmuch, 0 );
n = (int) send(fd, buffer->buffer, howmuch, 0 );
#else
n = write(fd, buffer->buffer, howmuch );
n = (int) write(fd, buffer->buffer, howmuch );
#endif
e = errno;
dbgmsg( io, "wrote %zd to peer (%s)", n, (n==-1?strerror(e):"") );
dbgmsg( io, "wrote %d to peer (%s)", n, (n==-1?strerror(e):"") );
if( n > 0 )
evbuffer_drain( buffer, n );
@ -762,10 +762,10 @@ tr_peerIoDrain( tr_peerIo * io,
****
***/
static ssize_t
static int
tr_peerIoTryRead( tr_peerIo * io, size_t howmuch )
{
ssize_t res = 0;
int res = 0;
if(( howmuch = tr_bandwidthClamp( &io->bandwidth, TR_DOWN, howmuch )))
{
@ -774,7 +774,7 @@ tr_peerIoTryRead( tr_peerIo * io, size_t howmuch )
res = evbuffer_read( io->inbuf, io->socket, howmuch );
e = errno;
dbgmsg( io, "read %zd from peer (%s)", res, (res==-1?strerror(e):"") );
dbgmsg( io, "read %d from peer (%s)", res, (res==-1?strerror(e):"") );
if( EVBUFFER_LENGTH( io->inbuf ) )
canReadWrapper( io );
@ -784,7 +784,7 @@ tr_peerIoTryRead( tr_peerIo * io, size_t howmuch )
short what = EVBUFFER_READ | EVBUFFER_ERROR;
if( res == 0 )
what |= EVBUFFER_EOF;
dbgmsg( io, "tr_peerIoTryRead got an error. res is %zd, what is %hd, errno is %d (%s)", res, what, e, strerror( e ) );
dbgmsg( io, "tr_peerIoTryRead got an error. res is %d, what is %hd, errno is %d (%s)", res, what, e, strerror( e ) );
io->gotError( io, what, io->userData );
}
}
@ -792,10 +792,10 @@ tr_peerIoTryRead( tr_peerIo * io, size_t howmuch )
return res;
}
static ssize_t
static int
tr_peerIoTryWrite( tr_peerIo * io, size_t howmuch )
{
ssize_t n = 0;
int n = 0;
if(( howmuch = tr_bandwidthClamp( &io->bandwidth, TR_UP, howmuch )))
{
@ -810,7 +810,7 @@ tr_peerIoTryWrite( tr_peerIo * io, size_t howmuch )
if( ( n < 0 ) && ( io->gotError ) && ( e != EPIPE ) && ( e != EAGAIN ) && ( e != EINTR ) && ( e != EINPROGRESS ) )
{
const short what = EVBUFFER_WRITE | EVBUFFER_ERROR;
dbgmsg( io, "tr_peerIoTryWrite got an error. res is %zd, what is %hd, errno is %d (%s)", n, what, e, strerror( e ) );
dbgmsg( io, "tr_peerIoTryWrite got an error. res is %d, what is %hd, errno is %d (%s)", n, what, e, strerror( e ) );
io->gotError( io, what, io->userData );
}
}
@ -818,10 +818,10 @@ tr_peerIoTryWrite( tr_peerIo * io, size_t howmuch )
return n;
}
ssize_t
int
tr_peerIoFlush( tr_peerIo * io, tr_direction dir, size_t limit )
{
ssize_t bytesUsed;
int bytesUsed;
assert( tr_isPeerIo( io ) );
assert( tr_isDirection( dir ) );
@ -834,7 +834,7 @@ tr_peerIoFlush( tr_peerIo * io, tr_direction dir, size_t limit )
bytesUsed = tr_peerIoTryWrite( io, limit );
}
dbgmsg( io, "flushing peer-io, direction %d, limit %zu, bytesUsed %zd", (int)dir, limit, bytesUsed );
dbgmsg( io, "flushing peer-io, direction %d, limit %zu, bytesUsed %d", (int)dir, limit, bytesUsed );
return bytesUsed;
}

View File

@ -76,7 +76,7 @@ typedef struct tr_peerIo
tr_port port;
int socket;
ssize_t refCount;
int refCount;
uint8_t peerId[SHA_DIGEST_LENGTH];
time_t timeCreated;
@ -360,7 +360,7 @@ void tr_peerIoSetEnabled( tr_peerIo * io,
tr_direction dir,
tr_bool isEnabled );
ssize_t tr_peerIoFlush( tr_peerIo * io,
int tr_peerIoFlush( tr_peerIo * io,
tr_direction dir,
size_t byteLimit );

View File

@ -980,7 +980,7 @@ request_exec( tr_session * session,
void
tr_rpc_request_exec_json( tr_session * session,
const void * request_json,
ssize_t request_len,
int request_len,
tr_rpc_response_func callback,
void * callback_user_data )
{
@ -1032,7 +1032,7 @@ addToken( tr_benc * list,
void
tr_rpc_parse_list_str( tr_benc * setme,
const char * str_in,
ssize_t len )
int len )
{
char * str = tr_strndup( str_in, len );
@ -1079,7 +1079,7 @@ tr_rpc_parse_list_str( tr_benc * setme,
void
tr_rpc_request_exec_uri( tr_session * session,
const void * request_uri,
ssize_t request_len,
int request_len,
tr_rpc_response_func callback,
void * callback_user_data )
{

View File

@ -13,8 +13,6 @@
#ifndef TR_RPC_H
#define TR_RPC_H
#include <unistd.h> /* ssize_t */
/***
**** RPC processing
***/
@ -28,20 +26,20 @@ typedef void( tr_rpc_response_func )( tr_session * session,
/* http://www.json.org/ */
void tr_rpc_request_exec_json( tr_session * session,
const void * request_json,
ssize_t request_len,
int request_len,
tr_rpc_response_func callback,
void * callback_user_data );
/* see the RPC spec's "Request URI Notation" section */
void tr_rpc_request_exec_uri( tr_session * session,
const void * request_uri,
ssize_t request_len,
int request_len,
tr_rpc_response_func callback,
void * callback_user_data );
void tr_rpc_parse_list_str( struct tr_benc * setme,
const char * list_str,
ssize_t list_str_len );
int list_str_len );
#endif

View File

@ -1,7 +1,6 @@
#include <stdio.h> /* fprintf */
#include <string.h> /* strcmp */
#include "transmission.h"
#include <unistd.h> /* ssize_t */
#include "ConvertUTF.h" /* tr_utf8_validate*/
#include "platform.h"
#include "utils.h"

View File

@ -637,7 +637,7 @@ tr_buildPath( const char *first_element, ... )
****/
char*
tr_strndup( const void * in, ssize_t len )
tr_strndup( const void * in, int len )
{
char * out = NULL;
@ -1325,7 +1325,7 @@ tr_lowerBound( const void * key,
***/
char*
tr_utf8clean( const char * str, ssize_t max_len, tr_bool * err )
tr_utf8clean( const char * str, int max_len, tr_bool * err )
{
const char zero = '\0';
char * ret;
@ -1336,11 +1336,11 @@ tr_utf8clean( const char * str, ssize_t max_len, tr_bool * err )
*err = FALSE;
if( max_len < 0 )
max_len = (ssize_t) strlen( str );
max_len = (int) strlen( str );
while( !tr_utf8_validate ( str, max_len, &end ) )
{
const ssize_t good_len = end - str;
const int good_len = end - str;
evbuffer_add( buf, str, good_len );
max_len -= ( good_len + 1 );

View File

@ -238,7 +238,7 @@ uint64_t tr_date( void );
void tr_wait( uint64_t delay_milliseconds );
char* tr_utf8clean( const char * str,
ssize_t max_len,
int max_len,
tr_bool * err );
@ -302,7 +302,7 @@ static TR_INLINE void* tr_memdup( const void * src, int byteCount )
( (struct_type *) realloc ( ( mem ), ( (size_t) sizeof ( struct_type ) ) * ( ( size_t) ( n_structs ) ) ) )
/** @param in is a void* so that callers can pass in both signed & unsigned without a cast */
char* tr_strndup( const void * in, ssize_t len ) TR_GNUC_MALLOC;
char* tr_strndup( const void * in, int len ) TR_GNUC_MALLOC;
/** @param in is a void* so that callers can pass in both signed & unsigned without a cast */
static TR_INLINE char* tr_strdup( const void * in )