summaryrefslogtreecommitdiff
path: root/Userland/Services/SystemServer
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2022-07-11 17:32:29 +0000
committerAndreas Kling <kling@serenityos.org>2022-07-12 23:11:35 +0200
commit3f3f45580ab7266258e97cb3cecf1e24716d61c5 (patch)
tree152c7a187c98184d58bf91a326357e0af435edcf /Userland/Services/SystemServer
parente5f09ea1703bacfbb79a4ad3c587a7d5d3d7bb13 (diff)
downloadserenity-3f3f45580ab7266258e97cb3cecf1e24716d61c5.zip
Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
Diffstat (limited to 'Userland/Services/SystemServer')
-rw-r--r--Userland/Services/SystemServer/Service.cpp2
-rw-r--r--Userland/Services/SystemServer/main.cpp50
2 files changed, 26 insertions, 26 deletions
diff --git a/Userland/Services/SystemServer/Service.cpp b/Userland/Services/SystemServer/Service.cpp
index babd700aa2..0749ca6231 100644
--- a/Userland/Services/SystemServer/Service.cpp
+++ b/Userland/Services/SystemServer/Service.cpp
@@ -411,7 +411,7 @@ ErrorOr<void> Service::determine_account(int fd)
TRY(Core::System::getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &creds, &creds_size));
auto const directory_name = String::formatted("/proc/{}/", creds.pid);
- auto const stat = TRY(Core::System::stat(directory_name.characters()));
+ auto const stat = TRY(Core::System::stat(directory_name));
m_account = TRY(Core::Account::from_uid(stat.st_uid));
return {};
diff --git a/Userland/Services/SystemServer/main.cpp b/Userland/Services/SystemServer/main.cpp
index 795106df20..2759747d44 100644
--- a/Userland/Services/SystemServer/main.cpp
+++ b/Userland/Services/SystemServer/main.cpp
@@ -95,7 +95,7 @@ static ErrorOr<void> chown_all_matching_device_nodes_under_specific_directory(St
auto rc = stat(entry_name.characters(), &cur_file_stat);
if (rc < 0)
continue;
- TRY(Core::System::chown(entry_name.characters(), 0, group.gr_gid));
+ TRY(Core::System::chown(entry_name, 0, group.gr_gid));
}
return {};
}
@@ -114,7 +114,7 @@ static ErrorOr<void> chown_all_matching_device_nodes(group const& group, unsigne
continue;
if (major(cur_file_stat.st_rdev) != major_number)
continue;
- TRY(Core::System::chown(entry_name.characters(), 0, group.gr_gid));
+ TRY(Core::System::chown(entry_name, 0, group.gr_gid));
}
return {};
}
@@ -370,35 +370,35 @@ static void populate_devtmpfs()
static ErrorOr<void> prepare_synthetic_filesystems()
{
// FIXME: Find a better way to all of this stuff, without hardcoding all of this!
- TRY(Core::System::mount(-1, "/proc", "proc", MS_NOSUID));
- TRY(Core::System::mount(-1, "/sys", "sys", 0));
- TRY(Core::System::mount(-1, "/dev", "dev", 0));
+ TRY(Core::System::mount(-1, "/proc"sv, "proc"sv, MS_NOSUID));
+ TRY(Core::System::mount(-1, "/sys"sv, "sys"sv, 0));
+ TRY(Core::System::mount(-1, "/dev"sv, "dev"sv, 0));
- TRY(Core::System::mkdir("/dev/audio", 0755));
+ TRY(Core::System::mkdir("/dev/audio"sv, 0755));
- TRY(Core::System::symlink("/proc/self/fd/0", "/dev/stdin"));
- TRY(Core::System::symlink("/proc/self/fd/1", "/dev/stdout"));
- TRY(Core::System::symlink("/proc/self/fd/2", "/dev/stderr"));
+ TRY(Core::System::symlink("/proc/self/fd/0"sv, "/dev/stdin"sv));
+ TRY(Core::System::symlink("/proc/self/fd/1"sv, "/dev/stdout"sv));
+ TRY(Core::System::symlink("/proc/self/fd/2"sv, "/dev/stderr"sv));
- TRY(Core::System::mkdir("/dev/gpu", 0755));
+ TRY(Core::System::mkdir("/dev/gpu"sv, 0755));
populate_devtmpfs();
- TRY(Core::System::mkdir("/dev/pts", 0755));
+ TRY(Core::System::mkdir("/dev/pts"sv, 0755));
- TRY(Core::System::mount(-1, "/dev/pts", "devpts", 0));
+ TRY(Core::System::mount(-1, "/dev/pts"sv, "devpts"sv, 0));
- TRY(Core::System::symlink("/dev/random", "/dev/urandom"));
+ TRY(Core::System::symlink("/dev/random"sv, "/dev/urandom"sv));
- TRY(Core::System::chmod("/dev/urandom", 0666));
+ TRY(Core::System::chmod("/dev/urandom"sv, 0666));
- auto phys_group = TRY(Core::System::getgrnam("phys"));
+ auto phys_group = TRY(Core::System::getgrnam("phys"sv));
VERIFY(phys_group.has_value());
// FIXME: Try to find a way to not hardcode the major number of framebuffer device nodes.
TRY(chown_all_matching_device_nodes(phys_group.value(), 29));
auto const filter_chown_ENOENT = [](ErrorOr<void> result) -> ErrorOr<void> {
- auto const chown_enoent = Error::from_syscall("chown", -ENOENT);
+ auto const chown_enoent = Error::from_syscall("chown"sv, -ENOENT);
if (result.is_error() && result.error() == chown_enoent) {
dbgln("{}", result.release_error());
return {};
@@ -406,18 +406,18 @@ static ErrorOr<void> prepare_synthetic_filesystems()
return result;
};
- TRY(filter_chown_ENOENT(Core::System::chown("/dev/keyboard0", 0, phys_group.value().gr_gid)));
- TRY(filter_chown_ENOENT(Core::System::chown("/dev/mouse0", 0, phys_group.value().gr_gid)));
+ TRY(filter_chown_ENOENT(Core::System::chown("/dev/keyboard0"sv, 0, phys_group.value().gr_gid)));
+ TRY(filter_chown_ENOENT(Core::System::chown("/dev/mouse0"sv, 0, phys_group.value().gr_gid)));
- auto tty_group = TRY(Core::System::getgrnam("tty"));
+ auto tty_group = TRY(Core::System::getgrnam("tty"sv));
VERIFY(tty_group.has_value());
// FIXME: Try to find a way to not hardcode the major number of tty nodes.
TRY(chown_all_matching_device_nodes(tty_group.release_value(), 4));
- auto audio_group = TRY(Core::System::getgrnam("audio"));
+ auto audio_group = TRY(Core::System::getgrnam("audio"sv));
VERIFY(audio_group.has_value());
- TRY(Core::System::chown("/dev/audio", 0, audio_group->gr_gid));
- TRY(chown_all_matching_device_nodes_under_specific_directory("/dev/audio", audio_group.release_value()));
+ TRY(Core::System::chown("/dev/audio"sv, 0, audio_group->gr_gid));
+ TRY(chown_all_matching_device_nodes_under_specific_directory("/dev/audio"sv, audio_group.release_value()));
// Note: We open the /dev/null device and set file descriptors 0, 1, 2 to it
// because otherwise these file descriptors won't have a custody, making
@@ -426,7 +426,7 @@ static ErrorOr<void> prepare_synthetic_filesystems()
// This affects also every other process that inherits the file descriptors
// from SystemServer, so it is important for other things (also for ProcFS
// tests that are running in CI mode).
- int stdin_new_fd = TRY(Core::System::open("/dev/null", O_NONBLOCK));
+ int stdin_new_fd = TRY(Core::System::open("/dev/null"sv, O_NONBLOCK));
TRY(Core::System::dup2(stdin_new_fd, 0));
TRY(Core::System::dup2(stdin_new_fd, 1));
@@ -442,7 +442,7 @@ static ErrorOr<void> mount_all_filesystems()
pid_t pid = TRY(Core::System::fork());
if (pid == 0)
- TRY(Core::System::exec("/bin/mount", Vector<StringView> { "mount", "-a" }, Core::System::SearchInPath::No));
+ TRY(Core::System::exec("/bin/mount"sv, Vector { "mount"sv, "-a"sv }, Core::System::SearchInPath::No));
wait(nullptr);
return {};
@@ -453,7 +453,7 @@ static ErrorOr<void> create_tmp_coredump_directory()
dbgln("Creating /tmp/coredump directory");
auto old_umask = umask(0);
// FIXME: the coredump directory should be made read-only once CrashDaemon is no longer responsible for compressing coredumps
- TRY(Core::System::mkdir("/tmp/coredump", 0777));
+ TRY(Core::System::mkdir("/tmp/coredump"sv, 0777));
umask(old_umask);
return {};
}