summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-04-27 16:48:28 +0200
committerTor Andersson <tor.andersson@artifex.com>2016-04-27 17:01:06 +0200
commitd6813444e1fa8c633398fa47e5c919801158eecd (patch)
tree06fbe29d76c023ddc9e8b15c402fc23e3018c3c3
parent29d53a0a460e00b3ec9dda508adbd2964077ab27 (diff)
downloadmupdf-d6813444e1fa8c633398fa47e5c919801158eecd.tar.xz
Remove useless try/catch/rethrows.
-rw-r--r--source/fitz/load-gif.c34
-rw-r--r--source/fitz/load-tiff.c19
-rw-r--r--source/pdf/pdf-interpret.c2
-rw-r--r--source/pdf/pdf-xref.c54
4 files changed, 25 insertions, 84 deletions
diff --git a/source/fitz/load-gif.c b/source/fitz/load-gif.c
index 46b2ba66..02c153f0 100644
--- a/source/fitz/load-gif.c
+++ b/source/fitz/load-gif.c
@@ -304,16 +304,7 @@ gif_read_gce(fz_context *ctx, struct info *info, unsigned char *p, unsigned char
static unsigned char *
gif_read_ce(fz_context *ctx, struct info *info, unsigned char *p, unsigned char *end)
{
- fz_try(ctx)
- {
- p = gif_read_subblocks(ctx, info, p + 2, end, NULL);
- }
- fz_catch(ctx)
- {
- fz_rethrow(ctx);
- }
-
- return p;
+ return gif_read_subblocks(ctx, info, p + 2, end, NULL);
}
static unsigned char*
@@ -323,17 +314,7 @@ gif_read_pte(fz_context *ctx, struct info *info, unsigned char *p, unsigned char
fz_throw(ctx, FZ_ERROR_GENERIC, "premature end in plain text extension in gif image");
if (p[2] != 0x0c)
fz_throw(ctx, FZ_ERROR_GENERIC, "out of range plain text extension block size in gif image");
-
- fz_try(ctx)
- {
- p = gif_read_subblocks(ctx, info, p + 15, end, NULL);
- }
- fz_catch(ctx)
- {
- fz_rethrow(ctx);
- }
-
- return p;
+ return gif_read_subblocks(ctx, info, p + 15, end, NULL);
}
/*
@@ -387,16 +368,7 @@ gif_read_ae(fz_context *ctx, struct info *info, unsigned char *p, unsigned char
fz_warn(ctx, "ignoring unsupported application extension '%s' in gif image", extension);
}
- fz_try(ctx)
- {
- p = gif_read_subblocks(ctx, info, p + 14, end, NULL);
- }
- fz_catch(ctx)
- {
- fz_rethrow(ctx);
- }
-
- return p;
+ return gif_read_subblocks(ctx, info, p + 14, end, NULL);
}
static void
diff --git a/source/fitz/load-tiff.c b/source/fitz/load-tiff.c
index 819ed7fd..2002c61a 100644
--- a/source/fitz/load-tiff.c
+++ b/source/fitz/load-tiff.c
@@ -939,21 +939,14 @@ fz_load_tiff_subimage_count(fz_context *ctx, unsigned char *buf, int len)
unsigned subimage_count = 0;
struct tiff tiff = { 0 };
- fz_try(ctx)
- {
- fz_decode_tiff_header(ctx, &tiff, buf, len);
+ fz_decode_tiff_header(ctx, &tiff, buf, len);
- offset = tiff.ifd_offset;
+ offset = tiff.ifd_offset;
- do {
- subimage_count++;
- offset = fz_next_ifd(ctx, &tiff, offset);
- } while (offset != 0);
- }
- fz_catch(ctx)
- {
- fz_rethrow(ctx);
- }
+ do {
+ subimage_count++;
+ offset = fz_next_ifd(ctx, &tiff, offset);
+ } while (offset != 0);
return subimage_count;
}
diff --git a/source/pdf/pdf-interpret.c b/source/pdf/pdf-interpret.c
index f037ae22..6ad384f3 100644
--- a/source/pdf/pdf-interpret.c
+++ b/source/pdf/pdf-interpret.c
@@ -1225,7 +1225,6 @@ pdf_process_contents(fz_context *ctx, pdf_processor *proc, pdf_document *doc, pd
}
fz_catch(ctx)
{
- fz_rethrow_if(ctx, FZ_ERROR_ABORT);
fz_rethrow(ctx);
}
}
@@ -1292,7 +1291,6 @@ pdf_process_glyph(fz_context *ctx, pdf_processor *proc, pdf_document *doc, pdf_o
}
fz_catch(ctx)
{
- fz_rethrow_if(ctx, FZ_ERROR_ABORT);
fz_rethrow(ctx);
}
}
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c
index c1f7fa0d..e6f39cfe 100644
--- a/source/pdf/pdf-xref.c
+++ b/source/pdf/pdf-xref.c
@@ -770,7 +770,6 @@ pdf_read_old_xref(fz_context *ctx, pdf_document *doc, pdf_lexbuf *buf)
pdf_token tok;
fz_off_t i;
int c;
- pdf_obj *trailer;
int xref_len = pdf_xref_size_from_old_trailer(ctx, doc, buf);
pdf_xref_entry *table;
@@ -831,23 +830,15 @@ pdf_read_old_xref(fz_context *ctx, pdf_document *doc, pdf_lexbuf *buf)
}
}
- fz_try(ctx)
- {
- tok = pdf_lex(ctx, file, buf);
- if (tok != PDF_TOK_TRAILER)
- fz_throw(ctx, FZ_ERROR_GENERIC, "expected trailer marker");
+ tok = pdf_lex(ctx, file, buf);
+ if (tok != PDF_TOK_TRAILER)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "expected trailer marker");
- tok = pdf_lex(ctx, file, buf);
- if (tok != PDF_TOK_OPEN_DICT)
- fz_throw(ctx, FZ_ERROR_GENERIC, "expected trailer dictionary");
+ tok = pdf_lex(ctx, file, buf);
+ if (tok != PDF_TOK_OPEN_DICT)
+ fz_throw(ctx, FZ_ERROR_GENERIC, "expected trailer dictionary");
- trailer = pdf_parse_dict(ctx, doc, file, buf);
- }
- fz_catch(ctx)
- {
- fz_rethrow(ctx);
- }
- return trailer;
+ return pdf_parse_dict(ctx, doc, file, buf);
}
static void
@@ -996,20 +987,14 @@ pdf_read_xref(fz_context *ctx, pdf_document *doc, fz_off_t ofs, pdf_lexbuf *buf)
while (iswhite(fz_peek_byte(ctx, doc->file)))
fz_read_byte(ctx, doc->file);
- fz_try(ctx)
- {
- c = fz_peek_byte(ctx, doc->file);
- if (c == 'x')
- trailer = pdf_read_old_xref(ctx, doc, buf);
- else if (c >= '0' && c <= '9')
- trailer = pdf_read_new_xref(ctx, doc, buf);
- else
- fz_throw(ctx, FZ_ERROR_GENERIC, "cannot recognize xref format");
- }
- fz_catch(ctx)
- {
- fz_rethrow(ctx);
- }
+ c = fz_peek_byte(ctx, doc->file);
+ if (c == 'x')
+ trailer = pdf_read_old_xref(ctx, doc, buf);
+ else if (c >= '0' && c <= '9')
+ trailer = pdf_read_new_xref(ctx, doc, buf);
+ else
+ fz_throw(ctx, FZ_ERROR_GENERIC, "cannot recognize xref format");
+
return trailer;
}
@@ -2070,14 +2055,7 @@ object_updated:
{
if (!x->obj)
{
- fz_try(ctx)
- {
- x = pdf_load_obj_stm(ctx, doc, x->ofs, 0, &doc->lexbuf.base, num);
- }
- fz_catch(ctx)
- {
- fz_rethrow(ctx);
- }
+ x = pdf_load_obj_stm(ctx, doc, x->ofs, 0, &doc->lexbuf.base, num);
if (x == NULL)
fz_throw(ctx, FZ_ERROR_GENERIC, "cannot load object stream containing object (%d %d R)", num, gen);
if (!x->obj)