summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Rasmussen <sebras@gmail.com>2018-05-23 23:12:43 +0800
committerSebastian Rasmussen <sebras@gmail.com>2018-07-13 16:54:30 +0800
commit1e751b882e18fee36a16488e7b46c0e1b571d605 (patch)
treefb4fa64dbfc1e57a17f80c8fd0ed027d5dcf3642
parentc159c4534b9b9af4998d6dcdee896fe2197fa542 (diff)
downloadghostpdl-1e751b882e18fee36a16488e7b46c0e1b571d605.tar.gz
jbig2dec: Return jbig2_error(WARNING); they indicate errors.
Because jbig2_error(ctx, JBIG2_SEVERITY_WARNING, ...) now returns -1, it can be immediately returned or assigned as a return code.
-rw-r--r--jbig2dec/jbig2_generic.c3
-rw-r--r--jbig2dec/jbig2_halftone.c25
-rw-r--r--jbig2dec/jbig2_metadata.c15
-rw-r--r--jbig2dec/jbig2_mmr.c12
-rw-r--r--jbig2dec/jbig2_page.c12
-rw-r--r--jbig2dec/jbig2_symbol_dict.c2
-rw-r--r--jbig2dec/jbig2_text.c6
7 files changed, 25 insertions, 50 deletions
diff --git a/jbig2dec/jbig2_generic.c b/jbig2dec/jbig2_generic.c
index b98e0f4da..44d16d5c6 100644
--- a/jbig2dec/jbig2_generic.c
+++ b/jbig2dec/jbig2_generic.c
@@ -746,8 +746,7 @@ jbig2_decode_generic_region(Jbig2Ctx *ctx,
for (i = 0; i < 8; i++)
jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number, "gbat[%d] = %d", i, params->gbat[i]);
}
- jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "decode_generic_region: MMR=%d, GBTEMPLATE=%d NYI", params->MMR, params->GBTEMPLATE);
- return -1;
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "decode_generic_region: MMR=%d, GBTEMPLATE=%d NYI", params->MMR, params->GBTEMPLATE);
}
/**
diff --git a/jbig2dec/jbig2_halftone.c b/jbig2dec/jbig2_halftone.c
index a6202657f..c30fed176 100644
--- a/jbig2dec/jbig2_halftone.c
+++ b/jbig2dec/jbig2_halftone.c
@@ -221,10 +221,8 @@ jbig2_pattern_dictionary(Jbig2Ctx *ctx, Jbig2Segment *segment, const byte *segme
int stats_size = jbig2_generic_stats_size(ctx, params.HDTEMPLATE);
GB_stats = jbig2_new(ctx, Jbig2ArithCx, stats_size);
- if (GB_stats == NULL) {
- jbig2_error(ctx, JBIG2_SEVERITY_FATAL, segment->number, "failed to allocate GB_stats in pattern dictionary");
- return 0;
- }
+ if (GB_stats == NULL)
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "failed to allocate GB_stats in pattern dictionary");
memset(GB_stats, 0, stats_size);
}
@@ -476,10 +474,8 @@ jbig2_decode_halftone_region(Jbig2Ctx *ctx, Jbig2Segment *segment,
* get it from referred pattern dictionary */
HPATS = jbig2_decode_ht_region_get_hpats(ctx, segment);
- if (!HPATS) {
- jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "no pattern dictionary found, skipping halftone image");
- return -1;
- }
+ if (!HPATS)
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "no pattern dictionary found, skipping halftone image");
HNUMPATS = HPATS->n_patterns;
/* calculate ceil(log2(HNUMPATS)) */
@@ -489,11 +485,8 @@ jbig2_decode_halftone_region(Jbig2Ctx *ctx, Jbig2Segment *segment,
/* 6.6.5 point 4. decode gray-scale image as mentioned in annex C */
GI = jbig2_decode_gray_scale_image(ctx, segment, data, size,
params->HMMR, params->HGW, params->HGH, HBPP, params->HENABLESKIP, HSKIP, params->HTEMPLATE, GB_stats);
-
- if (!GI) {
- jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "unable to acquire gray-scale image, skipping halftone image");
- return -1;
- }
+ if (!GI)
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "unable to acquire gray-scale image, skipping halftone image");
/* 6.6.5 point 5. place patterns with procedure mentioned in 6.6.5.2 */
for (mg = 0; mg < params->HGH; ++mg) {
@@ -509,10 +502,8 @@ jbig2_decode_halftone_region(Jbig2Ctx *ctx, Jbig2Segment *segment,
gray_val = HNUMPATS - 1;
}
code = jbig2_image_compose(ctx, image, HPATS->patterns[gray_val], x, y, params->op);
- if (code < 0) {
- jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "failed to compose pattern with gray-scale image");
- return -1;
- }
+ if (code < 0)
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "failed to compose pattern with gray-scale image");
}
}
diff --git a/jbig2dec/jbig2_metadata.c b/jbig2dec/jbig2_metadata.c
index 3bc842508..01860819f 100644
--- a/jbig2dec/jbig2_metadata.c
+++ b/jbig2dec/jbig2_metadata.c
@@ -110,8 +110,7 @@ jbig2_metadata_add(Jbig2Ctx *ctx, Jbig2Metadata *md, const char *key, const int
md->keys[md->entries] = jbig2_strndup(ctx, key, key_length);
md->values[md->entries] = jbig2_strndup(ctx, value, value_length);
if (md->keys[md->entries] == NULL || md->values[md->entries] == NULL) {
- jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "unable to accommodate more metadata");
- return -1;
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "unable to accommodate more metadata");
}
md->entries++;
@@ -131,10 +130,8 @@ jbig2_comment_ascii(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment
jbig2_error(ctx, JBIG2_SEVERITY_INFO, segment->number, "ASCII comment data");
comment = jbig2_metadata_new(ctx, JBIG2_ENCODING_ASCII);
- if (comment == NULL) {
- jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "unable to allocate comment structure");
- return -1;
- }
+ if (comment == NULL)
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "unable to allocate comment structure");
/* loop over the segment data pulling out the key,value pairs */
while (s < end && *s) {
key = s;
@@ -147,10 +144,8 @@ jbig2_comment_ascii(Jbig2Ctx *ctx, Jbig2Segment *segment, const uint8_t *segment
goto too_short;
s++;
code = jbig2_metadata_add(ctx, comment, key, value - key, value, s - value);
- if (code < 0) {
- jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "unable to add ascii comment data");
- return -1;
- }
+ if (code < 0)
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "unable to add ascii comment data");
jbig2_error(ctx, JBIG2_SEVERITY_INFO, segment->number, "'%s'\t'%s'", key, value);
}
diff --git a/jbig2dec/jbig2_mmr.c b/jbig2dec/jbig2_mmr.c
index e2d8e957d..0b4a7150e 100644
--- a/jbig2dec/jbig2_mmr.c
+++ b/jbig2dec/jbig2_mmr.c
@@ -1022,10 +1022,8 @@ jbig2_decode_generic_mmr(Jbig2Ctx *ctx, Jbig2Segment *segment, const Jbig2Generi
for (y = 0; y < image->height; y++) {
memset(dst, 0, rowstride);
code = jbig2_decode_mmr_line(ctx, &mmr, ref, dst);
- if (code < 0) {
- jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "failed to decode mmr line");
- return code;
- }
+ if (code < 0)
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "failed to decode mmr line");
ref = dst;
dst += rowstride;
}
@@ -1063,10 +1061,8 @@ jbig2_decode_halftone_mmr(Jbig2Ctx *ctx, const Jbig2GenericRegionParams *params,
for (y = 0; y < image->height; y++) {
memset(dst, 0, rowstride);
code = jbig2_decode_mmr_line(ctx, &mmr, ref, dst);
- if (code < 0) {
- jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "failed to decode halftone mmr line");
- return code;
- }
+ if (code < 0)
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "failed to decode halftone mmr line");
ref = dst;
dst += rowstride;
}
diff --git a/jbig2dec/jbig2_page.c b/jbig2dec/jbig2_page.c
index 0f1b2f2bd..26695b825 100644
--- a/jbig2dec/jbig2_page.c
+++ b/jbig2dec/jbig2_page.c
@@ -257,10 +257,8 @@ jbig2_page_add_result(Jbig2Ctx *ctx, Jbig2Page *page, Jbig2Image *image, int x,
int code;
/* ensure image exists first */
- if (page->image == NULL) {
- jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "page info possibly missing, no image defined");
- return 0;
- }
+ if (page->image == NULL)
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "page info possibly missing, no image defined");
/* grow the page to accommodate a new stripe if necessary */
if (page->striped && page->height == 0xFFFFFFFF) {
@@ -279,10 +277,8 @@ jbig2_page_add_result(Jbig2Ctx *ctx, Jbig2Page *page, Jbig2Image *image, int x,
}
code = jbig2_image_compose(ctx, page->image, image, x, y + page->end_row, op);
- if (code < 0) {
- jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "failed to compose image with page");
- return -1;
- }
+ if (code < 0)
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, -1, "failed to compose image with page");
return 0;
}
diff --git a/jbig2dec/jbig2_symbol_dict.c b/jbig2dec/jbig2_symbol_dict.c
index 67e245774..abd612ca8 100644
--- a/jbig2dec/jbig2_symbol_dict.c
+++ b/jbig2dec/jbig2_symbol_dict.c
@@ -86,7 +86,7 @@ jbig2_dump_symbol_dict(Jbig2Ctx *ctx, Jbig2Segment *segment)
code = jbig2_image_write_pbm_file(dict->glyphs[index], filename);
#endif
if (code < 0)
- jbig2_error(ctx, JBIG2_SEVERITY_INFO, segment->number, "failed to dump symbol %d/%d as '%s'", index, dict->n_symbols, filename);
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "failed to dump symbol %d/%d as '%s'", index, dict->n_symbols, filename);
}
}
#endif /* DUMP_SYMDICT */
diff --git a/jbig2dec/jbig2_text.c b/jbig2dec/jbig2_text.c
index c3dc0090e..efdbe84a0 100644
--- a/jbig2dec/jbig2_text.c
+++ b/jbig2dec/jbig2_text.c
@@ -98,10 +98,8 @@ jbig2_decode_text_region(Jbig2Ctx *ctx, Jbig2Segment *segment,
jbig2_error(ctx, JBIG2_SEVERITY_DEBUG, segment->number, "huffman coded text region");
hs = jbig2_huffman_new(ctx, ws);
- if (hs == NULL) {
- jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "failed to allocate storage for text region");
- return -1;
- }
+ if (hs == NULL)
+ return jbig2_error(ctx, JBIG2_SEVERITY_WARNING, segment->number, "failed to allocate storage for text region");
/* 7.4.3.1.7 - decode symbol ID Huffman table */
/* this is actually part of the segment header, but it is more