]> granicus.if.org Git - json-c/commitdiff
Use sizeof instead of hard coded values when calling snprintf.
authorEric Haszlakiewicz <erh+git@nimenees.com>
Thu, 12 Sep 2013 01:28:56 +0000 (20:28 -0500)
committerEric Haszlakiewicz <erh+git@nimenees.com>
Thu, 12 Sep 2013 01:28:56 +0000 (20:28 -0500)
json_object.c

index f65ae5249cee7e7cc66969757b6383397cc3956e..118def765fd319f40313a5788affb9c36c67ab46 100644 (file)
@@ -570,14 +570,14 @@ static int json_object_double_to_json_string(struct json_object* jso,
      ECMA 262 section 9.8.1 defines
      how to handle these cases as strings */
   if(isnan(jso->o.c_double))
-    size = snprintf(buf, 128, "NaN");
+    size = snprintf(buf, sizeof(buf), "NaN");
   else if(isinf(jso->o.c_double))
     if(jso->o.c_double > 0)
-      size = snprintf(buf, 128, "Infinity");
+      size = snprintf(buf, sizeof(buf), "Infinity");
     else
-      size = snprintf(buf, 128, "-Infinity");
+      size = snprintf(buf, sizeof(buf), "-Infinity");
   else
-    size = snprintf(buf, 128, "%f", jso->o.c_double);
+    size = snprintf(buf, sizeof(buf), "%f", jso->o.c_double);
 
   p = strchr(buf, ',');
   if (p) {