mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
AK: Prefer snprintf over sprintf
This commit is contained in:
parent
b6afe1f0ce
commit
04f494fc44
Notes:
sideshowbarker
2024-07-19 03:17:06 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/04f494fc44e Pull-request: https://github.com/SerenityOS/serenity/pull/3263
2 changed files with 13 additions and 13 deletions
|
@ -60,49 +60,49 @@ const LogStream& operator<<(const LogStream& stream, const StringView& value)
|
|||
const LogStream& operator<<(const LogStream& stream, int value)
|
||||
{
|
||||
char buffer[32];
|
||||
sprintf(buffer, "%d", value);
|
||||
snprintf(buffer, sizeof(buffer), "%d", value);
|
||||
return stream << buffer;
|
||||
}
|
||||
|
||||
const LogStream& operator<<(const LogStream& stream, long value)
|
||||
{
|
||||
char buffer[32];
|
||||
sprintf(buffer, "%ld", value);
|
||||
snprintf(buffer, sizeof(buffer), "%ld", value);
|
||||
return stream << buffer;
|
||||
}
|
||||
|
||||
const LogStream& operator<<(const LogStream& stream, long long value)
|
||||
{
|
||||
char buffer[32];
|
||||
sprintf(buffer, "%lld", value);
|
||||
snprintf(buffer, sizeof(buffer), "%lld", value);
|
||||
return stream << buffer;
|
||||
}
|
||||
|
||||
const LogStream& operator<<(const LogStream& stream, unsigned value)
|
||||
{
|
||||
char buffer[32];
|
||||
sprintf(buffer, "%u", value);
|
||||
snprintf(buffer, sizeof(buffer), "%u", value);
|
||||
return stream << buffer;
|
||||
}
|
||||
|
||||
const LogStream& operator<<(const LogStream& stream, unsigned long long value)
|
||||
{
|
||||
char buffer[32];
|
||||
sprintf(buffer, "%llu", value);
|
||||
snprintf(buffer, sizeof(buffer), "%llu", value);
|
||||
return stream << buffer;
|
||||
}
|
||||
|
||||
const LogStream& operator<<(const LogStream& stream, unsigned long value)
|
||||
{
|
||||
char buffer[32];
|
||||
sprintf(buffer, "%lu", value);
|
||||
snprintf(buffer, sizeof(buffer), "%lu", value);
|
||||
return stream << buffer;
|
||||
}
|
||||
|
||||
const LogStream& operator<<(const LogStream& stream, const void* value)
|
||||
{
|
||||
char buffer[32];
|
||||
sprintf(buffer, "%p", value);
|
||||
snprintf(buffer, sizeof(buffer), "%p", value);
|
||||
return stream << buffer;
|
||||
}
|
||||
|
||||
|
|
|
@ -210,7 +210,7 @@ String String::number(unsigned long long value)
|
|||
{
|
||||
int size;
|
||||
char buffer[32];
|
||||
size = sprintf(buffer, "%llu", value);
|
||||
size = snprintf(buffer, sizeof(buffer), "%llu", value);
|
||||
return String(buffer, size);
|
||||
}
|
||||
|
||||
|
@ -218,35 +218,35 @@ String String::number(unsigned long value)
|
|||
{
|
||||
int size;
|
||||
char buffer[32];
|
||||
size = sprintf(buffer, "%lu", value);
|
||||
size = snprintf(buffer, sizeof(buffer), "%lu", value);
|
||||
return String(buffer, size);
|
||||
}
|
||||
|
||||
String String::number(unsigned value)
|
||||
{
|
||||
char buffer[32];
|
||||
int size = sprintf(buffer, "%u", value);
|
||||
int size = snprintf(buffer, sizeof(buffer), "%u", value);
|
||||
return String(buffer, size);
|
||||
}
|
||||
|
||||
String String::number(long long value)
|
||||
{
|
||||
char buffer[32];
|
||||
int size = sprintf(buffer, "%lld", value);
|
||||
int size = snprintf(buffer, sizeof(buffer), "%lld", value);
|
||||
return String(buffer, size);
|
||||
}
|
||||
|
||||
String String::number(long value)
|
||||
{
|
||||
char buffer[32];
|
||||
int size = sprintf(buffer, "%ld", value);
|
||||
int size = snprintf(buffer, sizeof(buffer), "%ld", value);
|
||||
return String(buffer, size);
|
||||
}
|
||||
|
||||
String String::number(int value)
|
||||
{
|
||||
char buffer[32];
|
||||
int size = sprintf(buffer, "%d", value);
|
||||
int size = snprintf(buffer, sizeof(buffer), "%d", value);
|
||||
return String(buffer, size);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue