Skip to content

Commit 90f2ab4

Browse files
tectonic: fix many format issues
-Wformat -Wformat-extra-args -Wformat-security
1 parent 3cae115 commit 90f2ab4

24 files changed

+65
-63
lines changed

tectonic/dpx-bmpimage.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ bmp_include_image (pdf_ximage *ximage, rust_input_handle_t handle)
140140
if (hdr.bit_count < 24) {
141141
if (hdr.bit_count != 1 &&
142142
hdr.bit_count != 4 && hdr.bit_count != 8) {
143-
dpx_warning("Unsupported palette size: %ld", hdr.bit_count);
143+
dpx_warning("Unsupported palette size: %hu", hdr.bit_count);
144144
return -1;
145145
}
146146
num_palette = (hdr.offset - hdr.hsize - DIB_FILE_HEADER_SIZE) / hdr.psize;
@@ -151,12 +151,12 @@ bmp_include_image (pdf_ximage *ximage, rust_input_handle_t handle)
151151
info.bits_per_component = 8;
152152
info.num_components = 3;
153153
} else {
154-
dpx_warning("Unkown/Unsupported BMP bitCount value: %ld", hdr.bit_count);
154+
dpx_warning("Unkown/Unsupported BMP bitCount value: %hu", hdr.bit_count);
155155
return -1;
156156
}
157157

158158
if (info.width == 0 || info.height == 0 || num_palette < 1) {
159-
dpx_warning("Invalid BMP file: width=%ld, height=%ld, #palette=%d",
159+
dpx_warning("Invalid BMP file: width=%u, height=%d, #palette=%d",
160160
info.width, info.height, num_palette);
161161
return -1;
162162
}
@@ -236,7 +236,7 @@ bmp_include_image (pdf_ximage *ximage, rust_input_handle_t handle)
236236
return -1;
237237
}
238238
} else {
239-
dpx_warning("Unknown/Unsupported compression type for BMP image: %ld", hdr.compression);
239+
dpx_warning("Unknown/Unsupported compression type for BMP image: %d", hdr.compression);
240240
pdf_release_obj(stream);
241241
return -1;
242242
}

tectonic/dpx-cidtype0.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ CIDFont_type0_dofont (CIDFont *font)
817817
CIDFontInfo_close(&info);
818818

819819
if (verbose > 1)
820-
dpx_message("[%u/%u glyphs][%ld bytes]", num_glyphs, cs_count, destlen);
820+
dpx_message("[%u/%u glyphs][%d bytes]", num_glyphs, cs_count, destlen);
821821

822822
CIDFont_type0_add_CIDSet(font, used_chars, last_cid);
823823
}
@@ -1272,7 +1272,7 @@ CIDFont_type0_t1cdofont (CIDFont *font)
12721272
CIDFontInfo_close(&info);
12731273

12741274
if (verbose > 1)
1275-
dpx_message("[%u glyphs][%ld bytes]", num_glyphs, destlen);
1275+
dpx_message("[%u glyphs][%d bytes]", num_glyphs, destlen);
12761276

12771277
CIDFont_type0_add_CIDSet(font, used_chars, last_cid);
12781278
}

tectonic/dpx-cidtype2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ CIDFont_type2_dofont (CIDFont *font)
888888
_tt_abort("Could not created FontFile stream for \"%s\".", font->ident);
889889

890890
if (verbose > 1) {
891-
dpx_message("[%ld bytes]", pdf_stream_length(fontfile));
891+
dpx_message("[%d bytes]", pdf_stream_length(fontfile));
892892
}
893893

894894
pdf_add_dict(font->descriptor,

tectonic/dpx-cs_type2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ get_subr (card8 **subr, int *len, cff_index *subr_idx, int id)
679679
}
680680

681681
if (id > count)
682-
_tt_abort("%s: Invalid Subr index: %ld (max=%u)", CS_TYPE2_DEBUG_STR, id, count);
682+
_tt_abort("%s: Invalid Subr index: %d (max=%u)", CS_TYPE2_DEBUG_STR, id, count);
683683

684684
*len = (subr_idx->offset)[id + 1] - (subr_idx->offset)[id];
685685
*subr = subr_idx->data + (subr_idx->offset)[id] - 1;

tectonic/dpx-dvi.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <stdio.h>
2727
#include <stdlib.h>
2828
#include <ctype.h>
29+
#include <inttypes.h>
2930

3031
#include <tectonic/dpx-system.h>
3132
#include <tectonic/dpx-mem.h>
@@ -468,11 +469,11 @@ get_dvi_info (int32_t post_location)
468469

469470
if (verbose > 2) {
470471
dpx_message("DVI File Info\n");
471-
dpx_message("Unit: %ld / %ld\n", dvi_info.unit_num, dvi_info.unit_den);
472-
dpx_message("Magnification: %ld\n", dvi_info.mag);
473-
dpx_message("Media Height: %ld\n", dvi_info.media_height);
474-
dpx_message("Media Width: %ld\n", dvi_info.media_width);
475-
dpx_message("Stack Depth: %d\n", dvi_info.stackdepth);
472+
dpx_message("Unit: %" PRIu32 " / %" PRIu32 "\n", dvi_info.unit_num, dvi_info.unit_den);
473+
dpx_message("Magnification: %" PRIu32 "\n", dvi_info.mag);
474+
dpx_message("Media Height: %" PRIu32 "\n", dvi_info.media_height);
475+
dpx_message("Media Width: %" PRIu32 "\n", dvi_info.media_width);
476+
dpx_message("Stack Depth: %u\n", dvi_info.stackdepth);
476477
}
477478
}
478479

@@ -510,8 +511,8 @@ get_preamble_dvi_info (void)
510511

511512
if (verbose > 2) {
512513
dpx_message("DVI File Info\n");
513-
dpx_message("Unit: %ld / %ld\n", dvi_info.unit_num, dvi_info.unit_den);
514-
dpx_message("Magnification: %ld\n", dvi_info.mag);
514+
dpx_message("Unit: %" PRIu32 " / %" PRIu32 "\n", dvi_info.unit_num, dvi_info.unit_den);
515+
dpx_message("Magnification: %" PRIu32 "\n", dvi_info.mag);
515516
}
516517

517518
if (verbose) {

tectonic/dpx-epdf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ pdf_get_page_obj (pdf_file *pf, int page_no,
179179
int count = pdf_number_value(pdf_lookup_dict(page_tree, "Count"));
180180
page_idx = page_no + (page_no >= 0 ? -1 : count);
181181
if (page_idx < 0 || page_idx >= count) {
182-
dpx_warning("Page %ld does not exist.", page_no);
182+
dpx_warning("Page %d does not exist.", page_no);
183183
pdf_release_obj(page_tree);
184184
return NULL;
185185
}
@@ -282,7 +282,7 @@ pdf_get_page_obj (pdf_file *pf, int page_no,
282282
pdf_release_obj(kids);
283283

284284
if (i == kids_length) {
285-
dpx_warning("Page %ld not found! Broken PDF file?", page_no);
285+
dpx_warning("Page %d not found! Broken PDF file?", page_no);
286286
if (bbox)
287287
pdf_release_obj(bbox);
288288
if (crop_box)

tectonic/dpx-jp2image.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ read_box_hdr (FILE *fp, unsigned int *lbox, unsigned int *tbox)
7272
*lbox = get_unsigned_quad(fp);
7373
bytesread += 8;
7474
} else if (*lbox > 1 && *lbox < 8) {
75-
dpx_warning("JPEG2000: Unknown LBox value %lu in JP2 file!", lbox);
75+
dpx_warning("JPEG2000: Unknown LBox value %u in JP2 file!", *lbox);
7676
}
7777

7878
return bytesread;

tectonic/dpx-otl_conf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ otl_read_conf (const char *conf_name)
471471

472472
if (verbose > VERBOSE_LEVEL_MIN) {
473473
dpx_message("\n");
474-
dpx_message("otl_conf>> Layout config. \"%s\" found: file=\"%s\" (%ld bytes)\n",
474+
dpx_message("otl_conf>> Layout config. \"%s\" found: file=\"%s\" (%d bytes)\n",
475475
conf_name, filename, size);
476476
}
477477
free(filename);

tectonic/dpx-pdfcolor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -865,7 +865,7 @@ iccp_unpack_header (iccHeader *icch,
865865
if (check_size) {
866866
if (!profile || proflen < 128 ||
867867
proflen % 4 != 0) {
868-
dpx_warning("Profile size: %ld", proflen);
868+
dpx_warning("Profile size: %d", proflen);
869869
return -1;
870870
}
871871
}
@@ -876,7 +876,7 @@ iccp_unpack_header (iccHeader *icch,
876876
icch->size = sget_signed_long(p);
877877
if (check_size) {
878878
if (icch->size != proflen) {
879-
dpx_warning("ICC Profile size: %ld(header) != %ld", icch->size, proflen);
879+
dpx_warning("ICC Profile size: %d(header) != %d", icch->size, proflen);
880880
return -1;
881881
}
882882
}
@@ -993,7 +993,7 @@ print_iccp_header (iccHeader *icch, unsigned char *checksum)
993993

994994
dpx_message("\n");
995995
dpx_message("pdf_color>> ICC Profile Info\n");
996-
dpx_message("pdf_color>> Profile Size:\t%ld bytes\n", icch->size);
996+
dpx_message("pdf_color>> Profile Size:\t%d bytes\n", icch->size);
997997
print_iccSig(icch->CMMType, "CMM Type");
998998
dpx_message("pdf_color>> Profile Version:\t%d.%01d.%01d\n",
999999
(icch->version >> 24) & 0xff,

tectonic/dpx-pdfdev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ pdf_dev_set_rule (spt_t xpos, spt_t ypos, spt_t width, spt_t height)
16431643
* "Details of Graphics State Parameters", p. 185.
16441644
*/
16451645
if (height < dev_unit.min_bp_val) {
1646-
dpx_warning("Too thin line: height=%ld (%g bp)", height, width_in_bp);
1646+
dpx_warning("Too thin line: height=%d (%g bp)", height, width_in_bp);
16471647
dpx_warning("Please consider using \"-d\" option.");
16481648
}
16491649
len += dev_sprint_line(format_buffer+len,
@@ -1654,7 +1654,7 @@ pdf_dev_set_rule (spt_t xpos, spt_t ypos, spt_t width, spt_t height)
16541654
ypos + height/2);
16551655
} else {
16561656
if (width < dev_unit.min_bp_val) {
1657-
dpx_warning("Too thin line: width=%ld (%g bp)", width, width_in_bp);
1657+
dpx_warning("Too thin line: width=%d (%g bp)", width, width_in_bp);
16581658
dpx_warning("Please consider using \"-d\" option.");
16591659
}
16601660
len += dev_sprint_line(format_buffer+len,

0 commit comments

Comments
 (0)