aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/netxray.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-08-25 03:18:48 +0000
committerGuy Harris <guy@alum.mit.edu>2001-08-25 03:18:48 +0000
commit606d363a9b76a9d9b86c9e3c3fc02ba8f813919a (patch)
tree9ca4eed5d5acdec6fb7ef0d977332ffde57d710c /wiretap/netxray.c
parent837e848329ac0b9ce00438a914d13f9910cc90f3 (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/netxray.c')
-rw-r--r--wiretap/netxray.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/wiretap/netxray.c b/wiretap/netxray.c
index df6e1cf2f5..f6fa286364 100644
--- a/wiretap/netxray.c
+++ b/wiretap/netxray.c
@@ -1,6 +1,6 @@
/* netxray.c
*
- * $Id: netxray.c,v 1.39 2001/05/09 04:42:27 guy Exp $
+ * $Id: netxray.c,v 1.40 2001/08/25 03:18:48 guy Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@@ -383,7 +383,7 @@ static gboolean netxray_dump_1_1(wtap_dumper *wdh, const struct wtap_pkthdr *phd
netxray_dump_t *netxray = wdh->dump.netxray;
guint32 timestamp;
struct netxrayrec_1_x_hdr rec_hdr;
- int nwritten;
+ size_t nwritten;
/* NetXRay/Windows Sniffer files have a capture start date/time
in the header, in a UNIX-style format, with one-second resolution,
@@ -411,7 +411,7 @@ static gboolean netxray_dump_1_1(wtap_dumper *wdh, const struct wtap_pkthdr *phd
nwritten = fwrite(&rec_hdr, 1, sizeof(rec_hdr), wdh->fh);
if (nwritten != sizeof(rec_hdr)) {
- if (nwritten < 0)
+ if (nwritten == 0 && ferror(wdh->fh))
*err = errno;
else
*err = WTAP_ERR_SHORT_WRITE;
@@ -421,7 +421,7 @@ static gboolean netxray_dump_1_1(wtap_dumper *wdh, const struct wtap_pkthdr *phd
/* write the packet data */
nwritten = fwrite(pd, 1, phdr->caplen, wdh->fh);
if (nwritten != phdr->caplen) {
- if (nwritten < 0)
+ if (nwritten == 0 && ferror(wdh->fh))
*err = errno;
else
*err = WTAP_ERR_SHORT_WRITE;
@@ -441,7 +441,7 @@ static gboolean netxray_dump_close_1_1(wtap_dumper *wdh, int *err)
netxray_dump_t *netxray = wdh->dump.netxray;
guint32 filelen;
struct netxray_hdr file_hdr;
- int nwritten;
+ size_t nwritten;
filelen = ftell(wdh->fh);
@@ -451,7 +451,7 @@ static gboolean netxray_dump_close_1_1(wtap_dumper *wdh, int *err)
/* Rewrite the file header. */
nwritten = fwrite(netxray_magic, 1, sizeof netxray_magic, wdh->fh);
if (nwritten != sizeof netxray_magic) {
- if (nwritten < 0)
+ if (nwritten == 0 && ferror(wdh->fh))
*err = errno;
else
*err = WTAP_ERR_SHORT_WRITE;
@@ -473,7 +473,7 @@ static gboolean netxray_dump_close_1_1(wtap_dumper *wdh, int *err)
memcpy(hdr_buf, &file_hdr, sizeof(file_hdr));
nwritten = fwrite(hdr_buf, 1, sizeof hdr_buf, wdh->fh);
if (nwritten != sizeof hdr_buf) {
- if (nwritten < 0)
+ if (nwritten == 0 && ferror(wdh->fh))
*err = errno;
else
*err = WTAP_ERR_SHORT_WRITE;