summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-11-02 20:02:40 +0000
committerRobin Watts <robin.watts@artifex.com>2016-11-03 18:10:50 +0000
commit6e2a71d0b743c105c71f88a7ed1de0851cdd90ca (patch)
tree8bd6d452d6b4686f509e6478edf13f267621d6f3
parent0289421f68b810cee600a5a047507091ff4731df (diff)
downloadmupdf-6e2a71d0b743c105c71f88a7ed1de0851cdd90ca.tar.xz
Fix signed/unsigned and size_t/int/fz_off_t warnings.
All seen in MSVC, mostly in 64bit builds.
-rw-r--r--source/fitz/filter-basic.c8
-rw-r--r--source/fitz/load-pnm.c6
-rw-r--r--source/fitz/load-tiff.c10
-rw-r--r--source/fitz/output.c2
-rw-r--r--source/fitz/stream-open.c6
-rw-r--r--source/fitz/stream-prog.c2
-rw-r--r--source/fitz/unzip.c2
-rw-r--r--source/html/epub-doc.c2
-rw-r--r--source/html/html-layout.c2
-rw-r--r--source/pdf/pdf-form.c7
-rw-r--r--source/pdf/pdf-repair.c2
-rw-r--r--source/pdf/pdf-xref.c6
-rw-r--r--source/tools/muraster.c4
13 files changed, 30 insertions, 29 deletions
diff --git a/source/fitz/filter-basic.c b/source/fitz/filter-basic.c
index 0211442c..0bc5525a 100644
--- a/source/fitz/filter-basic.c
+++ b/source/fitz/filter-basic.c
@@ -39,8 +39,8 @@ next_null(fz_context *ctx, fz_stream *stm, size_t max)
return EOF;
state->chain->rp += n;
state->remain -= n;
- state->offset += n;
- stm->pos += n;
+ state->offset += (fz_off_t)n;
+ stm->pos += (fz_off_t)n;
return *stm->rp++;
}
@@ -104,7 +104,7 @@ next_concat(fz_context *ctx, fz_stream *stm, size_t max)
{
stm->rp = state->chain[state->current]->rp;
stm->wp = state->chain[state->current]->wp;
- stm->pos += n;
+ stm->pos += (fz_off_t)n;
return *stm->rp++;
}
else
@@ -576,7 +576,7 @@ next_arc4(fz_context *ctx, fz_stream *stm, size_t max)
stm->wp = state->buffer + n;
fz_arc4_encrypt(&state->arc4, stm->rp, state->chain->rp, n);
state->chain->rp += n;
- stm->pos += n;
+ stm->pos += (fz_off_t)n;
return *stm->rp++;
}
diff --git a/source/fitz/load-pnm.c b/source/fitz/load-pnm.c
index 1bb5098b..4c827e43 100644
--- a/source/fitz/load-pnm.c
+++ b/source/fitz/load-pnm.c
@@ -253,7 +253,7 @@ pnm_ascii_read_image(fz_context *ctx, struct info *pnm, unsigned char *p, unsign
fz_throw(ctx, FZ_ERROR_GENERIC, "image height must be > 0");
if (pnm->width <= 0)
fz_throw(ctx, FZ_ERROR_GENERIC, "image width must be > 0");
- if (pnm->height > UINT_MAX / pnm->width / fz_colorspace_n(ctx, pnm->cs) / (pnm->bitdepth / 8 + 1))
+ if ((unsigned int)pnm->height > UINT_MAX / pnm->width / fz_colorspace_n(ctx, pnm->cs) / (pnm->bitdepth / 8 + 1))
fz_throw(ctx, FZ_ERROR_GENERIC, "image too large");
if (!onlymeta)
@@ -332,7 +332,7 @@ pnm_binary_read_image(fz_context *ctx, struct info *pnm, unsigned char *p, unsig
fz_throw(ctx, FZ_ERROR_GENERIC, "image height must be > 0");
if (pnm->width <= 0)
fz_throw(ctx, FZ_ERROR_GENERIC, "image width must be > 0");
- if (pnm->height > UINT_MAX / pnm->width / fz_colorspace_n(ctx, pnm->cs) / (pnm->bitdepth / 8 + 1))
+ if ((unsigned int)pnm->height > UINT_MAX / pnm->width / fz_colorspace_n(ctx, pnm->cs) / (pnm->bitdepth / 8 + 1))
fz_throw(ctx, FZ_ERROR_GENERIC, "image too large");
if (!onlymeta)
@@ -494,7 +494,7 @@ pam_binary_read_image(fz_context *ctx, struct info *pnm, unsigned char *p, unsig
fz_throw(ctx, FZ_ERROR_GENERIC, "image height must be > 0");
if (pnm->width <= 0)
fz_throw(ctx, FZ_ERROR_GENERIC, "image width must be > 0");
- if (pnm->height > UINT_MAX / pnm->width / fz_colorspace_n(ctx, pnm->cs) / (pnm->bitdepth / 8 + 1))
+ if ((unsigned int)pnm->height > UINT_MAX / pnm->width / fz_colorspace_n(ctx, pnm->cs) / (pnm->bitdepth / 8 + 1))
fz_throw(ctx, FZ_ERROR_GENERIC, "image too large");
if (!onlymeta)
diff --git a/source/fitz/load-tiff.c b/source/fitz/load-tiff.c
index a2c081ca..60b0e8a6 100644
--- a/source/fitz/load-tiff.c
+++ b/source/fitz/load-tiff.c
@@ -377,7 +377,7 @@ tiff_decode_data(fz_context *ctx, struct tiff *tiff, unsigned char *rp, unsigned
fz_throw(ctx, FZ_ERROR_GENERIC, "unknown TIFF compression: %d", tiff->compression);
}
- size = fz_read(ctx, stm, wp, wlen);
+ size = (unsigned)fz_read(ctx, stm, wp, wlen);
}
fz_always(ctx)
{
@@ -471,8 +471,8 @@ tiff_paste_subsampled_tile(fz_context *ctx, struct tiff *tiff, unsigned char *ti
unsigned char *src = tile;
unsigned char *dst;
- int x, y, w, h; /* coordinates and dimensions of entire image */
- int sx, sy, sw, sh; /* coordinates and dimensions of a single subsample region, i.e. max 4 x 4 samples */
+ unsigned x, y, w, h; /* coordinates and dimensions of entire image */
+ unsigned sx, sy, sw, sh; /* coordinates and dimensions of a single subsample region, i.e. max 4 x 4 samples */
int k;
int offsets[4 * 4 * 3]; /* for a pixel position, these point to all pixel components in a subsample region */
int *offset = offsets;
@@ -583,7 +583,7 @@ tiff_decode_tiles(fz_context *ctx, struct tiff *tiff)
unsigned int offset = tiff->tileoffsets[tile];
unsigned int rlen = tiff->tilebytecounts[tile];
unsigned char *rp = tiff->bp + offset;
- int decoded;
+ unsigned decoded;
if (offset > (unsigned)(tiff->ep - tiff->bp))
fz_throw(ctx, FZ_ERROR_GENERIC, "invalid tile offset %u", offset);
@@ -1035,7 +1035,7 @@ tiff_read_ifd(fz_context *ctx, struct tiff *tiff)
static void
tiff_ycc_to_rgb(fz_context *ctx, struct tiff *tiff)
{
- int x, y;
+ unsigned x, y;
for (y = 0; y < tiff->imagelength; y++)
{
diff --git a/source/fitz/output.c b/source/fitz/output.c
index ee3f5b6f..3133116c 100644
--- a/source/fitz/output.c
+++ b/source/fitz/output.c
@@ -193,7 +193,7 @@ static fz_off_t
buffer_tell(fz_context *ctx, void *opaque)
{
fz_buffer *buffer = opaque;
- return buffer->len;
+ return (fz_off_t)buffer->len;
}
static void
diff --git a/source/fitz/stream-open.c b/source/fitz/stream-open.c
index cb80b4f3..e70fc0e9 100644
--- a/source/fitz/stream-open.c
+++ b/source/fitz/stream-open.c
@@ -78,7 +78,7 @@ static int next_file(fz_context *ctx, fz_stream *stm, size_t n)
fz_throw(ctx, FZ_ERROR_GENERIC, "read error: %s", strerror(errno));
stm->rp = state->buffer;
stm->wp = state->buffer + n;
- stm->pos += n;
+ stm->pos += (fz_off_t)n;
if (n == 0)
return EOF;
@@ -206,7 +206,7 @@ fz_open_buffer(fz_context *ctx, fz_buffer *buf)
stm->rp = buf->data;
stm->wp = buf->data + buf->len;
- stm->pos = buf->len;
+ stm->pos = (fz_off_t)buf->len;
return stm;
}
@@ -222,7 +222,7 @@ fz_open_memory(fz_context *ctx, unsigned char *data, size_t len)
stm->rp = data;
stm->wp = data + len;
- stm->pos = len;
+ stm->pos = (fz_off_t)len;
return stm;
}
diff --git a/source/fitz/stream-prog.c b/source/fitz/stream-prog.c
index 042df96f..7aa4b339 100644
--- a/source/fitz/stream-prog.c
+++ b/source/fitz/stream-prog.c
@@ -43,7 +43,7 @@ static int next_prog(fz_context *ctx, fz_stream *stm, size_t len)
fz_throw(ctx, FZ_ERROR_GENERIC, "read error: %s", strerror(errno));
stm->rp = ps->buffer + stm->pos;
stm->wp = ps->buffer + stm->pos + n;
- stm->pos += n;
+ stm->pos += (fz_off_t)n;
if (n == 0)
return EOF;
return *stm->rp++;
diff --git a/source/fitz/unzip.c b/source/fitz/unzip.c
index cb9ccc40..491322fd 100644
--- a/source/fitz/unzip.c
+++ b/source/fitz/unzip.c
@@ -232,7 +232,7 @@ static void ensure_zip_entries(fz_context *ctx, fz_zip_archive *zip)
while (back < maxback)
{
- fz_seek(ctx, file, size - back, 0);
+ fz_seek(ctx, file, (fz_off_t)(size - back), 0);
n = fz_read(ctx, file, buf, sizeof buf);
if (n < 4)
break;
diff --git a/source/html/epub-doc.c b/source/html/epub-doc.c
index 7b44107b..a30fbcd3 100644
--- a/source/html/epub-doc.c
+++ b/source/html/epub-doc.c
@@ -41,7 +41,7 @@ epub_resolve_link(fz_context *ctx, fz_document *doc_, const char *dest)
epub_chapter *ch;
const char *s = strchr(dest, '#');
- int n = s ? s - dest : strlen(dest);
+ size_t n = s ? s - dest : strlen(dest);
if (s && s[1] == 0)
s = NULL;
diff --git a/source/html/html-layout.c b/source/html/html-layout.c
index e57aac68..8b7a08db 100644
--- a/source/html/html-layout.c
+++ b/source/html/html-layout.c
@@ -938,7 +938,7 @@ static int walk_string(string_walker *walker)
if (walker->language)
{
fz_string_from_text_language(lang, walker->language);
- hb_buffer_set_language(walker->hb_buf, hb_language_from_string(lang, strlen(lang)));
+ hb_buffer_set_language(walker->hb_buf, hb_language_from_string(lang, (int)strlen(lang)));
}
/* hb_buffer_set_cluster_level(hb_buf, HB_BUFFER_CLUSTER_LEVEL_CHARACTERS); */
diff --git a/source/pdf/pdf-form.c b/source/pdf/pdf-form.c
index 4fbccfa2..f4c5278c 100644
--- a/source/pdf/pdf-form.c
+++ b/source/pdf/pdf-form.c
@@ -1083,6 +1083,7 @@ void pdf_field_set_text_color(fz_context *ctx, pdf_document *doc, pdf_obj *field
fz_buffer *fzbuf = NULL;
char *da = pdf_to_str_buf(ctx, pdf_get_inheritable(ctx, doc, field, PDF_NAME_DA));
unsigned char *buf;
+ int ilen;
size_t len;
pdf_obj *daobj = NULL;
@@ -1093,13 +1094,13 @@ void pdf_field_set_text_color(fz_context *ctx, pdf_document *doc, pdf_obj *field
fz_var(daobj);
fz_try(ctx)
{
- size_t i;
+ int i;
pdf_parse_da(ctx, da, &di);
di.col_size = pdf_array_len(ctx, col);
- len = fz_mini(di.col_size, (int)nelem(di.col));
- for (i = 0; i < len; i++)
+ ilen = fz_mini(di.col_size, (int)nelem(di.col));
+ for (i = 0; i < ilen; i++)
di.col[i] = pdf_to_real(ctx, pdf_array_get(ctx, col, i));
fzbuf = fz_new_buffer(ctx, 0);
diff --git a/source/pdf/pdf-repair.c b/source/pdf/pdf-repair.c
index 167f6097..04c968b3 100644
--- a/source/pdf/pdf-repair.c
+++ b/source/pdf/pdf-repair.c
@@ -346,7 +346,7 @@ pdf_repair_xref(fz_context *ctx, pdf_document *doc)
{
if (memcmp(&buf->scratch[j], "%PDF", 4) == 0)
{
- fz_seek(ctx, doc->file, j + 8, 0); /* skip "%PDF-X.Y" */
+ fz_seek(ctx, doc->file, (fz_off_t)(j + 8), 0); /* skip "%PDF-X.Y" */
break;
}
}
diff --git a/source/pdf/pdf-xref.c b/source/pdf/pdf-xref.c
index 2c964e90..41dd9984 100644
--- a/source/pdf/pdf-xref.c
+++ b/source/pdf/pdf-xref.c
@@ -635,7 +635,7 @@ pdf_xref_size_from_old_trailer(fz_context *ctx, pdf_document *doc, pdf_lexbuf *b
int size;
fz_off_t ofs;
pdf_obj *trailer = NULL;
- int n;
+ size_t n;
fz_var(trailer);
@@ -683,10 +683,10 @@ pdf_xref_size_from_old_trailer(fz_context *ctx, pdf_document *doc, pdf_lexbuf *b
else
n = 20;
- if (len > (FZ_OFF_MAX - t) / n)
+ if (len > (fz_off_t)((FZ_OFF_MAX - t) / n))
fz_throw(ctx, FZ_ERROR_GENERIC, "xref has too many entries");
- fz_seek(ctx, doc->file, t + n * len, SEEK_SET);
+ fz_seek(ctx, doc->file, (fz_off_t)(t + n * len), SEEK_SET);
}
fz_try(ctx)
diff --git a/source/tools/muraster.c b/source/tools/muraster.c
index a85475e8..f08de504 100644
--- a/source/tools/muraster.c
+++ b/source/tools/muraster.c
@@ -558,7 +558,7 @@ static int alphabits_text = 8;
static int alphabits_graphics = 8;
static int min_band_height;
-static int max_band_memory;
+static size_t max_band_memory;
int band_height;
static int errored = 0;
@@ -1143,7 +1143,7 @@ initialise_banding(fz_context *ctx, render_details *render, int color)
w = render->ibounds.x1 - render->ibounds.x0;
min_band_mem = bpp * w * min_band_height;
- reps = max_band_memory / min_band_mem;
+ reps = (int)(max_band_memory / min_band_mem);
if (reps < 1)
reps = 1;