Convert a bunch of ints to size_t in ngsniffer.c, and make sure file_read

can accept size_t's.

svn path=/trunk/; revision=27684
This commit is contained in:
Gerald Combs 2009-03-09 22:28:05 +00:00
parent cc739fecb0
commit 40f5a17d46
2 changed files with 15 additions and 15 deletions

View File

@ -33,7 +33,7 @@ extern int file_error(void *fh);
extern FILE_T file_open(const char *path, const char *mode);
#define filed_open gzdopen
/* XX: gzread and gzwrite return number of *bytes* (not number of elements) */
#define file_read(buf, bsize, count, file) gzread((file),(buf),((count)*(bsize)))
#define file_read(buf, bsize, count, file) gzread((file),(buf),(unsigned)((count)*(bsize)))
#define file_write(buf, bsize, count, file) gzwrite((file),(buf),((count)*(bsize)))
#define file_close gzclose
#define file_getc gzgetc

View File

@ -494,9 +494,9 @@ static void ngsniffer_close(wtap *wth);
static gboolean ngsniffer_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
const union wtap_pseudo_header *pseudo_header, const guchar *pd, int *err);
static gboolean ngsniffer_dump_close(wtap_dumper *wdh, int *err);
static int SnifferDecompress( unsigned char * inbuf, size_t inlen,
static size_t SnifferDecompress( unsigned char * inbuf, size_t inlen,
unsigned char * outbuf, size_t outlen, int *err );
static int ng_file_read(void *buffer, size_t elementsize, size_t numelements,
static size_t ng_file_read(void *buffer, size_t elementsize, size_t numelements,
wtap *wth, gboolean is_random, int *err);
static int read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream,
int *err);
@ -1287,7 +1287,7 @@ static gboolean ngsniffer_seek_read(wtap *wth, gint64 seek_off,
static int ngsniffer_read_rec_header(wtap *wth, gboolean is_random,
guint16 *typep, guint16 *lengthp, int *err)
{
int bytes_read;
size_t bytes_read;
char record_type[2];
char record_length[4]; /* only 1st 2 bytes are length */
@ -1319,7 +1319,7 @@ static int ngsniffer_read_rec_header(wtap *wth, gboolean is_random,
static gboolean ngsniffer_read_frame2(wtap *wth, gboolean is_random,
struct frame2_rec *frame2, int *err)
{
int bytes_read;
size_t bytes_read;
/* Read the f_frame2_struct */
bytes_read = ng_file_read(frame2, 1, sizeof *frame2, wth, is_random,
@ -1427,7 +1427,7 @@ static void set_pseudo_header_frame2(wtap *wth,
static gboolean ngsniffer_read_frame4(wtap *wth, gboolean is_random,
struct frame4_rec *frame4, int *err)
{
int bytes_read;
size_t bytes_read;
/* Read the f_frame4_struct */
bytes_read = ng_file_read(frame4, 1, sizeof *frame4, wth, is_random,
@ -1696,7 +1696,7 @@ static void set_pseudo_header_frame4(union wtap_pseudo_header *pseudo_header,
static gboolean ngsniffer_read_frame6(wtap *wth, gboolean is_random,
struct frame6_rec *frame6, int *err)
{
int bytes_read;
size_t bytes_read;
/* Read the f_frame6_struct */
bytes_read = ng_file_read(frame6, 1, sizeof *frame6, wth, is_random,
@ -1727,7 +1727,7 @@ static void set_pseudo_header_frame6(wtap *wth,
static gboolean ngsniffer_read_rec_data(wtap *wth, gboolean is_random,
guchar *pd, int length, int *err)
{
int bytes_read;
size_t bytes_read;
bytes_read = ng_file_read(pd, 1, length, wth, is_random, err);
@ -2205,7 +2205,7 @@ static gboolean ngsniffer_dump_close(wtap_dumper *wdh, int *err)
Return value is the number of bytes in outbuf on return.
*/
static int
static size_t
SnifferDecompress( unsigned char * inbuf, size_t inlen,
unsigned char * outbuf, size_t outlen, int *err )
{
@ -2397,18 +2397,18 @@ typedef struct {
gint64 blob_uncomp_offset;
} blob_info_t;
static int
static size_t
ng_file_read(void *buffer, size_t elementsize, size_t numelements, wtap *wth,
gboolean is_random, int *err)
{
FILE_T infile;
ngsniffer_comp_stream_t *comp_stream;
int copybytes = elementsize * numelements; /* bytes left to be copied */
int copied_bytes = 0; /* bytes already copied */
size_t copybytes = elementsize * numelements; /* bytes left to be copied */
size_t copied_bytes = 0; /* bytes already copied */
unsigned char *outbuffer = buffer; /* where to write next decompressed data */
blob_info_t *blob;
int bytes_to_copy;
int bytes_left;
size_t bytes_to_copy;
size_t bytes_left;
if (is_random) {
infile = wth->random_fh;
@ -2514,7 +2514,7 @@ read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, int *err)
gint16 blob_len_host;
gboolean uncompressed;
unsigned char file_inbuf[65536];
int out_len;
size_t out_len;
/* Read one 16-bit word which is length of next compressed blob */
errno = WTAP_ERR_CANT_READ;