From aefe6a511b3cb901034e5995fd882e334e40f2bb Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 13 Sep 2013 15:47:58 +0100 Subject: Fix various compile warnings spotted by the cluster. --- platform/x11/pdfapp.c | 7 +++++-- source/fitz/buffer.c | 2 +- source/fitz/crypt-aes.c | 6 +++--- source/fitz/draw-device.c | 8 ++++---- source/fitz/draw-edge.c | 1 - source/fitz/draw-glyph.c | 9 ++++++--- source/fitz/draw-path.c | 6 +++--- source/fitz/draw-scale-simple.c | 2 +- source/fitz/font.c | 1 + source/fitz/halftone.c | 2 +- source/fitz/load-tiff.c | 4 ++-- source/fitz/pixmap.c | 9 +++------ source/fitz/stext-device.c | 3 +++ source/fitz/xml.c | 8 ++++---- source/pdf/pdf-appearance.c | 2 +- source/pdf/pdf-colorspace.c | 2 +- source/pdf/pdf-crypt.c | 3 ++- source/pdf/pdf-font.c | 2 +- source/pdf/pdf-image.c | 2 +- source/pdf/pdf-parse.c | 2 +- source/pdf/pdf-repair.c | 4 +++- source/pdf/pdf-write.c | 8 ++++---- source/xps/xps-tile.c | 2 +- 23 files changed, 52 insertions(+), 43 deletions(-) diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c index afd4196e..10a44573 100644 --- a/platform/x11/pdfapp.c +++ b/platform/x11/pdfapp.c @@ -428,7 +428,7 @@ static int pdfapp_save(pdfapp_t *app) if (gen_tmp_file(buf, PATH_MAX)) { - int written; + int written = 0; fz_try(app->ctx) { @@ -438,7 +438,6 @@ static int pdfapp_save(pdfapp_t *app) } fz_catch(app->ctx) { - written = 0; } if (written) @@ -797,6 +796,10 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai fz_transition *new_trans; app->new_image = app->image; app->image = NULL; + if (app->grayscale) + colorspace = fz_device_gray(app->ctx); + else + colorspace = app->colorspace; app->image = fz_new_pixmap_with_bbox(app->ctx, colorspace, &ibounds); app->duration = 0; new_trans = fz_page_presentation(app->doc, app->page, &app->duration); diff --git a/source/fitz/buffer.c b/source/fitz/buffer.c index 3d80fbbd..07ce9361 100644 --- a/source/fitz/buffer.c +++ b/source/fitz/buffer.c @@ -341,7 +341,7 @@ fz_buffer_cat_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *text) *d++ = c; } } - *d++ = ')'; + *d = ')'; buffer->len += len; } diff --git a/source/fitz/crypt-aes.c b/source/fitz/crypt-aes.c index 6ce14903..f98fb8fd 100644 --- a/source/fitz/crypt-aes.c +++ b/source/fitz/crypt-aes.c @@ -325,7 +325,7 @@ int aes_setkey_dec(aes_context *ctx, const unsigned char *key, int keysize) *RK++ = *SK++; *RK++ = *SK++; *RK++ = *SK++; - *RK++ = *SK++; + *RK = *SK; memset( &cty, 0, sizeof( aes_context ) ); return 0; @@ -428,7 +428,7 @@ void aes_crypt_ecb( aes_context *ctx, ( RSb[ ( Y0 >> 16 ) & 0xFF ] << 16 ) ^ ( RSb[ ( Y3 >> 24 ) & 0xFF ] << 24 ); - X3 = *RK++ ^ ( RSb[ ( Y3 ) & 0xFF ] ) ^ + X3 = *RK ^ ( RSb[ ( Y3 ) & 0xFF ] ) ^ ( RSb[ ( Y2 >> 8 ) & 0xFF ] << 8 ) ^ ( RSb[ ( Y1 >> 16 ) & 0xFF ] << 16 ) ^ ( RSb[ ( Y0 >> 24 ) & 0xFF ] << 24 ); @@ -458,7 +458,7 @@ void aes_crypt_ecb( aes_context *ctx, ( FSb[ ( Y0 >> 16 ) & 0xFF ] << 16 ) ^ ( FSb[ ( Y1 >> 24 ) & 0xFF ] << 24 ); - X3 = *RK++ ^ ( FSb[ ( Y3 ) & 0xFF ] ) ^ + X3 = *RK ^ ( FSb[ ( Y3 ) & 0xFF ] ) ^ ( FSb[ ( Y0 >> 8 ) & 0xFF ] << 8 ) ^ ( FSb[ ( Y1 >> 16 ) & 0xFF ] << 16 ) ^ ( FSb[ ( Y2 >> 24 ) & 0xFF ] << 24 ); diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c index 79886405..bcd93edb 100644 --- a/source/fitz/draw-device.c +++ b/source/fitz/draw-device.c @@ -1482,7 +1482,7 @@ fz_draw_begin_group(fz_device *devp, const fz_rect *rect, int isolated, int knoc { fz_draw_device *dev = devp->user; fz_irect bbox; - fz_pixmap *dest, *shape; + fz_pixmap *dest; fz_context *ctx = dev->ctx; fz_draw_state *state = &dev->stack[dev->top]; fz_colorspace *model = state->dest->colorspace; @@ -1515,12 +1515,12 @@ fz_draw_begin_group(fz_device *devp, const fz_rect *rect, int isolated, int knoc { /* We can render direct to any existing shape plane. * If there isn't one, we don't need to make one. */ - state[1].shape =shape = state[0].shape; + state[1].shape = state[0].shape; } else { - state[1].shape = shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox); - fz_clear_pixmap(dev->ctx, shape); + state[1].shape = fz_new_pixmap_with_bbox(ctx, NULL, &bbox); + fz_clear_pixmap(dev->ctx, state[1].shape); } state[1].alpha = alpha; diff --git a/source/fitz/draw-edge.c b/source/fitz/draw-edge.c index fcce6f5c..59d92967 100644 --- a/source/fitz/draw-edge.c +++ b/source/fitz/draw-edge.c @@ -922,7 +922,6 @@ fz_scan_convert_sharp(fz_gel *gel, int eofill, const fz_irect *clip, y += height; if (y >= clip->y0) { - height -= y - clip->y0; y = clip->y0; break; } diff --git a/source/fitz/draw-glyph.c b/source/fitz/draw-glyph.c index 223e48d6..73f2eb71 100644 --- a/source/fitz/draw-glyph.c +++ b/source/fitz/draw-glyph.c @@ -254,6 +254,7 @@ fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix *ctm, fz_colo fz_var(locked); fz_var(caching); + fz_var(val); memset(&key, 0, sizeof key); size = fz_subpixel_adjust(ctm, &subpix_ctm, &key.e, &key.f); @@ -296,6 +297,7 @@ fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix *ctm, fz_colo locked = 1; caching = 0; + val = NULL; fz_try(ctx) { @@ -323,7 +325,6 @@ fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix *ctm, fz_colo else { fz_warn(ctx, "assert: uninitialized font structure"); - val = NULL; } if (val && do_cache) { @@ -344,8 +345,7 @@ fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix *ctm, fz_colo fz_drop_glyph(ctx, val); move_to_front(cache, entry); val = fz_keep_glyph(ctx, entry->val); - fz_unlock(ctx, FZ_LOCK_GLYPHCACHE); - return val; + goto unlock_and_return_val; } entry = entry->bucket_next; } @@ -380,6 +380,9 @@ fz_render_glyph(fz_context *ctx, fz_font *font, int gid, fz_matrix *ctm, fz_colo } } +unlock_and_return_val: + { + } } fz_always(ctx) { diff --git a/source/fitz/draw-path.c b/source/fitz/draw-path.c index 1d2d7500..03b83f78 100644 --- a/source/fitz/draw-path.c +++ b/source/fitz/draw-path.c @@ -55,7 +55,7 @@ bezier(fz_gel *gel, const fz_matrix *ctm, float flatness, yabcd = yabc + ybcd; xab *= 0.5f; yab *= 0.5f; - xbc *= 0.5f; ybc *= 0.5f; + /* xbc *= 0.5f; ybc *= 0.5f; */ xcd *= 0.5f; ycd *= 0.5f; xabc *= 0.25f; yabc *= 0.25f; @@ -529,7 +529,7 @@ fz_stroke_bezier(struct sctx *s, yabcd = yabc + ybcd; xab *= 0.5f; yab *= 0.5f; - xbc *= 0.5f; ybc *= 0.5f; + /* xbc *= 0.5f; ybc *= 0.5f; */ xcd *= 0.5f; ycd *= 0.5f; xabc *= 0.25f; yabc *= 0.25f; @@ -734,7 +734,7 @@ fz_dash_bezier(struct sctx *s, yabcd = yabc + ybcd; xab *= 0.5f; yab *= 0.5f; - xbc *= 0.5f; ybc *= 0.5f; + /* xbc *= 0.5f; ybc *= 0.5f; */ xcd *= 0.5f; ycd *= 0.5f; xabc *= 0.25f; yabc *= 0.25f; diff --git a/source/fitz/draw-scale-simple.c b/source/fitz/draw-scale-simple.c index 08dedf0b..1ec6ffd8 100644 --- a/source/fitz/draw-scale-simple.c +++ b/source/fitz/draw-scale-simple.c @@ -1469,7 +1469,7 @@ fz_scale_pixmap_cached(fz_context *ctx, fz_pixmap *src, float x, float y, float */ int row_index = contrib_rows->index[row]; int row_min = contrib_rows->index[row_index++]; - int row_len = contrib_rows->index[row_index++]; + int row_len = contrib_rows->index[row_index]; while (max_row < row_min+row_len) { /* Scale another row */ diff --git a/source/fitz/font.c b/source/fitz/font.c index 165b6880..334f076a 100644 --- a/source/fitz/font.c +++ b/source/fitz/font.c @@ -906,6 +906,7 @@ fz_outline_ft_glyph(fz_context *ctx, fz_font *font, int gid, const fz_matrix *tr FT_Outline_Translate(&face->glyph->outline, -strength * 32, -strength * 32); } + cc.path = NULL; fz_try(ctx) { cc.ctx = ctx; diff --git a/source/fitz/halftone.c b/source/fitz/halftone.c index 15aebead..26dbc941 100644 --- a/source/fitz/halftone.c +++ b/source/fitz/halftone.c @@ -158,7 +158,7 @@ static void do_threshold_1(unsigned char *ht_line, unsigned char *pixmap, unsign } while (--w); if (bit != 0x80) - *out++ = h; + *out = h; } fz_bitmap *fz_halftone_pixmap(fz_context *ctx, fz_pixmap *pix, fz_halftone *ht) diff --git a/source/fitz/load-tiff.c b/source/fitz/load-tiff.c index fbe84740..f473802b 100644 --- a/source/fitz/load-tiff.c +++ b/source/fitz/load-tiff.c @@ -781,7 +781,7 @@ fz_pixmap * fz_load_tiff(fz_context *ctx, unsigned char *buf, int len) { fz_pixmap *image; - struct tiff tiff; + struct tiff tiff = { 0 }; fz_try(ctx) { @@ -842,7 +842,7 @@ fz_load_tiff(fz_context *ctx, unsigned char *buf, int len) void fz_load_tiff_info(fz_context *ctx, unsigned char *buf, int len, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep) { - struct tiff tiff; + struct tiff tiff = { 0 }; fz_try(ctx) { diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c index 2cc6a98c..8b3ac6a6 100644 --- a/source/fitz/pixmap.c +++ b/source/fitz/pixmap.c @@ -648,7 +648,6 @@ fz_output_png_header(fz_output *out, int w, int h, int n, int savealpha) unsigned char head[13]; fz_context *ctx; int color; - int sn, dn; fz_png_output_context *poc; if (!out) @@ -661,12 +660,10 @@ fz_output_png_header(fz_output *out, int w, int h, int n, int savealpha) poc = fz_malloc_struct(ctx, fz_png_output_context); - sn = n; - dn = n; - if (!savealpha && dn > 1) - dn--; + if (!savealpha && n > 1) + n--; - switch (dn) + switch (n) { default: case 1: color = 0; break; diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c index 89cf8566..20e5e525 100644 --- a/source/fitz/stext-device.c +++ b/source/fitz/stext-device.c @@ -56,6 +56,7 @@ fz_text_char_bbox(fz_rect *bbox, fz_text_span *span, int i) if (!span || i >= span->len) { *bbox = fz_empty_rect; + return bbox; } ch = &span->text[i]; if (i == span->len-1) @@ -622,7 +623,9 @@ fz_add_text_char_imp(fz_context *ctx, fz_text_device *dev, fz_text_style *style, else { can_append = 0; +#ifdef DEBUG_SPANS spacing = 0; +#endif } } diff --git a/source/fitz/xml.c b/source/fitz/xml.c index 8c97562c..958eb51c 100644 --- a/source/fitz/xml.c +++ b/source/fitz/xml.c @@ -144,7 +144,7 @@ static int xml_parse_entity(int *c, char *a) *c = '"'; return 6; } - *c = *a++; + *c = *a; return 1; } @@ -290,7 +290,7 @@ parse_comment: if (*p == '[') goto parse_cdata; if (*p++ != '-') return "syntax error in comment (') { p += 3; @@ -304,7 +304,7 @@ parse_cdata: if (p[1] != 'C' || p[2] != 'D' || p[3] != 'A' || p[4] != 'T' || p[5] != 'A' || p[6] != '[') return "syntax error in CDATA section"; p += 7; - mark = p; + /* mark = p; */ while (*p) { if (p[0] == ']' && p[1] == ']' && p[2] == '>') { p += 3; @@ -326,7 +326,7 @@ parse_processing_instruction: parse_closing_element: while (iswhite(*p)) ++p; - mark = p; + /* mark = p; */ while (isname(*p)) ++p; while (iswhite(*p)) ++p; if (*p != '>') diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c index f143fc65..0b1a290a 100644 --- a/source/pdf/pdf-appearance.c +++ b/source/pdf/pdf-appearance.c @@ -80,7 +80,7 @@ static void da_check_stack(float *stack, int *top) void pdf_parse_da(fz_context *ctx, char *da, pdf_da_info *di) { - float stack[32]; + float stack[32] = { 0.0f }; int top = 0; pdf_token tok; char *name = NULL; diff --git a/source/pdf/pdf-colorspace.c b/source/pdf/pdf-colorspace.c index de138f90..9ade1a71 100644 --- a/source/pdf/pdf-colorspace.c +++ b/source/pdf/pdf-colorspace.c @@ -206,7 +206,7 @@ load_indexed(pdf_document *doc, pdf_obj *array) fz_try(ctx) { file = pdf_open_stream(doc, pdf_to_num(lookupobj), pdf_to_gen(lookupobj)); - i = fz_read(file, lookup, n); + (void)fz_read(file, lookup, n); } fz_always(ctx) { diff --git a/source/pdf/pdf-crypt.c b/source/pdf/pdf-crypt.c index c1a4a52c..850ab942 100644 --- a/source/pdf/pdf-crypt.c +++ b/source/pdf/pdf-crypt.c @@ -477,7 +477,8 @@ pdf_compute_hardened_hash_r6(fz_context *ctx, unsigned char *password, int pwlen /* Step 2: repeat password and data block 64 times */ memcpy(data, password, pwlen); memcpy(data + pwlen, block, block_size); - memcpy(data + pwlen + block_size, ownerkey, ownerkey ? 48 : 0); + if (ownerkey) + memcpy(data + pwlen + block_size, ownerkey, 48); data_len = pwlen + block_size + (ownerkey ? 48 : 0); for (j = 1; j < 64; j++) memcpy(data + j * data_len, data, data_len); diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c index aee22e51..f79a0769 100644 --- a/source/pdf/pdf-font.c +++ b/source/pdf/pdf-font.c @@ -466,7 +466,7 @@ pdf_load_simple_font_by_name(pdf_document *doc, pdf_obj *dict, char *basefont) fontdesc->to_ttf_cmap = pdf_load_system_cmap(ctx, "Adobe-GB1-UCS2"); face = fontdesc->font->ft_face; - kind = ft_kind(face); + /* kind = ft_kind(face); */ goto skip_encoding; } } diff --git a/source/pdf/pdf-image.c b/source/pdf/pdf-image.c index ef93d96b..f3f63d65 100644 --- a/source/pdf/pdf-image.c +++ b/source/pdf/pdf-image.c @@ -222,7 +222,7 @@ pdf_load_jpx(pdf_document *doc, pdf_obj *dict, int forcemask) img = fz_load_jpx(ctx, buf->data, buf->len, colorspace, indexed); - if (img && colorspace == NULL) + if (colorspace == NULL) colorspace = fz_keep_colorspace(ctx, img->colorspace); fz_drop_buffer(ctx, buf); diff --git a/source/pdf/pdf-parse.c b/source/pdf/pdf-parse.c index cf2bdc20..aaa45c0d 100644 --- a/source/pdf/pdf-parse.c +++ b/source/pdf/pdf-parse.c @@ -235,7 +235,7 @@ pdf_parse_array(pdf_document *doc, fz_stream *file, pdf_lexbuf *buf) int a = 0, b = 0, n = 0; pdf_token tok; fz_context *ctx = file->ctx; - pdf_obj *op; + pdf_obj *op = NULL; fz_var(obj); diff --git a/source/pdf/pdf-repair.c b/source/pdf/pdf-repair.c index fc603d1d..8fedbeff 100644 --- a/source/pdf/pdf-repair.c +++ b/source/pdf/pdf-repair.c @@ -257,7 +257,7 @@ pdf_repair_xref(pdf_document *doc, pdf_lexbuf *buf) int num = 0; int gen = 0; int tmpofs, numofs = 0, genofs = 0; - int stm_len, stm_ofs = 0; + int stm_len, stm_ofs; pdf_token tok; int next; int i, n, c; @@ -339,6 +339,8 @@ pdf_repair_xref(pdf_document *doc, pdf_lexbuf *buf) { fz_try(ctx) { + stm_len = 0; + stm_ofs = 0; tok = pdf_repair_obj(doc, buf, &stm_ofs, &stm_len, &encrypt, &id, NULL, &tmpofs); } fz_catch(ctx) diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c index cfd14715..3ae6796e 100644 --- a/source/pdf/pdf-write.c +++ b/source/pdf/pdf-write.c @@ -1708,11 +1708,11 @@ static void writeobject(pdf_document *doc, pdf_write_options *opts, int num, int dontexpand = !(opts->do_expand & fz_expand_fonts); if (o = pdf_dict_gets(obj, "Type"), !strcmp(pdf_to_name(o), "FontDescriptor")) dontexpand = !(opts->do_expand & fz_expand_fonts); - if ((o = pdf_dict_gets(obj, "Length1")) != NULL) + if (pdf_dict_gets(obj, "Length1") != NULL) dontexpand = !(opts->do_expand & fz_expand_fonts); - if ((o = pdf_dict_gets(obj, "Length2")) != NULL) + if (pdf_dict_gets(obj, "Length2") != NULL) dontexpand = !(opts->do_expand & fz_expand_fonts); - if ((o = pdf_dict_gets(obj, "Length3")) != NULL) + if (pdf_dict_gets(obj, "Length3") != NULL) dontexpand = !(opts->do_expand & fz_expand_fonts); if (o = pdf_dict_gets(obj, "Subtype"), !strcmp(pdf_to_name(o), "Type1C")) dontexpand = !(opts->do_expand & fz_expand_fonts); @@ -2104,7 +2104,7 @@ make_page_offset_hints(pdf_document *doc, pdf_write_options *opts, fz_buffer *bu int min_page_length, max_page_length; int objs_per_page_bits; int min_shared_object, max_shared_object; - int max_shared_object_refs; + int max_shared_object_refs = 0; int min_shared_length, max_shared_length; page_objects **pop = &opts->page_object_lists->page[0]; int page_len_bits, shared_object_bits, shared_object_id_bits; diff --git a/source/xps/xps-tile.c b/source/xps/xps-tile.c index cbf3943d..0225d76e 100644 --- a/source/xps/xps-tile.c +++ b/source/xps/xps-tile.c @@ -170,7 +170,7 @@ xps_parse_tiling_brush(xps_document *doc, const fz_matrix *ctm, const fz_rect *a int x0, y0, x1, y1; fz_matrix invctm; fz_rect local_area = *area; - area = fz_transform_rect(&local_area, fz_invert_matrix(&invctm, &transform)); + fz_transform_rect(&local_area, fz_invert_matrix(&invctm, &transform)); x0 = floorf(local_area.x0 / xstep); y0 = floorf(local_area.y0 / ystep); x1 = ceilf(local_area.x1 / xstep); -- cgit v1.2.3