summaryrefslogtreecommitdiff
path: root/source/cbz
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2015-02-13 12:16:06 +0100
committerTor Andersson <tor.andersson@artifex.com>2015-02-17 18:06:11 +0100
commit6cc97e85489f5e4e39aa185d17ad5e35b09dddb5 (patch)
tree336b711593d85f80d89da363d1ae269dcdf9b159 /source/cbz
parentf84a189d5f94250e46d2cbd1a75aba00130e2dd6 (diff)
downloadmupdf-6cc97e85489f5e4e39aa185d17ad5e35b09dddb5.tar.xz
Remove pointless return value checks when calling fz_open_file.
fz_open_file does not return NULL on failure -- it throws an exception!
Diffstat (limited to 'source/cbz')
-rw-r--r--source/cbz/mucbz.c2
-rw-r--r--source/cbz/muimg.c2
-rw-r--r--source/cbz/mutiff.c22
3 files changed, 2 insertions, 24 deletions
diff --git a/source/cbz/mucbz.c b/source/cbz/mucbz.c
index 75148490..8ea782aa 100644
--- a/source/cbz/mucbz.c
+++ b/source/cbz/mucbz.c
@@ -230,8 +230,6 @@ cbz_open_document(fz_context *ctx, const char *filename)
cbz_document *doc;
file = fz_open_file(ctx, filename);
- if (!file)
- fz_throw(ctx, FZ_ERROR_GENERIC, "cannot open file '%s': %s", filename, strerror(errno));
fz_try(ctx)
doc = cbz_open_document_with_stream(ctx, file);
diff --git a/source/cbz/muimg.c b/source/cbz/muimg.c
index a288a4f4..0680c15a 100644
--- a/source/cbz/muimg.c
+++ b/source/cbz/muimg.c
@@ -145,8 +145,6 @@ img_open_document(fz_context *ctx, const char *filename)
img_document *doc;
stm = fz_open_file(ctx, filename);
- if (!stm)
- fz_throw(ctx, FZ_ERROR_GENERIC, "cannot open file '%s': %s", filename, strerror(errno));
fz_try(ctx)
doc = img_open_document_with_stream(ctx, stm);
diff --git a/source/cbz/mutiff.c b/source/cbz/mutiff.c
index c03cb3b7..c0b9cff0 100644
--- a/source/cbz/mutiff.c
+++ b/source/cbz/mutiff.c
@@ -14,7 +14,6 @@ struct tiff_page_s
struct tiff_document_s
{
fz_document super;
- fz_stream *file;
fz_buffer *buffer;
int page_count;
};
@@ -118,7 +117,6 @@ static void
tiff_close_document(fz_context *ctx, tiff_document *doc)
{
fz_drop_buffer(ctx, doc->buffer);
- fz_drop_stream(ctx, doc->file);
fz_free(ctx, doc);
}
@@ -126,8 +124,6 @@ static tiff_document *
tiff_open_document_with_stream(fz_context *ctx, fz_stream *file)
{
tiff_document *doc;
- unsigned char *buf;
- int len;
doc = fz_new_document(ctx, sizeof *doc);
@@ -136,16 +132,10 @@ tiff_open_document_with_stream(fz_context *ctx, fz_stream *file)
doc->super.load_page = (fz_document_load_page_fn *)tiff_load_page;
doc->super.meta = (fz_document_meta_fn *)tiff_meta;
- doc->file = fz_keep_stream(ctx, file);
- doc->page_count = 0;
-
fz_try(ctx)
{
- doc->buffer = fz_read_all(ctx, doc->file, 1024);
- len = doc->buffer->len;
- buf = doc->buffer->data;
-
- doc->page_count = fz_load_tiff_subimage_count(ctx, buf, len);
+ doc->buffer = fz_read_all(ctx, file, 1024);
+ doc->page_count = fz_load_tiff_subimage_count(ctx, doc->buffer->data, doc->buffer->len);
}
fz_catch(ctx)
{
@@ -163,21 +153,13 @@ tiff_open_document(fz_context *ctx, const char *filename)
tiff_document *doc;
file = fz_open_file(ctx, filename);
- if (!file)
- fz_throw(ctx, FZ_ERROR_GENERIC, "cannot open file '%s': %s", filename, strerror(errno));
fz_try(ctx)
- {
doc = tiff_open_document_with_stream(ctx, file);
- }
fz_always(ctx)
- {
fz_drop_stream(ctx, file);
- }
fz_catch(ctx)
- {
fz_rethrow(ctx);
- }
return doc;
}