sim: bfin: simplify field width processing and fix build warnings
authorMike Frysinger <vapier@gentoo.org>
Sun, 1 Apr 2012 04:23:40 +0000 (04:23 +0000)
committerMike Frysinger <vapier@gentoo.org>
Sun, 1 Apr 2012 04:23:40 +0000 (04:23 +0000)
This fix the build time warning:
warning: format not a string literal, argument types not checked [-Wformat-nonliteral]

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
sim/bfin/ChangeLog
sim/bfin/bfin-sim.c

index 70d9275..899d0ca 100644 (file)
@@ -1,5 +1,10 @@
 2012-04-01  Mike Frysinger  <vapier@gentoo.org>
 
+       * bfin-dis.c (fmtconst): Replace decimal handling with a single
+       sprintf call and the '*' field width.
+
+2012-04-01  Mike Frysinger  <vapier@gentoo.org>
+
        * machs.c (bfin_model_map_bfrom): Return when mnum is 535.
 
 2012-04-01  Mike Frysinger  <vapier@gentoo.org>
index 2c93e04..54d6bca 100644 (file)
@@ -223,16 +223,7 @@ fmtconst_str (const_forms_t cf, bs32 x, bu32 pc)
     x <<= constant_formats[cf].scale;
 
   if (constant_formats[cf].decimal)
-    {
-      if (constant_formats[cf].leading)
-       {
-         char ps[10];
-         sprintf (ps, "%%%ii", constant_formats[cf].leading);
-         sprintf (buf, ps, x);
-       }
-      else
-       sprintf (buf, "%i", x);
-    }
+    sprintf (buf, "%*i", constant_formats[cf].leading, x);
   else
     {
       if (constant_formats[cf].issigned && x < 0)