diff options
author | Guy Harris <guy@alum.mit.edu> | 2001-08-25 03:18:48 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2001-08-25 03:18:48 +0000 |
commit | 606d363a9b76a9d9b86c9e3c3fc02ba8f813919a (patch) | |
tree | 9ca4eed5d5acdec6fb7ef0d977332ffde57d710c /wiretap/snoop.c | |
parent | 837e848329ac0b9ce00438a914d13f9910cc90f3 (diff) |
The return value from "fwrite()" is a "size_t"; make the variable into
which we store it a "size_t", and then fix up the bugs that were
revealed by the compiler warnings that produced - "fwrite()" returns 0,
not a negative number, on an I/O error.
Fix up some other items to have type "size_t", or to have various
unsigned types, while we're at it, to squelch compiler warnings.
svn path=/trunk/; revision=3867
Diffstat (limited to 'wiretap/snoop.c')
-rw-r--r-- | wiretap/snoop.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/wiretap/snoop.c b/wiretap/snoop.c index b46273d347..fd7d2f338d 100644 --- a/wiretap/snoop.c +++ b/wiretap/snoop.c @@ -1,6 +1,6 @@ /* snoop.c * - * $Id: snoop.c,v 1.35 2001/08/25 02:56:31 guy Exp $ + * $Id: snoop.c,v 1.36 2001/08/25 03:18:48 guy Exp $ * * Wiretap Library * Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org> @@ -521,7 +521,7 @@ int snoop_dump_can_write_encap(int filetype, int encap) gboolean snoop_dump_open(wtap_dumper *wdh, int *err) { struct snoop_hdr file_hdr; - int nwritten; + size_t nwritten; /* This is a snoop file */ wdh->subtype_write = snoop_dump; @@ -530,7 +530,7 @@ gboolean snoop_dump_open(wtap_dumper *wdh, int *err) /* Write the file header. */ nwritten = fwrite(&snoop_magic, 1, sizeof snoop_magic, wdh->fh); if (nwritten != sizeof snoop_magic) { - if (nwritten < 0) + if (nwritten == 0 && ferror(wdh->fh)) *err = errno; else *err = WTAP_ERR_SHORT_WRITE; @@ -542,7 +542,7 @@ gboolean snoop_dump_open(wtap_dumper *wdh, int *err) file_hdr.network = htonl(wtap_encap[wdh->encap]); nwritten = fwrite(&file_hdr, 1, sizeof file_hdr, wdh->fh); if (nwritten != sizeof file_hdr) { - if (nwritten < 0) + if (nwritten == 0 && ferror(wdh->fh)) *err = errno; else *err = WTAP_ERR_SHORT_WRITE; |