From a566f617d8f712a8f4d1fe7b6d9b9f6ebe79ba11 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 7 Oct 2014 16:18:47 -0700 Subject: No need for WTAP_ERR_CANT_READ. 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 --- rawshark.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'rawshark.c') diff --git a/rawshark.c b/rawshark.c index a1eb7fa027..3e9a0da992 100644 --- a/rawshark.c +++ b/rawshark.c @@ -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); -- cgit v1.2.3