Skip to content

Commit c85e179

Browse files
authored
Merge pull request #66 from ronnychevalier/rc/warnings
Fix warnings in tectonic/
2 parents 50bea01 + 90d36f1 commit c85e179

38 files changed

+95
-420
lines changed

build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ fn main() {
245245
.file("tectonic/xetexini.c")
246246
.file("tectonic/XeTeX_pic.c")
247247
.define("HAVE_GETENV", Some("1"))
248+
.define("HAVE_INTTYPES_H", Some("1"))
248249
.define("HAVE_LIBPNG", Some("1"))
249250
.define("HAVE_MKSTEMP", Some("1"))
250251
.define("HAVE_STDINT_H", Some("1"))

tectonic/TECkit_Engine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ TECkit_GetMappingFlags(
208208
*/
209209
UInt32
210210
WINAPI EXPORTED
211-
TECkit_GetVersion();
211+
TECkit_GetVersion(void);
212212

213213
/*
214214
***** New APIs for version 2.1 of the engine *****

tectonic/XeTeXFontInst.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ XeTeXFontInst::initialize(const char* pathname, int index, int &status)
335335

336336
size_t sz = ttstub_input_get_size (handle);
337337
FT_Byte *data = (FT_Byte *) xmalloc (sz);
338-
339-
if (ttstub_input_read (handle, data, sz) != sz)
338+
size_t r = ttstub_input_read (handle, data, sz);
339+
if (r < 0 || (size_t) r != sz)
340340
_tt_abort("failed to read font file");
341341
ttstub_input_close(handle);
342342

@@ -363,10 +363,10 @@ XeTeXFontInst::initialize(const char* pathname, int index, int &status)
363363
free (afm);
364364

365365
if (afm_handle != NULL) {
366-
size_t sz = ttstub_input_get_size (afm_handle);
367-
FT_Byte *data = (FT_Byte *) xmalloc (sz);
368-
369-
if (ttstub_input_read (afm_handle, data, sz) != sz)
366+
sz = ttstub_input_get_size (afm_handle);
367+
data = (FT_Byte *) xmalloc (sz);
368+
r = ttstub_input_read (afm_handle, data, sz);
369+
if (r < 0 || (size_t) r != sz)
370370
_tt_abort("failed to read AFM file");
371371
ttstub_input_close(afm_handle);
372372

tectonic/XeTeXLayoutInterface.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ extern char gPrefEngine;
4444
int getCachedGlyphBBox(uint16_t fontID, uint16_t glyphID, GlyphBBox* bbox);
4545
void cacheGlyphBBox(uint16_t fontID, uint16_t glyphID, const GlyphBBox* bbox);
4646

47-
void terminate_font_manager();
47+
void terminate_font_manager(void);
4848

4949
XeTeXFont createFont(PlatformFontRef fontRef, Fixed pointSize);
5050
XeTeXFont createFontFromFile(const char* filename, int index, Fixed pointSize);
@@ -53,7 +53,7 @@ void setFontLayoutDir(XeTeXFont font, int vertical);
5353

5454
PlatformFontRef findFontByName(const char* name, char* var, double size);
5555

56-
char getReqEngine();
56+
char getReqEngine(void);
5757
void setReqEngine(char reqEngine);
5858
const char* getFullName(PlatformFontRef fontRef);
5959

tectonic/XeTeX_ext.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ unsigned int read_rgb_a(const char** cp);
159159
int count_pdf_file_pages(void);
160160
int find_pic_file(char** path, real_rect* bounds, int pdfBoxType, int page);
161161

162-
void terminate_font_manager(void);
163162
int maketexstring(const char* s);
164163
extern void set_cp_code(int fontNum, unsigned int code, int side, int value);
165164
extern int get_cp_code(int fontNum, unsigned int code, int side);

tectonic/bibtex.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ peekable_getc (peekable_input_t *peekable)
7575
return rv;
7676
}
7777

78-
static int
78+
static void
7979
peekable_ungetc (peekable_input_t *peekable, int c)
8080
{
8181
/* TODO: assert c != EOF */
@@ -6517,7 +6517,7 @@ void get_bib_command_or_entry_and_process(void)
65176517
}
65186518
if ((right_outer_delim == 41 /*right_paren */ )) {
65196519
if ((scan1_white(44 /*comma */ ))) ;
6520-
} else if ((scan2_white(44 /*comma */ , 125 /*right_brace */ ))) ;
6520+
} else if ((scan2_white(44 /*comma */ , 125 /*right_brace */ ))) {};
65216521
{
65226522
;
65236523

tectonic/core-bridge.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
*/
55

66
#include <tectonic/core-bridge.h>
7+
#include <tectonic/internals.h>
78

89
#include <stdio.h> /*vsnprintf*/
910
#include <stdarg.h>
11+
#include <stdlib.h>
1012
#include <setjmp.h>
1113

1214

@@ -34,7 +36,7 @@ _tt_abort(const_string format, ...)
3436
longjmp(jump_buffer, 1);
3537
}
3638

37-
const const_string
39+
const_string
3840
tt_get_error_message(void)
3941
{
4042
return error_buf;
@@ -69,7 +71,7 @@ dvipdfmx_simple_main(tt_bridge_api_t *api, char *dviname, char *pdfname)
6971
{
7072
extern int dvipdfmx_main(int argc, char *argv[]);
7173

72-
char *argv[] = { "dvipdfmx", "-o", pdfname, dviname };
74+
char *argv[] = { xstrdup("dvipdfmx"), xstrdup("-o"), pdfname, dviname };
7375
int rv;
7476

7577
tectonic_global_bridge = api;
@@ -81,6 +83,10 @@ dvipdfmx_simple_main(tt_bridge_api_t *api, char *dviname, char *pdfname)
8183

8284
rv = dvipdfmx_main(4, argv);
8385
tectonic_global_bridge = NULL;
86+
87+
free(argv[0]);
88+
free(argv[1]);
89+
8490
return rv;
8591
}
8692

tectonic/core-bridge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ BEGIN_EXTERN_C
119119
/* These functions are not meant to be used in the C/C++ code. They define the
120120
* API that we expose to the Rust side of things. */
121121

122-
extern const const_string tt_get_error_message(void);
122+
extern const_string tt_get_error_message(void);
123123
extern int tex_simple_main(tt_bridge_api_t *api, char *dump_name, char *input_file_name);
124124
extern int dvipdfmx_simple_main(tt_bridge_api_t *api, char *dviname, char *pdfname);
125125
extern int bibtex_simple_main(tt_bridge_api_t *api, char *aux_file_name);

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
}

0 commit comments

Comments
 (0)