summaryrefslogtreecommitdiff
path: root/source/pdf
diff options
context:
space:
mode:
authorSimon Bünzli <zeniko@gmail.com>2014-01-02 21:27:15 +0100
committerRobin Watts <robin.watts@artifex.com>2014-01-06 13:13:35 +0000
commit9b92bac1ec135862132b1c49b977b53891b73d88 (patch)
treedfd5faac92aa678cc5c8b23ae626d347b9d17494 /source/pdf
parentf6fe26922653b45519d406bd07840719cef1d979 (diff)
downloadmupdf-9b92bac1ec135862132b1c49b977b53891b73d88.tar.xz
fix various MSVC warnings
Some warnings we'd like to enable for MuPDF and still be able to compile it with warnings as errors using MSVC (2008 to 2013): * C4115: 'timeval' : named type definition in parentheses * C4204: nonstandard extension used : non-constant aggregate initializer * C4295: 'hex' : array is too small to include a terminating null character * C4389: '==' : signed/unsigned mismatch * C4702: unreachable code * C4706: assignment within conditional expression Also, globally disable C4701 which is frequently caused by MSVC not being able to correctly figure out fz_try/fz_catch code flow. And don't define isnan for VS2013 and later where that's no longer needed.
Diffstat (limited to 'source/pdf')
-rw-r--r--source/pdf/pdf-cmap-load.c2
-rw-r--r--source/pdf/pdf-colorspace.c4
-rw-r--r--source/pdf/pdf-font.c11
-rw-r--r--source/pdf/pdf-form.c2
-rw-r--r--source/pdf/pdf-function.c2
-rw-r--r--source/pdf/pdf-image.c2
-rw-r--r--source/pdf/pdf-outline.c4
-rw-r--r--source/pdf/pdf-parse.c1
-rw-r--r--source/pdf/pdf-pattern.c2
-rw-r--r--source/pdf/pdf-shade.c2
-rw-r--r--source/pdf/pdf-write.c2
-rw-r--r--source/pdf/pdf-xobject.c2
12 files changed, 15 insertions, 21 deletions
diff --git a/source/pdf/pdf-cmap-load.c b/source/pdf/pdf-cmap-load.c
index 4ac7208b..08c4a80a 100644
--- a/source/pdf/pdf-cmap-load.c
+++ b/source/pdf/pdf-cmap-load.c
@@ -33,7 +33,7 @@ pdf_load_embedded_cmap(pdf_document *doc, pdf_obj *stmobj)
if (pdf_obj_marked(stmobj))
fz_throw(ctx, FZ_ERROR_GENERIC, "Recursion in embedded cmap");
- if ((cmap = pdf_find_item(ctx, pdf_free_cmap_imp, stmobj)))
+ if ((cmap = pdf_find_item(ctx, pdf_free_cmap_imp, stmobj)) != NULL)
{
return cmap;
}
diff --git a/source/pdf/pdf-colorspace.c b/source/pdf/pdf-colorspace.c
index 611a187b..5fd569c3 100644
--- a/source/pdf/pdf-colorspace.c
+++ b/source/pdf/pdf-colorspace.c
@@ -42,7 +42,6 @@ load_icc_based(pdf_document *doc, pdf_obj *dict)
}
fz_throw(ctx, FZ_ERROR_GENERIC, "syntaxerror: ICCBased must have 1, 3 or 4 components");
- return NULL; /* Stupid MSVC */
}
/* Lab */
@@ -350,7 +349,6 @@ pdf_load_colorspace_imp(pdf_document *doc, pdf_obj *obj)
}
fz_throw(doc->ctx, FZ_ERROR_GENERIC, "syntaxerror: could not parse color space (%d %d R)", pdf_to_num(obj), pdf_to_gen(obj));
- return NULL; /* Stupid MSVC */
}
fz_colorspace *
@@ -359,7 +357,7 @@ pdf_load_colorspace(pdf_document *doc, pdf_obj *obj)
fz_context *ctx = doc->ctx;
fz_colorspace *cs;
- if ((cs = pdf_find_item(ctx, fz_free_colorspace_imp, obj)))
+ if ((cs = pdf_find_item(ctx, fz_free_colorspace_imp, obj)) != NULL)
{
return cs;
}
diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c
index 0d387151..efb1eee6 100644
--- a/source/pdf/pdf-font.c
+++ b/source/pdf/pdf-font.c
@@ -821,7 +821,7 @@ pdf_load_hail_mary_font(pdf_document *doc)
pdf_font_desc *fontdesc;
pdf_font_desc *existing;
- if ((fontdesc = fz_find_item(ctx, pdf_free_font_imp, &hail_mary_store_type, &hail_mary_store_type)))
+ if ((fontdesc = fz_find_item(ctx, pdf_free_font_imp, &hail_mary_store_type, &hail_mary_store_type)) != NULL)
{
return fontdesc;
}
@@ -1101,12 +1101,9 @@ pdf_load_type0_font(pdf_document *doc, pdf_obj *dict)
if (pdf_is_name(subtype) && !strcmp(pdf_to_name(subtype), "CIDFontType0"))
return load_cid_font(doc, dfont, encoding, to_unicode);
- else if (pdf_is_name(subtype) && !strcmp(pdf_to_name(subtype), "CIDFontType2"))
+ if (pdf_is_name(subtype) && !strcmp(pdf_to_name(subtype), "CIDFontType2"))
return load_cid_font(doc, dfont, encoding, to_unicode);
- else
- fz_throw(doc->ctx, FZ_ERROR_GENERIC, "syntaxerror: unknown cid font type");
-
- return NULL; /* Stupid MSVC */
+ fz_throw(doc->ctx, FZ_ERROR_GENERIC, "syntaxerror: unknown cid font type");
}
/*
@@ -1224,7 +1221,7 @@ pdf_load_font(pdf_document *doc, pdf_obj *rdb, pdf_obj *dict, int nested_depth)
pdf_font_desc *fontdesc;
int type3 = 0;
- if ((fontdesc = pdf_find_item(ctx, pdf_free_font_imp, dict)))
+ if ((fontdesc = pdf_find_item(ctx, pdf_free_font_imp, dict)) != NULL)
{
return fontdesc;
}
diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c
index 2b48abec..a6ea16c3 100644
--- a/source/pdf/pdf-form.c
+++ b/source/pdf/pdf-form.c
@@ -137,7 +137,7 @@ static pdf_obj *find_field(pdf_obj *dict, char *name, int len)
field = pdf_array_get(dict, i);
part = pdf_to_str_buf(pdf_dict_gets(field, "T"));
- if (strlen(part) == len && !memcmp(part, name, len))
+ if (strlen(part) == (size_t)len && !memcmp(part, name, len))
return field;
}
diff --git a/source/pdf/pdf-function.c b/source/pdf/pdf-function.c
index 510e36cf..b18ccf17 100644
--- a/source/pdf/pdf-function.c
+++ b/source/pdf/pdf-function.c
@@ -1626,7 +1626,7 @@ pdf_load_function(pdf_document *doc, pdf_obj *dict, int in, int out)
if (pdf_obj_marked(dict))
fz_throw(ctx, FZ_ERROR_GENERIC, "Recursion in function definition");
- if ((func = pdf_find_item(ctx, pdf_free_function_imp, dict)))
+ if ((func = pdf_find_item(ctx, pdf_free_function_imp, dict)) != NULL)
{
return (fz_function *)func;
}
diff --git a/source/pdf/pdf-image.c b/source/pdf/pdf-image.c
index b22f39fb..ef7f94ad 100644
--- a/source/pdf/pdf-image.c
+++ b/source/pdf/pdf-image.c
@@ -268,7 +268,7 @@ pdf_load_image(pdf_document *doc, pdf_obj *dict)
fz_context *ctx = doc->ctx;
fz_image *image;
- if ((image = pdf_find_item(ctx, fz_free_image, dict)))
+ if ((image = pdf_find_item(ctx, fz_free_image, dict)) != NULL)
{
return (fz_image *)image;
}
diff --git a/source/pdf/pdf-outline.c b/source/pdf/pdf-outline.c
index 1e01b692..44273dda 100644
--- a/source/pdf/pdf-outline.c
+++ b/source/pdf/pdf-outline.c
@@ -31,9 +31,9 @@ pdf_load_outline_imp(pdf_document *doc, pdf_obj *dict)
if (obj)
node->title = pdf_to_utf8(doc, obj);
- if ((obj = pdf_dict_gets(dict, "Dest")))
+ if ((obj = pdf_dict_gets(dict, "Dest")) != NULL)
node->dest = pdf_parse_link_dest(doc, FZ_LINK_GOTO, obj);
- else if ((obj = pdf_dict_gets(dict, "A")))
+ else if ((obj = pdf_dict_gets(dict, "A")) != NULL)
node->dest = pdf_parse_action(doc, obj);
obj = pdf_dict_gets(dict, "First");
diff --git a/source/pdf/pdf-parse.c b/source/pdf/pdf-parse.c
index 66e0fbe7..a2fd09db 100644
--- a/source/pdf/pdf-parse.c
+++ b/source/pdf/pdf-parse.c
@@ -490,7 +490,6 @@ pdf_parse_stm_obj(pdf_document *doc, fz_stream *file, pdf_lexbuf *buf)
case PDF_TOK_INT: return pdf_new_int(doc, buf->i); break;
default: fz_throw(ctx, FZ_ERROR_GENERIC, "unknown token in object stream");
}
- return NULL; /* Stupid MSVC */
}
pdf_obj *
diff --git a/source/pdf/pdf-pattern.c b/source/pdf/pdf-pattern.c
index 89e7f94f..f13a49c9 100644
--- a/source/pdf/pdf-pattern.c
+++ b/source/pdf/pdf-pattern.c
@@ -39,7 +39,7 @@ pdf_load_pattern(pdf_document *doc, pdf_obj *dict)
pdf_obj *obj;
fz_context *ctx = doc->ctx;
- if ((pat = pdf_find_item(ctx, pdf_free_pattern_imp, dict)))
+ if ((pat = pdf_find_item(ctx, pdf_free_pattern_imp, dict)) != NULL)
{
return pat;
}
diff --git a/source/pdf/pdf-shade.c b/source/pdf/pdf-shade.c
index afeab247..40728dc7 100644
--- a/source/pdf/pdf-shade.c
+++ b/source/pdf/pdf-shade.c
@@ -456,7 +456,7 @@ pdf_load_shading(pdf_document *doc, pdf_obj *dict)
fz_context *ctx = doc->ctx;
fz_shade *shade;
- if ((shade = pdf_find_item(ctx, fz_free_shade_imp, dict)))
+ if ((shade = pdf_find_item(ctx, fz_free_shade_imp, dict)) != NULL)
{
return shade;
}
diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c
index 42316da1..df432c21 100644
--- a/source/pdf/pdf-write.c
+++ b/source/pdf/pdf-write.c
@@ -1464,7 +1464,7 @@ static int isbinarystream(fz_buffer *buf)
static fz_buffer *hexbuf(fz_context *ctx, unsigned char *p, int n)
{
- static const char hex[16] = "0123456789abcdef";
+ static const char hex[17] = "0123456789abcdef";
fz_buffer *buf;
int x = 0;
diff --git a/source/pdf/pdf-xobject.c b/source/pdf/pdf-xobject.c
index 648f8d29..c4259466 100644
--- a/source/pdf/pdf-xobject.c
+++ b/source/pdf/pdf-xobject.c
@@ -40,7 +40,7 @@ pdf_load_xobject(pdf_document *doc, pdf_obj *dict)
pdf_obj *obj;
fz_context *ctx = doc->ctx;
- if ((form = pdf_find_item(ctx, pdf_free_xobject_imp, dict)))
+ if ((form = pdf_find_item(ctx, pdf_free_xobject_imp, dict)) != NULL)
{
return form;
}