Android forces -Wformat on for all source.

  toys/pending/expr.c:116:28: warning: field precision should have type 'int',
                                       but argument has type 'long' [-Wformat]
      ret->s = xmprintf("%.*s", m[1].rm_eo-m[1].rm_so, target+m[1].rm_so);
                         ~~^~   ~~~~~~~~~~~~~~~~~~~~~
---
 toys/pending/expr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
From 8f4e828c4a2196521f15519da0876ba91d77dc3d Mon Sep 17 00:00:00 2001
From: Elliott Hughes <e...@google.com>
Date: Fri, 7 Jul 2017 13:06:36 -0700
Subject: [PATCH] Fix -Wformat compiler warning in expr.c.

Android forces -Wformat on for all source.

  toys/pending/expr.c:116:28: warning: field precision should have type 'int',
                                       but argument has type 'long' [-Wformat]
      ret->s = xmprintf("%.*s", m[1].rm_eo-m[1].rm_so, target+m[1].rm_so);
                         ~~^~   ~~~~~~~~~~~~~~~~~~~~~
---
 toys/pending/expr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/toys/pending/expr.c b/toys/pending/expr.c
index 743a953..9e094a7 100644
--- a/toys/pending/expr.c
+++ b/toys/pending/expr.c
@@ -113,7 +113,8 @@ static void re(char *target, char *pattern, struct value *ret)
   if (!regexec(&pat, target, 2, m, 0) && !m[0].rm_so) {
     // Return first parenthesized subexpression as string, or length of match
     if (pat.re_nsub>0) {
-      ret->s = xmprintf("%.*s", m[1].rm_eo-m[1].rm_so, target+m[1].rm_so);
+      ret->s = xmprintf("%.*s", (int)(m[1].rm_eo-m[1].rm_so),
+          target+m[1].rm_so);
       if (TT.refree) free(TT.refree);
       TT.refree = ret->s;
     } else assign_int(ret, m[0].rm_eo);
-- 
2.13.2.725.g09c95d1e9-goog

_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to