1 From ee23bda1e4a85243fa02dc712f0f323e366dbf8c Mon Sep 17 00:00:00 2001
2 From: Steven Barth <cyrus@openwrt.org>
3 Date: Mon, 15 Dec 2014 14:14:46 +0100
4 Subject: [PATCH 3/5] erec: use stdio vasprintf instead of gmp_vasprintf
6 Use stdio's vasprintf instead of gmp_vasprintf which is not part
7 of the mini-gmp function subset. Furthermore convert the only
8 gmp-specific user and allow the compiler to verify format-strings.
10 Signed-off-by: Steven Barth <cyrus@openwrt.org>
13 src/evaluate.c | 8 ++++++--
14 2 files changed, 11 insertions(+), 3 deletions(-)
18 @@ -44,6 +44,7 @@ static void erec_destroy(struct error_re
22 +__attribute__((format(printf, 3, 0)))
23 struct error_record *erec_vcreate(enum error_record_types type,
24 const struct location *loc,
25 const char *fmt, va_list ap)
26 @@ -55,10 +56,13 @@ struct error_record *erec_vcreate(enum e
27 erec->num_locations = 0;
28 erec_add_location(erec, loc);
30 - gmp_vasprintf(&erec->msg, fmt, ap);
31 + if (vasprintf(&erec->msg, fmt, ap) < 0)
37 +__attribute__((format(printf, 3, 4)))
38 struct error_record *erec_create(enum error_record_types type,
39 const struct location *loc,
43 @@ -232,9 +232,13 @@ static int expr_evaluate_value(struct ev
45 mpz_init_bitmask(mask, ctx->ectx.len);
46 if (mpz_cmp((*expr)->value, mask) > 0) {
47 + char *valstr = mpz_get_str(NULL, 10, (*expr)->value);
48 + char *rangestr = mpz_get_str(NULL, 10, mask);
49 expr_error(ctx->msgs, *expr,
50 - "Value %Zu exceeds valid range 0-%Zu",
51 - (*expr)->value, mask);
52 + "Value %s exceeds valid range 0-%s",