mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:07:34 +00:00
Kernel: Convert snprintf() => String::formatted()/number()
This commit is contained in:
parent
5f610417d0
commit
6c2f0316d9
3 changed files with 5 additions and 11 deletions
|
@ -1260,9 +1260,7 @@ KResult ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntr
|
||||||
callback({ { entry.name, strlen(entry.name) }, to_identifier(fsid(), PDI_Root, 0, (ProcFileType)entry.proc_file_type), 0 });
|
callback({ { entry.name, strlen(entry.name) }, to_identifier(fsid(), PDI_Root, 0, (ProcFileType)entry.proc_file_type), 0 });
|
||||||
}
|
}
|
||||||
for (auto pid_child : Process::all_pids()) {
|
for (auto pid_child : Process::all_pids()) {
|
||||||
char name[16];
|
callback({ String::number(pid_child.value()), to_identifier(fsid(), PDI_Root, pid_child, FI_PID), 0 });
|
||||||
size_t name_length = (size_t)snprintf(name, sizeof(name), "%d", pid_child.value());
|
|
||||||
callback({ { name, name_length }, to_identifier(fsid(), PDI_Root, pid_child, FI_PID), 0 });
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1305,9 +1303,7 @@ KResult ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntr
|
||||||
auto description = process->file_description(i);
|
auto description = process->file_description(i);
|
||||||
if (!description)
|
if (!description)
|
||||||
continue;
|
continue;
|
||||||
char name[16];
|
callback({ String::number(i), to_identifier_with_fd(fsid(), pid, i), 0 });
|
||||||
size_t name_length = (size_t)snprintf(name, sizeof(name), "%d", i);
|
|
||||||
callback({ { name, name_length }, to_identifier_with_fd(fsid(), pid, i), 0 });
|
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -1318,9 +1314,7 @@ KResult ProcFSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntr
|
||||||
return ENOENT;
|
return ENOENT;
|
||||||
process->for_each_thread([&](Thread& thread) -> IterationDecision {
|
process->for_each_thread([&](Thread& thread) -> IterationDecision {
|
||||||
int tid = thread.tid().value();
|
int tid = thread.tid().value();
|
||||||
char name[16];
|
callback({ String::number(tid), to_identifier_with_stack(fsid(), tid), 0 });
|
||||||
size_t name_length = (size_t)snprintf(name, sizeof(name), "%d", tid);
|
|
||||||
callback({ { name, name_length }, to_identifier_with_stack(fsid(), tid), 0 });
|
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
});
|
});
|
||||||
} break;
|
} break;
|
||||||
|
|
|
@ -37,7 +37,7 @@ SlavePTY::SlavePTY(MasterPTY& master, unsigned index)
|
||||||
, m_master(master)
|
, m_master(master)
|
||||||
, m_index(index)
|
, m_index(index)
|
||||||
{
|
{
|
||||||
snprintf(m_tty_name, sizeof(m_tty_name), "/dev/pts/%u", m_index);
|
m_tty_name = String::formatted("/dev/pts/{}", m_index);
|
||||||
auto process = Process::current();
|
auto process = Process::current();
|
||||||
set_uid(process->uid());
|
set_uid(process->uid());
|
||||||
set_gid(process->gid());
|
set_gid(process->gid());
|
||||||
|
|
|
@ -66,7 +66,7 @@ private:
|
||||||
RefPtr<MasterPTY> m_master;
|
RefPtr<MasterPTY> m_master;
|
||||||
time_t m_time_of_last_write { 0 };
|
time_t m_time_of_last_write { 0 };
|
||||||
unsigned m_index { 0 };
|
unsigned m_index { 0 };
|
||||||
char m_tty_name[32];
|
String m_tty_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue