Cleanup: Converted all sprintf to snprintf

This commit is contained in:
Paul Beckingham 2016-02-25 00:19:38 -05:00
parent 9e5a0f0e61
commit 48167f53eb
8 changed files with 24 additions and 32 deletions

View file

@ -155,10 +155,10 @@ std::string formatBytes (size_t bytes)
{
char formatted[24];
if (bytes >= 995000000) sprintf (formatted, "%.1f %s", (bytes / 1000000000.0), STRING_UTIL_GIBIBYTES);
else if (bytes >= 995000) sprintf (formatted, "%.1f %s", (bytes / 1000000.0), STRING_UTIL_MEBIBYTES);
else if (bytes >= 995) sprintf (formatted, "%.1f %s", (bytes / 1000.0), STRING_UTIL_KIBIBYTES);
else sprintf (formatted, "%d %s", (int)bytes, STRING_UTIL_BYTES);
if (bytes >= 995000000) snprintf (formatted, 24, "%.1f %s", (bytes / 1000000000.0), STRING_UTIL_GIBIBYTES);
else if (bytes >= 995000) snprintf (formatted, 24, "%.1f %s", (bytes / 1000000.0), STRING_UTIL_MEBIBYTES);
else if (bytes >= 995) snprintf (formatted, 24, "%.1f %s", (bytes / 1000.0), STRING_UTIL_KIBIBYTES);
else snprintf (formatted, 24, "%d %s", (int)bytes, STRING_UTIL_BYTES);
return Lexer::commify (formatted);
}