mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:57:35 +00:00
Everywhere: Fix incorrect uses of String::format and StringBuilder::appendf
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.
This commit is contained in:
parent
099b83fd28
commit
6d97b623cd
9 changed files with 10 additions and 10 deletions
|
@ -34,7 +34,7 @@ String generate_only_additions(const String& text)
|
||||||
{
|
{
|
||||||
auto lines = text.split('\n', true); // Keep empty
|
auto lines = text.split('\n', true); // Keep empty
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
builder.appendf("@@ -1,%zu +1,%zu @@\n", lines.size());
|
builder.appendf("@@ -0,0 +1,%zu @@\n", lines.size());
|
||||||
for (const auto& line : lines) {
|
for (const auto& line : lines) {
|
||||||
builder.appendf("+%s\n", line.characters());
|
builder.appendf("+%s\n", line.characters());
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ namespace Gfx {
|
||||||
|
|
||||||
String Triangle::to_string() const
|
String Triangle::to_string() const
|
||||||
{
|
{
|
||||||
return String::format("({},{},{})", m_a, m_b, m_c);
|
return String::formatted("({},{},{})", m_a, m_b, m_c);
|
||||||
}
|
}
|
||||||
|
|
||||||
const LogStream& operator<<(const LogStream& stream, const Triangle& value)
|
const LogStream& operator<<(const LogStream& stream, const Triangle& value)
|
||||||
|
|
|
@ -173,7 +173,7 @@ struct ParsedDHCPv4Options {
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
builder.append("DHCP Options (");
|
builder.append("DHCP Options (");
|
||||||
builder.appendf("%d", options.size());
|
builder.appendf("%zu", options.size());
|
||||||
builder.append(" entries)\n");
|
builder.append(" entries)\n");
|
||||||
for (auto& opt : options) {
|
for (auto& opt : options) {
|
||||||
builder.appendf("\toption %d (%d bytes):", (u8)opt.key, (u8)opt.value.length);
|
builder.appendf("\toption %d (%d bytes):", (u8)opt.key, (u8)opt.value.length);
|
||||||
|
|
|
@ -130,7 +130,7 @@ static void prepare_devfs()
|
||||||
|
|
||||||
for (size_t index = 0; index < 4; index++) {
|
for (size_t index = 0; index < 4; index++) {
|
||||||
// FIXME: Find a better way to chown without hardcoding the gid!
|
// FIXME: Find a better way to chown without hardcoding the gid!
|
||||||
rc = chown(String::format("/dev/tty%d", index).characters(), 0, 2);
|
rc = chown(String::formatted("/dev/tty{}", index).characters(), 0, 2);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ static void prepare_devfs()
|
||||||
|
|
||||||
for (size_t index = 0; index < 4; index++) {
|
for (size_t index = 0; index < 4; index++) {
|
||||||
// FIXME: Find a better way to chown without hardcoding the gid!
|
// FIXME: Find a better way to chown without hardcoding the gid!
|
||||||
rc = chown(String::format("/dev/ttyS%d", index).characters(), 0, 2);
|
rc = chown(String::formatted("/dev/ttyS{}", index).characters(), 0, 2);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
ASSERT_NOT_REACHED();
|
ASSERT_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ struct Command {
|
||||||
builder.append("SUPPRESS_GO_AHEAD");
|
builder.append("SUPPRESS_GO_AHEAD");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
builder.append(String::format("UNKNOWN<%02x>"));
|
builder.append(String::format("UNKNOWN<%02x>", subcommand));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ void Client::handle_directory_listing(const String& requested_path, const String
|
||||||
builder.append(escape_html_entities(name));
|
builder.append(escape_html_entities(name));
|
||||||
builder.append("</a></td><td> </td>");
|
builder.append("</a></td><td> </td>");
|
||||||
|
|
||||||
builder.appendf("<td>%10d</td><td> </td>", st.st_size);
|
builder.appendf("<td>%10zd</td><td> </td>", st.st_size);
|
||||||
builder.append("<td>");
|
builder.append("<td>");
|
||||||
builder.append(Core::DateTime::from_timestamp(st.st_mtime).to_string());
|
builder.append(Core::DateTime::from_timestamp(st.st_mtime).to_string());
|
||||||
builder.append("</td>");
|
builder.append("</td>");
|
||||||
|
|
|
@ -57,7 +57,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
for (String filename : filenames) {
|
for (String filename : filenames) {
|
||||||
if (!filename.ends_with(".gz"))
|
if (!filename.ends_with(".gz"))
|
||||||
filename = String::format("%s.gz", filename);
|
filename = String::format("%s.gz", filename.characters());
|
||||||
|
|
||||||
const auto input_filename = filename;
|
const auto input_filename = filename;
|
||||||
const auto output_filename = filename.substring_view(0, filename.length() - 3);
|
const auto output_filename = filename.substring_view(0, filename.length() - 3);
|
||||||
|
|
|
@ -107,7 +107,7 @@ int main()
|
||||||
if (stat(tty.characters(), &st) == 0) {
|
if (stat(tty.characters(), &st) == 0) {
|
||||||
auto idle_time = now - st.st_mtime;
|
auto idle_time = now - st.st_mtime;
|
||||||
if (idle_time >= 0) {
|
if (idle_time >= 0) {
|
||||||
builder.appendf("%ds", idle_time);
|
builder.appendf("%llds", idle_time);
|
||||||
idle_string = builder.to_string();
|
idle_string = builder.to_string();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ static volatile pid_t child_pid = -1;
|
||||||
static String build_header_string(const Vector<const char*>& command, const struct timeval& interval)
|
static String build_header_string(const Vector<const char*>& command, const struct timeval& interval)
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
builder.appendf("Every %d", interval.tv_sec);
|
builder.appendff("Every {}", interval.tv_sec);
|
||||||
builder.appendf(".%ds: \x1b[1m", interval.tv_usec / 100000);
|
builder.appendf(".%ds: \x1b[1m", interval.tv_usec / 100000);
|
||||||
builder.join(' ', command);
|
builder.join(' ', command);
|
||||||
builder.append("\x1b[0m");
|
builder.append("\x1b[0m");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue