From b5ef40e9d388915b973efab43a9fbe57e80e21d1 Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Mon, 25 Feb 2019 09:19:32 +0200 Subject: fix warnings found by -D_FORTIFY_SOURCE=2 --- src/bin/starpbm.c | 2 +- src/escpos/parser.rl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bin/starpbm.c b/src/bin/starpbm.c index ba4e46d..8abc036 100644 --- a/src/bin/starpbm.c +++ b/src/bin/starpbm.c @@ -92,7 +92,7 @@ pixels_from_pbm(FILE *f, size_t *out_w, size_t *out_h) cfg[i] = strtol(buf, NULL, 10); } - if (!cfg[0] || !cfg[2]) + if (!cfg[0] || !cfg[1]) errx(EXIT_FAILURE, "invalid width / height"); uint8_t *bw; diff --git a/src/escpos/parser.rl b/src/escpos/parser.rl index 7cf828f..34f4055 100644 --- a/src/escpos/parser.rl +++ b/src/escpos/parser.rl @@ -75,7 +75,7 @@ render_chr(struct escpos_canvas *canvas, struct cursor *cursor, const struct ras } } } - cursor->x += MIN(glyph->width + SPACING, canvas->w - cursor->x); + cursor->x += MIN((size_t)glyph->width + SPACING, canvas->w - cursor->x); cursor->wy = MIN(cursor->y + MAX(raster->font.height, 1) - 1, canvas->h); } @@ -226,7 +226,7 @@ cut(const struct escpos_parser *parser, struct escpos_canvas *canvas, struct cur action text { putc(fc, stderr); - uint32_t cp; + uint32_t cp = 0; if (utf8_decode(&utf8.state, &cp, fc) == UTF8_ACCEPT) render_chr(&parser->print_buffer, &print_buffer_cursor, &raster, cp); } -- cgit v1.2.3-70-g09d2