No need for WTAP_ERR_CANT_READ.
authorGuy Harris <guy@alum.mit.edu>
Tue, 7 Oct 2014 23:18:47 +0000 (16:18 -0700)
committerGuy Harris <guy@alum.mit.edu>
Tue, 7 Oct 2014 23:19:56 +0000 (23:19 +0000)
Unlike the standard I/O routines, the code we introduced that supports
fast random seeking on gzipped files will always supply some specific
error code for read errors, so we don't need WTAP_ERR_CANT_READ.

Add WTAP_ERR_CANT_WRITE for writing, as we're still using the standard
I/O routines for that.  Set errno to WTAP_ERR_CANT_WRITE before calling
fwrite() in wtap_dump_file_write(), so that it's used if fwrite() fails
without setting errno.

Change-Id: I6bf066a6838284a532737aa65fd0c9bb3639ad63
Reviewed-on: https://code.wireshark.org/review/4540
Reviewed-by: Guy Harris <guy@alum.mit.edu>
30 files changed:
epan/wslua/wslua_file.c
file.c
rawshark.c
tshark.c
wiretap/5views.c
wiretap/aethra.c
wiretap/btsnoop.c
wiretap/eyesdn.c
wiretap/file_access.c
wiretap/i4btrace.c
wiretap/iptrace.c
wiretap/iseries.c
wiretap/lanalyzer.c
wiretap/libpcap.c
wiretap/mp2t.c
wiretap/mpeg.c
wiretap/netmon.c
wiretap/netscaler.c
wiretap/nettl.c
wiretap/network_instruments.c
wiretap/netxray.c
wiretap/ngsniffer.c
wiretap/pcap-common.c
wiretap/pcapng.c
wiretap/radcom.c
wiretap/snoop.c
wiretap/visual.c
wiretap/vwr.c
wiretap/wtap.c
wiretap/wtap.h

index 81347aaae007f6bb660de72da3cbeec1f997fe21..6e129c9aeaaf4972b8415caf71277a5b9d42ab2e 100644 (file)
@@ -1668,7 +1668,7 @@ wslua_filehandler_open(wtap *wth, int *err, gchar **err_info)
     fp = push_File(L, wth->fh);
     fc = push_CaptureInfo(L, wth, TRUE);
 
-    errno = WTAP_ERR_CANT_READ;
+    errno = WTAP_ERR_CANT_OPEN;
     switch ( lua_pcall(L,2,1,1) ) {
         case 0:
             retval = wslua_optboolint(L,-1,0);
@@ -1755,7 +1755,6 @@ wslua_filehandler_read(wtap *wth, int *err, gchar **err_info,
     fc = push_CaptureInfo(L, wth, FALSE);
     fi = push_FrameInfo(L, &wth->phdr, wth->frame_buffer);
 
-    errno = WTAP_ERR_CANT_READ;
     switch ( lua_pcall(L,3,1,1) ) {
         case 0:
             if (lua_isnumber(L,-1)) {
@@ -1804,7 +1803,6 @@ wslua_filehandler_seek_read(wtap *wth, gint64 seek_off,
     fi = push_FrameInfo(L, phdr, buf);
     lua_pushnumber(L, (lua_Number)seek_off);
 
-    *err = WTAP_ERR_CANT_READ;
     switch ( lua_pcall(L,4,1,1) ) {
         case 0:
             if (lua_isstring(L,-1)) {
@@ -1916,7 +1914,6 @@ wslua_filehandler_can_write_encap(int encap, void* data)
 
     lua_pushnumber(L, encap);
 
-    errno = WTAP_ERR_CANT_READ;
     switch ( lua_pcall(L,1,1,1) ) {
         case 0:
             retval = wslua_optboolint(L,-1,WTAP_ERR_UNSUPPORTED_ENCAP);
@@ -2027,7 +2024,7 @@ wslua_filehandler_dump(wtap_dumper *wdh, const struct wtap_pkthdr *phdr,
     fc = push_CaptureInfoConst(L,wdh);
     fi = push_FrameInfoConst(L, phdr, pd);
 
-    errno = WTAP_ERR_CANT_READ;
+    errno = WTAP_ERR_CANT_WRITE;
     switch ( lua_pcall(L,3,1,1) ) {
         case 0:
             retval = wslua_optboolint(L,-1,0);
@@ -2064,7 +2061,7 @@ wslua_filehandler_dump_close(wtap_dumper *wdh, int *err)
     fp = push_Wdh(L, wdh);
     fc = push_CaptureInfoConst(L,wdh);
 
-    errno = WTAP_ERR_CANT_READ;
+    errno = WTAP_ERR_CANT_CLOSE;
     switch ( lua_pcall(L,2,1,1) ) {
         case 0:
             retval = wslua_optboolint(L,-1,0);
diff --git a/file.c b/file.c
index e948a48a835dda5a963a1232df5621a90350cdfa..31d2b6a713d002751fc7f72396c168d4fdf7ad7b 100644 (file)
--- a/file.c
+++ b/file.c
@@ -748,12 +748,6 @@ cf_read(capture_file *cf, gboolean reloading)
       g_free(err_info);
       break;
 
-    case WTAP_ERR_CANT_READ:
-      simple_error_message_box(
-                 "An attempt to read from the capture file failed for"
-                 " some unknown reason.");
-      break;
-
     case WTAP_ERR_SHORT_READ:
       simple_error_message_box(
                  "The capture file appears to have been cut short"
@@ -1533,12 +1527,6 @@ cf_merge_files(char **out_filenamep, int in_file_count,
           g_free(err_info);
           break;
 
-        case WTAP_ERR_CANT_READ:
-          simple_error_message_box(
-                     "An attempt to read from the capture file %s failed for"
-                     " some unknown reason.", display_basename);
-          break;
-
         case WTAP_ERR_SHORT_READ:
           simple_error_message_box(
                      "The capture file %s appears to have been cut short"
@@ -4466,12 +4454,6 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
       g_free(err_info);
       break;
 
-    case WTAP_ERR_CANT_READ:
-      simple_error_message_box(
-                 "An attempt to read from the capture file failed for"
-                 " some unknown reason.");
-      break;
-
     case WTAP_ERR_SHORT_READ:
       simple_error_message_box(
                  "The capture file appears to have been cut short"
index a1eb7fa0279caae2b55372ca88e88f5887bea8d0..3e9a0da992378dd3db6bc68eca3387304706dad9 100644 (file)
@@ -923,8 +923,7 @@ raw_pipe_read(struct wtap_pkthdr *phdr, guchar * pd, int *err, const gchar **err
             *err = 0;
             return FALSE;
         } else if (bytes_read < 0) {
-            *err = WTAP_ERR_CANT_READ;
-            *err_info = "Error reading header from pipe";
+            *err = errno;
             return FALSE;
         }
         bytes_needed -= bytes_read;
@@ -970,8 +969,7 @@ raw_pipe_read(struct wtap_pkthdr *phdr, guchar * pd, int *err, const gchar **err
             *err_info = "Got zero bytes reading data from pipe";
             return FALSE;
         } else if (bytes_read < 0) {
-            *err = WTAP_ERR_CANT_READ;
-            *err_info = "Error reading data from pipe";
+            *err = errno;
             return FALSE;
         }
         bytes_needed -= bytes_read;
@@ -1011,11 +1009,6 @@ load_cap_file(capture_file *cf)
                            cf->filename, err_info);
                 break;
 
-            case WTAP_ERR_CANT_READ:
-                cmdarg_err("An attempt to read from the file \"%s\" failed for some unknown reason.",
-                           cf->filename);
-                break;
-
             case WTAP_ERR_SHORT_READ:
                 cmdarg_err("The file \"%s\" appears to have been cut short in the middle of a packet.",
                            cf->filename);
index 48679fd229780fc638c3f5b6c3e2e9d7d56554ca..e60e38ce79cec0ade3f63c3c869dbb3833a9be02 100644 (file)
--- a/tshark.c
+++ b/tshark.c
@@ -3411,11 +3411,6 @@ load_cap_file(capture_file *cf, char *save_file, int out_file_type,
       g_free(err_info);
       break;
 
-    case WTAP_ERR_CANT_READ:
-      cmdarg_err("An attempt to read from the file \"%s\" failed for some unknown reason.",
-                 cf->filename);
-      break;
-
     case WTAP_ERR_SHORT_READ:
       cmdarg_err("The file \"%s\" appears to have been cut short in the middle of a packet.",
                  cf->filename);
index a2f5364283fc2444bc3c7261ac749960bdfb140f..6e128d4f0ec12b8684e17161fb20858cba871dcc 100644 (file)
@@ -115,7 +115,6 @@ int _5views_open(wtap *wth, int *err, gchar **err_info)
        t_5VW_Capture_Header Capture_Header;
        int encap = WTAP_ENCAP_UNKNOWN;
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, &Capture_Header.Info_Header,
            sizeof(t_5VW_Info_Header), err, err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
index 87e551503701ab532a6b2018eba50b4f36b9cab8..331c6fcfdd83bba1418e7276106b6634b07f0f67 100644 (file)
@@ -126,7 +126,6 @@ int aethra_open(wtap *wth, int *err, gchar **err_info)
        aethra_t *aethra;
 
        /* Read in the string that should be at the start of a "aethra" file */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, hdr.magic, sizeof hdr.magic, err,
            err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
@@ -138,7 +137,6 @@ int aethra_open(wtap *wth, int *err, gchar **err_info)
                return 0;
 
        /* Read the rest of the header. */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, (char *)&hdr + sizeof hdr.magic,
            sizeof hdr - sizeof hdr.magic, err, err_info))
                return -1;
@@ -301,7 +299,6 @@ aethra_read_rec_header(wtap *wth, FILE_T fh, struct aethrarec_hdr *hdr,
        guint32 msecs;
 
        /* Read record header. */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes_or_eof(fh, hdr, sizeof *hdr, err, err_info))
                return FALSE;
 
index 0e28449b5a103ed45cb2ddde96282d2fdd420245..051589e8f3f26c7e6064f891a1f26d2e27499d5f 100644 (file)
@@ -88,7 +88,6 @@ int btsnoop_open(wtap *wth, int *err, gchar **err_info)
        int file_encap=WTAP_ENCAP_UNKNOWN;
 
        /* Read in the string that should be at the start of a "btsnoop" file */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, magic, sizeof magic, err, err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
                        return -1;
@@ -100,7 +99,6 @@ int btsnoop_open(wtap *wth, int *err, gchar **err_info)
        }
 
        /* Read the rest of the header. */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, &hdr, sizeof hdr, err, err_info))
                return -1;
 
@@ -181,7 +179,6 @@ static gboolean btsnoop_read_record(wtap *wth, FILE_T fh,
 
        /* Read record header. */
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes_or_eof(fh, &hdr, sizeof hdr, err, err_info))
                return FALSE;
 
index 0c024e9c76bde55dc398479cf9ea5f2f79f5d036..2c815d62f14eaeba69482151551b49f5d04d04a6 100644 (file)
@@ -140,7 +140,6 @@ int eyesdn_open(wtap *wth, int *err, gchar **err_info)
        char    magic[EYESDN_HDR_MAGIC_SIZE];
 
        /* Look for eyesdn header */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, &magic, sizeof magic, err, err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
                        return -1;
@@ -325,7 +324,6 @@ read_eyesdn_rec(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf, int *err,
        /* Make sure we have enough room for the packet */
        ws_buffer_assure_space(buf, EYESDN_MAX_PACKET_LEN);
 
-       errno = WTAP_ERR_CANT_READ;
        pd = ws_buffer_start_ptr(buf);
        if (!esc_read(fh, pd, pkt_len, err, err_info))
                return FALSE;
index 33640df1d194a78e0da768abd471a2bb68cb01a9..b2a05b05feea6aaf7f77d9062231286d6b3c1cbe 100644 (file)
@@ -2405,6 +2405,7 @@ wtap_dump_file_write(wtap_dumper *wdh, const void *buf, size_t bufsize, int *err
        } else
 #endif
        {
+               errno = WTAP_ERR_CANT_WRITE;
                nwritten = fwrite(buf, 1, bufsize, (FILE *)wdh->fh);
                /*
                 * At least according to the Mac OS X man page,
index 4f7f241b429295dbb0315aff246363e33f715110..6e9ef001dc36aaef17b6e66300e69d5414a802f4 100644 (file)
@@ -55,7 +55,6 @@ int i4btrace_open(wtap *wth, int *err, gchar **err_info)
        i4btrace_t *i4btrace;
 
        /* I4B trace files have no magic in the header... Sigh */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, &hdr, sizeof(hdr), err, err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
                        return -1;
@@ -142,7 +141,6 @@ i4b_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
        i4b_trace_hdr_t hdr;
        guint32 length;
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes_or_eof(fh, &hdr, sizeof hdr, err, err_info))
                return FALSE;
 
index caa13c06986cfb9550c8f800d23e27c2d2450386..317d922215da0a3d478c1f947a9f91c97b13833c 100644 (file)
@@ -53,7 +53,6 @@ int iptrace_open(wtap *wth, int *err, gchar **err_info)
 {
        char name[NAME_SIZE+1];
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, name, NAME_SIZE, err, err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
                        return -1;
@@ -123,7 +122,6 @@ iptrace_read_rec_1_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
        iptrace_1_0_phdr        pkt_hdr;
        guint32                 packet_size;
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes_or_eof(fh, header, sizeof header, err, err_info)) {
                /* Read error or EOF */
                return FALSE;
@@ -299,7 +297,6 @@ iptrace_read_rec_2_0(FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
        iptrace_2_0_phdr        pkt_hdr;
        guint32                 packet_size;
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes_or_eof(fh, header, sizeof header, err, err_info)) {
                /* Read error or EOF */
                return FALSE;
index c6d3c36b9932ebf0e4bf818f2439090f3357ae12..50141f9ab67604ffcaaa7b8b0ce2a605f182f372 100644 (file)
@@ -209,7 +209,6 @@ iseries_open (wtap * wth, int *err, gchar ** err_info)
    * Check that file starts with a valid iSeries COMMS TRACE header
    * by scanning for it in the first line
    */
-  errno = WTAP_ERR_CANT_READ;
   if (!wtap_read_bytes (wth->fh, &magic, sizeof magic, err, err_info))
     {
       if (*err != WTAP_ERR_SHORT_READ)
index 70b0403cdd50f8331d9297196543518347e9ac72..3c3ba09ad9e604a0f2a48b27ce325abdcccea435 100644 (file)
@@ -289,7 +289,6 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
        struct tm tm;
        lanalyzer_t *lanalyzer;
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, &rec_header, LA_RecordHeaderSize,
            err, err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
@@ -345,7 +344,6 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
 
        /* Read records until we find the start of packets */
        while (1) {
-               errno = WTAP_ERR_CANT_READ;
                if (!wtap_read_bytes_or_eof(wth->fh, &rec_header,
                    LA_RecordHeaderSize, err, err_info)) {
                        if (*err == 0) {
@@ -365,7 +363,6 @@ int lanalyzer_open(wtap *wth, int *err, gchar **err_info)
                switch (record_type) {
                        /* Trace Summary Record */
                        case RT_Summary:
-                               errno = WTAP_ERR_CANT_READ;
                                if (!wtap_read_bytes(wth->fh, summary,
                                    sizeof summary, err, err_info))
                                        return -1;
@@ -449,7 +446,6 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
        time_t          tsecs;
 
        /* read the record type and length. */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes_or_eof(fh, LE_record_type, 2, err, err_info))
                return FALSE;
        if (!wtap_read_bytes(fh, LE_record_length, 2, err, err_info))
@@ -481,7 +477,6 @@ static gboolean lanalyzer_read_trace_record(wtap *wth, FILE_T fh,
        record_data_size = record_length - DESCRIPTOR_LEN;
 
        /* Read the descriptor data */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(fh, descriptor, DESCRIPTOR_LEN, err, err_info))
                return FALSE;
 
index 1b0e2b4571b285b94190f19ea6e100378de1bd8b..ecdf8922b3484c1f952b04f6c9aafe13ba4b51e5 100644 (file)
@@ -105,7 +105,6 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
        int i;
 
        /* Read in the number that should be at the start of a "libpcap" file */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, &magic, sizeof magic, err, err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
                        return -1;
@@ -173,7 +172,6 @@ int libpcap_open(wtap *wth, int *err, gchar **err_info)
        }
 
        /* Read the rest of the header. */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, &hdr, sizeof hdr, err, err_info))
                return -1;
 
@@ -741,7 +739,6 @@ static int libpcap_read_header(wtap *wth, FILE_T fh, int *err, gchar **err_info,
        guint32 temp;
        libpcap_t *libpcap;
 
-       errno = WTAP_ERR_CANT_READ;
        switch (wth->file_type_subtype) {
 
        case WTAP_FILE_TYPE_SUBTYPE_PCAP:
index 5337d1d35b6a32f93b781231f78b6a96fe97999a..72e566c0d64afd4ddabe4de78239aaf91b467073 100644 (file)
@@ -67,7 +67,6 @@ mp2t_read_packet(mp2t_filetype_t *mp2t, FILE_T fh, gint64 offset,
     guint64 tmp;
 
     ws_buffer_assure_space(buf, MP2T_SIZE);
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes_or_eof(fh, ws_buffer_start_ptr(buf), MP2T_SIZE, err, err_info))
         return FALSE;
 
@@ -152,7 +151,6 @@ mp2t_open(wtap *wth, int *err, gchar **err_info)
     mp2t_filetype_t *mp2t;
 
 
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes(wth->fh, buffer, MP2T_SIZE, err, err_info)) {
         if (*err != WTAP_ERR_SHORT_READ)
             return -1;
index 681e4baa5029d1c1bc65c5625e86dc83d240a9e8..00ff23e9bb4ed6cdd656ca411584662449166bc6 100644 (file)
@@ -92,7 +92,6 @@ mpeg_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
         * file begins with 0x00 0x00 0x01, it contains PES packets,
         * otherwise it doesn't)?
         */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes_or_eof(fh, &n, sizeof n, err, err_info))
                return FALSE;
        if (file_seek(fh, -(gint64)(sizeof n), SEEK_CUR, err) == -1)
@@ -239,7 +238,6 @@ mpeg_open(wtap *wth, int *err, gchar **err_info)
        struct _mpeg_magic* m;
        mpeg_t *mpeg;
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, magic_buf, sizeof magic_buf,
            err, err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
index 65da2d8805fcac6f1447898beae6496ec7a12c39..684509aeb6bad9e448b00fd308c56de6495e0b34 100644 (file)
@@ -203,7 +203,6 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
 
        /* Read in the string that should be at the start of a Network
         * Monitor file */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, magic, MAGIC_SIZE, err, err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
                        return -1;
@@ -216,7 +215,6 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
        }
 
        /* Read the rest of the header. */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, &hdr, sizeof hdr, err, err_info))
                return -1;
 
@@ -358,7 +356,6 @@ int netmon_open(wtap *wth, int *err, gchar **err_info)
                *err = ENOMEM;  /* we assume we're out of memory */
                return -1;
        }
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, frame_table, frame_table_length,
            err, err_info)) {
                g_free(frame_table);
@@ -489,7 +486,6 @@ netmon_process_record(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
                hdr_size = sizeof (struct netmonrec_2_x_hdr);
                break;
        }
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes_or_eof(fh, &hdr, hdr_size, err, err_info))
                return FAILURE;
 
@@ -660,7 +656,6 @@ netmon_process_record(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
                        }
                }
 
-               errno = WTAP_ERR_CANT_READ;
                if (!wtap_read_bytes(fh, &trlr, trlr_size, err, err_info))
                        return FAILURE;
 
@@ -876,7 +871,6 @@ netmon_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
        struct netmon_atm_hdr atm_phdr;
        guint16 vpi, vci;
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(fh, &atm_phdr, sizeof (struct netmon_atm_hdr),
            err, err_info))
                return FALSE;
index 03aba5bf74aa5b987072eb3750bec793d942e49f..1c28c5f11bfc046cff996faf386cb652f35206fa 100644 (file)
@@ -674,7 +674,6 @@ int nstrace_open(wtap *wth, int *err, gchar **err_info)
     gint32 page_size;
     nstrace_t *nstrace;
 
-    errno = WTAP_ERR_CANT_READ;
 
     if ((file_size = wtap_file_size(wth, err)) == -1)
         return 0;
index 175222527803b051457232d451cde978f9d954e3..b45652d4c4e9f78bb493163e45270c97a0957e50 100644 (file)
@@ -195,7 +195,6 @@ int nettl_open(wtap *wth, int *err, gchar **err_info)
     memset(&file_hdr, 0, sizeof(file_hdr));
 
     /* Read in the string that should be at the start of a HP file */
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes(wth->fh, file_hdr.magic, MAGIC_SIZE, err, err_info)) {
         if (*err != WTAP_ERR_SHORT_READ)
             return -1;
@@ -341,7 +340,6 @@ nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
     int bytes_to_read;
     guint8 *pd;
 
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes_or_eof(fh, &rec_hdr.hdr_len, sizeof rec_hdr.hdr_len,
                                 err, err_info))
         return FALSE;
@@ -586,7 +584,6 @@ nettl_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
      */
     ws_buffer_assure_space(buf, datalen);
     pd = ws_buffer_start_ptr(buf);
-    errno = WTAP_ERR_CANT_READ;
     if (fddihack) {
         /* read in FC, dest, src, DSAP and SSAP */
         bytes_to_read = 15;
index 555414253c67589ba1b8e1b67c356cacae9231bd..64b96375b6589f64174af7912554d2f960a579aa 100644 (file)
@@ -123,7 +123,6 @@ int network_instruments_open(wtap *wth, int *err, gchar **err_info)
     packet_entry_header packet_header;
     observer_dump_private_state * private_state = NULL;
 
-    errno = WTAP_ERR_CANT_READ;
     offset = 0;
 
     /* read in the buffer file header */
index fa8573839edc7f3be66a63f0f1c7089daec7934d..d6d37535a921ac5d1e87fa60771649d2a2c89dcc 100644 (file)
@@ -460,7 +460,6 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
 
        /* Read in the string that should be at the start of a NetXRay
         * file */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, magic, MAGIC_SIZE, err, err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
                        return -1;
@@ -476,7 +475,6 @@ netxray_open(wtap *wth, int *err, gchar **err_info)
        }
 
        /* Read the rest of the header. */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, &hdr, sizeof hdr, err, err_info))
                return -1;
 
@@ -1139,7 +1137,6 @@ netxray_process_rec_header(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
                hdr_size = sizeof (struct netxrayrec_2_x_hdr);
                break;
        }
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes_or_eof(fh, (void *)&hdr, hdr_size, err, err_info)) {
                /*
                 * If *err is 0, we're at EOF.  *err being 0 and a return
index b29840bbfc98ba46435cc17816c2e5f1ea8e542a..aa3a51494fccec6e355a5508a69d60b8786b14fd 100644 (file)
@@ -574,7 +574,6 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
        ngsniffer_t *ngsniffer;
 
        /* Read in the string that should be at the start of a Sniffer file */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, magic, sizeof magic, err, err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
                        return -1;
@@ -589,7 +588,6 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
         * Read the first record, which the manual says is a version
         * record.
         */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, record_type, 2, err, err_info))
                return -1;
        if (!wtap_read_bytes(wth->fh, record_length, 4, err, err_info))
@@ -603,7 +601,6 @@ ngsniffer_open(wtap *wth, int *err, gchar **err_info)
                return -1;
        }
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, &version, sizeof version, err, err_info))
                return -1;
 
@@ -788,7 +785,6 @@ process_header_records(wtap *wth, int *err, gchar **err_info, gint16 maj_vers,
        unsigned char buffer[256];
 
        for (;;) {
-               errno = WTAP_ERR_CANT_READ;
                if (!wtap_read_bytes_or_eof(wth->fh, record_type, 2, err, err_info)) {
                        if (*err != 0)
                                return -1;
@@ -813,7 +809,6 @@ process_header_records(wtap *wth, int *err, gchar **err_info, gint16 maj_vers,
                        return 0;
                }
 
-               errno = WTAP_ERR_CANT_READ;
                if (!wtap_read_bytes(wth->fh, record_length, 4,
                    err, err_info))
                        return -1;
@@ -2426,7 +2421,6 @@ ng_file_read(void *buffer, unsigned int nbytes, wtap *wth, gboolean is_random,
        }
 
        if (wth->file_type_subtype == WTAP_FILE_TYPE_SUBTYPE_NGSNIFFER_UNCOMPRESSED) {
-               errno = WTAP_ERR_CANT_READ;
                copied_bytes = file_read(buffer, copybytes, infile);
                if ((unsigned int) copied_bytes != copybytes)
                        *err = file_error(infile, err_info);
@@ -2533,7 +2527,6 @@ read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, int *err,
        int out_len;
 
        /* Read one 16-bit word which is length of next compressed blob */
-       errno = WTAP_ERR_CANT_READ;
        read_len = file_read(&blob_len, 2, infile);
        if (2 != read_len) {
                *err = file_error(infile, err_info);
@@ -2555,7 +2548,6 @@ read_blob(FILE_T infile, ngsniffer_comp_stream_t *comp_stream, int *err,
        file_inbuf = (unsigned char *)g_malloc(INBUF_SIZE);
 
        /* Read the blob */
-       errno = WTAP_ERR_CANT_READ;
        read_len = file_read(file_inbuf, in_len, infile);
        if ((size_t) in_len != read_len) {
                *err = file_error(infile, err_info);
index a4e39c1cb9feb4094722d60143014f19b9f0492c..a28c3248fc2465ea4fce95851766141d047ae939 100644 (file)
@@ -813,7 +813,6 @@ pcap_read_sunatm_pseudoheader(FILE_T fh,
        guint8  vpi;
        guint16 vci;
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(fh, atm_phdr, SUNATM_LEN, err, err_info))
                return FALSE;
 
@@ -895,7 +894,6 @@ pcap_read_nokiaatm_pseudoheader(FILE_T fh,
        guint8  vpi;
        guint16 vci;
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(fh, atm_phdr, NOKIAATM_LEN, err, err_info))
                return FALSE;
 
@@ -922,7 +920,6 @@ pcap_read_nokia_pseudoheader(FILE_T fh,
 {
        guint8  phdr[NOKIA_LEN];
 
-       errno = WTAP_ERR_CANT_READ;
 
        /* backtrack to read the 4 mysterious bytes that aren't considered
        * part of the packet size
@@ -949,7 +946,6 @@ pcap_read_irda_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
 {
        guint8  irda_phdr[IRDA_SLL_LEN];
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(fh, irda_phdr, IRDA_SLL_LEN, err, err_info))
                return FALSE;
 
@@ -970,7 +966,6 @@ pcap_read_mtp2_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
 {
        guint8 mtp2_hdr[MTP2_HDR_LEN];
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(fh, mtp2_hdr, MTP2_HDR_LEN, err, err_info))
                return FALSE;
 
@@ -987,7 +982,6 @@ pcap_read_lapd_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
 {
        guint8  lapd_phdr[LAPD_SLL_LEN];
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(fh, lapd_phdr, LAPD_SLL_LEN, err, err_info))
                return FALSE;
 
@@ -1009,7 +1003,6 @@ pcap_read_sita_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
 {
        guint8  sita_phdr[SITA_HDR_LEN];
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(fh, sita_phdr, SITA_HDR_LEN, err, err_info))
                return FALSE;
 
@@ -1346,7 +1339,6 @@ pcap_read_bt_pseudoheader(FILE_T fh,
 {
        struct libpcap_bt_phdr phdr;
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(fh, &phdr, sizeof (struct libpcap_bt_phdr),
            err, err_info))
                return FALSE;
@@ -1360,7 +1352,6 @@ pcap_read_bt_monitor_pseudoheader(FILE_T fh,
 {
        struct libpcap_bt_monitor_phdr phdr;
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(fh, &phdr, sizeof (struct libpcap_bt_monitor_phdr),
            err, err_info))
                return FALSE;
@@ -1376,7 +1367,6 @@ pcap_read_llcp_pseudoheader(FILE_T fh,
 {
        guint8 phdr[LLCP_HEADER_LEN];
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(fh, phdr, LLCP_HEADER_LEN, err, err_info))
                return FALSE;
        pseudo_header->llcp.adapter = phdr[LLCP_ADAPTER_OFFSET];
@@ -1390,7 +1380,6 @@ pcap_read_ppp_pseudoheader(FILE_T fh,
 {
        struct libpcap_ppp_phdr phdr;
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(fh, &phdr, sizeof (struct libpcap_ppp_phdr),
            err, err_info))
                return FALSE;
@@ -1404,7 +1393,6 @@ pcap_read_erf_pseudoheader(FILE_T fh, struct wtap_pkthdr *whdr,
 {
   guint8 erf_hdr[sizeof(struct erf_phdr)];
 
-  errno = WTAP_ERR_CANT_READ;
   if (!wtap_read_bytes(fh, erf_hdr, sizeof(struct erf_phdr), err, err_info))
     return FALSE;
   pseudo_header->erf.phdr.ts = pletoh64(&erf_hdr[0]); /* timestamp */
@@ -1446,7 +1434,6 @@ pcap_read_erf_exheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
   *psize = 0;
   if (pseudo_header->erf.phdr.type & 0x80){
     do{
-      errno = WTAP_ERR_CANT_READ;
       if (!wtap_read_bytes(fh, erf_exhdr, 8, err, err_info))
        return FALSE;
       type = erf_exhdr[0];
@@ -1480,7 +1467,6 @@ pcap_read_erf_subheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
   case ERF_TYPE_MC_AAL2:
   case ERF_TYPE_COLOR_MC_HDLC_POS:
     /* Extract the Multi Channel header to include it in the pseudo header part */
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes(fh, erf_subhdr, sizeof(erf_mc_header_t), err, err_info))
       return FALSE;
     pseudo_header->erf.subhdr.mc_hdr = pntoh32(&erf_subhdr[0]);
@@ -1490,7 +1476,6 @@ pcap_read_erf_subheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
   case ERF_TYPE_COLOR_ETH:
   case ERF_TYPE_DSM_COLOR_ETH:
     /* Extract the Ethernet additional header to include it in the pseudo header part */
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes(fh, erf_subhdr, sizeof(erf_eth_header_t), err, err_info))
       return FALSE;
     pseudo_header->erf.subhdr.eth_hdr = pntoh16(&erf_subhdr[0]);
@@ -1508,7 +1493,6 @@ pcap_read_i2c_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header, i
 {
        struct i2c_file_hdr i2c_hdr;
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(fh, &i2c_hdr, sizeof (i2c_hdr), err, err_info))
                return FALSE;
 
index 201588b22d4522c97c9acf64542b02b77da45437..eef773ef8d1df741dde768e5c77a6a5ac67d9526 100644 (file)
@@ -435,7 +435,6 @@ pcapng_read_option(FILE_T fh, pcapng_t *pn, pcapng_option_header_t *oh,
     }
 
     /* read option header */
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes(fh, oh, sizeof (*oh), err, err_info)) {
         pcapng_debug0("pcapng_read_option: failed to read option");
         return -1;
@@ -461,7 +460,6 @@ pcapng_read_option(FILE_T fh, pcapng_t *pn, pcapng_option_header_t *oh,
     }
 
     /* read option content */
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes(fh, content, oh->option_length, err, err_info)) {
         pcapng_debug1("pcapng_read_option: failed to read content of option %u", oh->option_code);
         return -1;
@@ -521,7 +519,6 @@ pcapng_read_section_header_block(FILE_T fh, gboolean first_block,
     }
 
     /* read block content */
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes(fh, &shb, sizeof shb, err, err_info)) {
         if (*err == WTAP_ERR_SHORT_READ) {
             if (first_block) {
@@ -615,7 +612,6 @@ pcapng_read_section_header_block(FILE_T fh, gboolean first_block,
     }
 
     /* Options */
-    errno = WTAP_ERR_CANT_READ;
     to_read = bh->block_total_length - MIN_SHB_SIZE;
 
     /* Allocate enough memory to hold all options */
@@ -737,7 +733,6 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh,
     }
 
     /* read block content */
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes(fh, &idb, sizeof idb, err, err_info)) {
         pcapng_debug0("pcapng_read_if_descr_block: failed to read IDB");
         return -1;
@@ -791,7 +786,6 @@ pcapng_read_if_descr_block(wtap *wth, FILE_T fh, pcapng_block_header_t *bh,
 
 
     /* Options */
-    errno = WTAP_ERR_CANT_READ;
     to_read = bh->block_total_length - MIN_IDB_SIZE;
 
     /* Allocate enough memory to hold all options */
@@ -1033,7 +1027,6 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
     }
 
     /* "(Enhanced) Packet Block" read fixed part */
-    errno = WTAP_ERR_CANT_READ;
     if (enhanced) {
         /*
          * Is this block long enough to be an EPB?
@@ -1209,7 +1202,6 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
     wblock->packet_header->ts.nsecs = (int)(((ts % iface_info.time_units_per_second) * 1000000000) / iface_info.time_units_per_second);
 
     /* "(Enhanced) Packet Block" read capture data */
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_packet_bytes(fh, wblock->frame_buffer,
                                 packet.cap_len - pseudo_header_len, err, err_info))
         return -1;
@@ -1236,7 +1228,6 @@ pcapng_read_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *pn, wta
      * epb_hash       3
      * epb_dropcount  4
      */
-    errno = WTAP_ERR_CANT_READ;
     to_read = block_total_length -
         (int)sizeof(pcapng_block_header_t) -
         block_read -    /* fixed and variable part, including padding */
@@ -1370,7 +1361,6 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *
     }
 
     /* "Simple Packet Block" read fixed part */
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes(fh, &spb, sizeof spb, err, err_info)) {
         pcapng_debug0("pcapng_read_simple_packet_block: failed to read packet data");
         return -1;
@@ -1480,7 +1470,6 @@ pcapng_read_simple_packet_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t *
     memset((void *)&wblock->packet_header->pseudo_header, 0, sizeof(union wtap_pseudo_header));
 
     /* "Simple Packet Block" read capture data */
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_packet_bytes(fh, wblock->frame_buffer,
                                 simple_packet.cap_len, err, err_info))
         return -1;
@@ -1583,7 +1572,6 @@ pcapng_read_name_resolution_block(FILE_T fh, pcapng_block_header_t *bh, pcapng_t
         return -1;
     }
 
-    errno = WTAP_ERR_CANT_READ;
     to_read = bh->block_total_length - 8 - 4; /* We have read the header adn should not read the final block_total_length */
 
     pcapng_debug1("pcapng_read_name_resolution_block, total %d bytes", bh->block_total_length);
@@ -1808,7 +1796,6 @@ pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, pca
     }
 
     /* "Interface Statistics Block" read fixed part */
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes(fh, &isb, sizeof isb, err, err_info)) {
         pcapng_debug0("pcapng_read_interface_statistics_block: failed to read packet data");
         return -1;
@@ -1835,7 +1822,6 @@ pcapng_read_interface_statistics_block(FILE_T fh, pcapng_block_header_t *bh, pca
     wblock->data.if_stats.isb_usrdeliv         = -1;
 
     /* Options */
-    errno = WTAP_ERR_CANT_READ;
     to_read = bh->block_total_length -
         (MIN_BLOCK_SIZE + block_read);    /* fixed and variable part, including padding */
 
@@ -2055,7 +2041,6 @@ pcapng_read_block(wtap *wth, FILE_T fh, gboolean first_block, pcapng_t *pn, wtap
     memset(&(wblock->data), 0, sizeof(wblock->data));
 
     /* Try to read the (next) block header */
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes_or_eof(fh, &bh, sizeof bh, err, err_info)) {
         pcapng_debug1("pcapng_read_block: wtap_read_bytes_or_eof() failed, err = %d.", *err);
         if (*err == 0 || *err == WTAP_ERR_SHORT_READ) {
@@ -2128,7 +2113,6 @@ pcapng_read_block(wtap *wth, FILE_T fh, gboolean first_block, pcapng_t *pn, wtap
     block_read += bytes_read;
 
     /* sanity check: first and second block lengths must match */
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes(fh, &block_total_length, sizeof block_total_length,
                          err, err_info)) {
         pcapng_debug0("pcapng_read_block: couldn't read second block length");
@@ -2271,7 +2255,6 @@ pcapng_open(wtap *wth, int *err, gchar **err_info)
         /* peek at next block */
         /* Try to read the (next) block header */
         saved_offset = file_tell(wth->fh);
-        errno = WTAP_ERR_CANT_READ;
         if (!wtap_read_bytes_or_eof(wth->fh, &bh, sizeof bh, err, err_info)) {
             if (*err == 0) {
                 /* EOF */
index 188882fd24f76a26bf93919800a409ca4257dfa8..52c7cdc05d413db0bffa6298cdb8cc1b91d7dd10 100644 (file)
@@ -101,7 +101,6 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
 #endif
 
        /* Read in the string that should be at the start of a RADCOM file */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, r_magic, 8, err, err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
                        return -1;
@@ -120,7 +119,6 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
 
        /* Look for the "Active Time" string. The "frame_date" structure should
         * be located 32 bytes before the beginning of this string */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, t_magic, 11, err, err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
                        return -1;
@@ -130,7 +128,6 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
        {
                if (file_seek(wth->fh, -10, SEEK_CUR, err) == -1)
                        return -1;
-               errno = WTAP_ERR_CANT_READ;
                if (!wtap_read_bytes(wth->fh, t_magic, 11, err, err_info)) {
                        if (*err != WTAP_ERR_SHORT_READ)
                                return -1;
@@ -140,7 +137,6 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
        if (file_seek(wth->fh, -43, SEEK_CUR, err) == -1) return -1;
 
        /* Get capture start time */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, &start_date, sizeof(struct frame_date),
            err, err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
@@ -152,7 +148,6 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
                return -1;
 
        for (;;) {
-               errno = WTAP_ERR_CANT_READ;
                if (!wtap_read_bytes(wth->fh, search_encap, 4,
                    err, err_info)) {
                        if (*err != WTAP_ERR_SHORT_READ)
@@ -174,7 +169,6 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
        }
        if (file_seek(wth->fh, 12, SEEK_CUR, err) == -1)
                return -1;
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, search_encap, 4, err, err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
                        return -1;
@@ -212,7 +206,6 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
        }
 
 #if 0
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, &next_date, sizeof(struct frame_date),
            err, err_info))
                return -1;
@@ -220,7 +213,6 @@ int radcom_open(wtap *wth, int *err, gchar **err_info)
        while (memcmp(&start_date, &next_date, 4)) {
                if (file_seek(wth->fh, 1-sizeof(struct frame_date), SEEK_CUR, err) == -1)
                        return -1;
-               errno = WTAP_ERR_CANT_READ;
                if (!wtap_read_bytes(wth->fh, &next_date, sizeof(struct frame_date),
                    err, err_info))
                        return -1;
@@ -261,7 +253,6 @@ static gboolean radcom_read(wtap *wth, int *err, gchar **err_info,
                   XXX - should we have some way of indicating the
                   presence and size of an FCS to our caller?
                   That'd let us handle other file types as well. */
-               errno = WTAP_ERR_CANT_READ;
                if (!wtap_read_bytes(wth->fh, &fcs, sizeof fcs, err, err_info))
                        return FALSE;
        }
@@ -300,7 +291,6 @@ radcom_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
        struct tm tm;
        guint8  atmhdr[8];
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes_or_eof(fh, &hdr, sizeof hdr, err, err_info))
                return FALSE;
 
@@ -350,7 +340,6 @@ radcom_read_rec(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr, Buffer *buf,
                 * XXX - is this stuff a pseudo-header?
                 * The direction appears to be in the "hdr.dce" field.
                 */
-               errno = WTAP_ERR_CANT_READ;
                if (!wtap_read_bytes(fh, atmhdr, sizeof atmhdr, err,
                    err_info))
                        return FALSE;   /* Read error */
index 9d175703894e22c8a822390d9e28350a4db23595..b8c64f9de91c78935dcaa352c4c2620ea5fc3d64 100644 (file)
@@ -253,7 +253,6 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
        gint64 saved_offset;
 
        /* Read in the string that should be at the start of a "snoop" file */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, magic, sizeof magic, err, err_info)) {
                if (*err != WTAP_ERR_SHORT_READ)
                        return -1;
@@ -265,7 +264,6 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
        }
 
        /* Read the rest of the header. */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(wth->fh, &hdr, sizeof hdr, err, err_info))
                return -1;
 
@@ -321,7 +319,6 @@ int snoop_open(wtap *wth, int *err, gchar **err_info)
 
        /* Read first record header. */
        saved_offset = file_tell(wth->fh);
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes_or_eof(wth->fh, &rec_hdr, sizeof rec_hdr, err, err_info)) {
                if (*err != 0)
                        return -1;
@@ -482,7 +479,6 @@ snoop_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
        int header_size;
 
        /* Read record header. */
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes_or_eof(fh, &hdr, sizeof hdr, err, err_info))
                return -1;
 
@@ -629,7 +625,6 @@ snoop_read_atm_pseudoheader(FILE_T fh, union wtap_pseudo_header *pseudo_header,
        guint8  vpi;
        guint16 vci;
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(fh, &atm_phdr, sizeof atm_phdr, err, err_info))
                return FALSE;
 
@@ -716,7 +711,6 @@ snoop_read_shomiti_wireless_pseudoheader(FILE_T fh,
        shomiti_wireless_header whdr;
        int     rsize;
 
-       errno = WTAP_ERR_CANT_READ;
        if (!wtap_read_bytes(fh, &whdr, sizeof whdr, err, err_info))
                return FALSE;
 
index 0aedeb3a73cc29b0b0d9641b3695ed0ced711fe7..d781e3651a688d36484d4e5ad6f8c0ef946c9710 100644 (file)
@@ -179,7 +179,6 @@ int visual_open(wtap *wth, int *err, gchar **err_info)
     int encap;
 
     /* Check the magic string at the start of the file */
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes(wth->fh, magic, sizeof magic, err, err_info))
     {
         if (*err != WTAP_ERR_SHORT_READ)
@@ -192,7 +191,6 @@ int visual_open(wtap *wth, int *err, gchar **err_info)
     }
 
     /* Read the rest of the file header. */
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes(wth->fh, &vfile_hdr, sizeof vfile_hdr, err, err_info))
     {
         return -1;
@@ -327,7 +325,6 @@ visual_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
     guint8 *pd;
 
     /* Read the packet header. */
-    errno = WTAP_ERR_CANT_READ;
     if (!wtap_read_bytes_or_eof(fh, &vpkt_hdr, (unsigned int)sizeof vpkt_hdr, err, err_info))
     {
         return FALSE;
@@ -445,7 +442,6 @@ visual_read_packet(wtap *wth, FILE_T fh, struct wtap_pkthdr *phdr,
 
            ATM packets have an additional packet header; read and
            process it. */
-        errno = WTAP_ERR_CANT_READ;
         if (!wtap_read_bytes(fh, &vatm_hdr, (unsigned int)sizeof vatm_hdr, err, err_info))
         {
             return FALSE;
index 1a76c6c7597b01869f21f4761e2d3da93ca782d7..43cedd33fe8a70cfa6db075006f6362b935bfa1d 100644 (file)
@@ -635,7 +635,6 @@ static gboolean vwr_read_rec_header(vwr_t *vwr, FILE_T fh, int *rec_size, int *I
     int     f_len, v_type;
     guint8  header[VW_RECORD_HEADER_LENGTH];
 
-    errno = WTAP_ERR_CANT_READ;
     *rec_size = 0;
 
     /* Read out the file data in 16-byte messages, stopping either after we find a frame,  */
index ff3d88a975c2b67f5a065ad0cff4a953245791be..cd64e9930fad4794977ae749b8ce37d5e871935b 100644 (file)
@@ -813,31 +813,82 @@ wtap_short_string_to_encap(const char *short_name)
 }
 
 static const char *wtap_errlist[] = {
+       /* WTAP_ERR_NOT_REGULAR_FILE */
        "The file isn't a plain file or pipe",
+
+       /* WTAP_ERR_RANDOM_OPEN_PIPE */
        "The file is being opened for random access but is a pipe",
+
+       /* WTAP_ERR_FILE_UNKNOWN_FORMAT */
        "The file isn't a capture file in a known format",
+
+       /* WTAP_ERR_UNSUPPORTED */
        "File contains record data we don't support",
+
+       /* WTAP_ERR_CANT_WRITE_TO_PIPE */
        "That file format cannot be written to a pipe",
+
+       /* WTAP_ERR_CANT_OPEN */
        NULL,
+
+       /* WTAP_ERR_UNSUPPORTED_FILE_TYPE */
        "Files can't be saved in that format",
+
+       /* WTAP_ERR_UNSUPPORTED_ENCAP */
        "Files from that network type can't be saved in that format",
+
+       /* WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED */
        "That file format doesn't support per-packet encapsulations",
+
+       /* WTAP_ERR_CANT_WRITE */
        NULL,
+
+       /* WTAP_ERR_CANT_CLOSE */
        NULL,
+
+       /* WTAP_ERR_SHORT_READ */
        "Less data was read than was expected",
+
+       /* WTAP_ERR_BAD_FILE */
        "The file appears to be damaged or corrupt",
+
+       /* WTAP_ERR_SHORT_WRITE */
        "Less data was written than was requested",
+
+       /* WTAP_ERR_UNC_TRUNCATED */
        "Uncompression error: data oddly truncated",
+
+       /* WTAP_ERR_UNC_OVERFLOW */
        "Uncompression error: data would overflow buffer",
+
+       /* WTAP_ERR_UNC_BAD_OFFSET */
        "Uncompression error: bad LZ77 offset",
+
+       /* WTAP_ERR_RANDOM_OPEN_STDIN */
        "The standard input cannot be opened for random access",
+
+       /* WTAP_ERR_COMPRESSION_NOT_SUPPORTED */
        "That file format doesn't support compression",
+
+       /* WTAP_ERR_CANT_SEEK */
        NULL,
+
+       /* WTAP_ERR_CANT_SEEK_COMPRESSED */
        NULL,
+
+       /* WTAP_ERR_DECOMPRESS */
        "Uncompression error",
+
+       /* WTAP_ERR_INTERNAL */
        "Internal error",
+
+       /* WTAP_ERR_PACKET_TOO_LARGE */
        "The packet being written is too large for that format",
+
+       /* WTAP_ERR_CHECK_WSLUA */
        NULL,
+
+       /* WTAP_ERR_REC_TYPE_UNSUPPORTED */
        "That record type cannot be written in that format"
 };
 #define        WTAP_ERRLIST_SIZE       (sizeof wtap_errlist / sizeof wtap_errlist[0])
@@ -1108,7 +1159,6 @@ wtap_read_packet_bytes(FILE_T fh, Buffer *buf, guint length, int *err,
     gchar **err_info)
 {
        ws_buffer_assure_space(buf, length);
-       errno = WTAP_ERR_CANT_READ;
        return wtap_read_bytes(fh, ws_buffer_start_ptr(buf), length, err,
            err_info);
 }
index e58134a2f0287ce42d401728bd49212915b1d3b8..3dd525826b42ec75e7c3932ebbbf85aa1aa6548a 100644 (file)
@@ -1636,12 +1636,12 @@ int wtap_register_encap_type(const char* name, const char* short_name);
 #define WTAP_ERR_ENCAP_PER_PACKET_UNSUPPORTED  -9
     /** The specified format doesn't support per-packet encapsulations */
 
-#define WTAP_ERR_CANT_CLOSE                   -10
-    /** The file couldn't be closed, reason unknown */
-
-#define WTAP_ERR_CANT_READ                    -11
+#define WTAP_ERR_CANT_WRITE                   -10
     /** An attempt to read failed, reason unknown */
 
+#define WTAP_ERR_CANT_CLOSE                   -11
+    /** The file couldn't be closed, reason unknown */
+
 #define WTAP_ERR_SHORT_READ                   -12
     /** An attempt to read read less data than it should have */