mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 22:27:35 +00:00
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.
This commit is contained in:
parent
e5f09ea170
commit
3f3f45580a
762 changed files with 8315 additions and 8316 deletions
|
@ -32,7 +32,7 @@ static String get_salt()
|
|||
fill_with_random(random_data, sizeof(random_data));
|
||||
|
||||
StringBuilder builder;
|
||||
builder.append("$5$");
|
||||
builder.append("$5$"sv);
|
||||
builder.append(encode_base64(ReadonlyBytes(random_data, sizeof(random_data))));
|
||||
|
||||
return builder.build();
|
||||
|
|
|
@ -743,7 +743,7 @@ void ArgsParser::autocomplete(FILE* file, StringView program_name, Span<char con
|
|||
continue;
|
||||
}
|
||||
|
||||
if (argument.starts_with("--")) {
|
||||
if (argument.starts_with("--"sv)) {
|
||||
option_to_complete = argument;
|
||||
completing_option = true;
|
||||
|
||||
|
@ -799,7 +799,7 @@ void ArgsParser::autocomplete(FILE* file, StringView program_name, Span<char con
|
|||
outln(file, "{}", object.to_string());
|
||||
};
|
||||
|
||||
if (option_to_complete.starts_with("--")) {
|
||||
if (option_to_complete.starts_with("--"sv)) {
|
||||
// Complete a long option.
|
||||
auto option_pattern = option_to_complete.substring_view(2);
|
||||
for (auto& option : m_options) {
|
||||
|
|
|
@ -173,7 +173,7 @@ String DateTime::to_string(StringView format) const
|
|||
builder.append('\n');
|
||||
break;
|
||||
case 'p':
|
||||
builder.append(tm.tm_hour < 12 ? "AM" : "PM");
|
||||
builder.append(tm.tm_hour < 12 ? "AM"sv : "PM"sv);
|
||||
break;
|
||||
case 'r': {
|
||||
int display_hour = tm.tm_hour % 12;
|
||||
|
@ -240,11 +240,11 @@ String DateTime::to_string(StringView format) const
|
|||
break;
|
||||
case ':':
|
||||
if (++i == format_len) {
|
||||
builder.append("%:");
|
||||
builder.append("%:"sv);
|
||||
break;
|
||||
}
|
||||
if (format[i] != 'z') {
|
||||
builder.append("%:");
|
||||
builder.append("%:"sv);
|
||||
builder.append(format[i]);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ public:
|
|||
|
||||
void handle_request(JsonObject const& request)
|
||||
{
|
||||
auto type = request.get("type").as_string_or({});
|
||||
auto type = request.get("type"sv).as_string_or({});
|
||||
|
||||
if (type.is_null()) {
|
||||
dbgln("RPC client sent request without type field");
|
||||
|
@ -255,7 +255,7 @@ public:
|
|||
}
|
||||
|
||||
if (type == "SetInspectedObject") {
|
||||
auto address = request.get("address").to_number<FlatPtr>();
|
||||
auto address = request.get("address"sv).to_number<FlatPtr>();
|
||||
for (auto& object : Object::all_objects()) {
|
||||
if ((FlatPtr)&object == address) {
|
||||
if (auto inspected_object = m_inspected_object.strong_ref())
|
||||
|
@ -269,10 +269,10 @@ public:
|
|||
}
|
||||
|
||||
if (type == "SetProperty") {
|
||||
auto address = request.get("address").to_number<FlatPtr>();
|
||||
auto address = request.get("address"sv).to_number<FlatPtr>();
|
||||
for (auto& object : Object::all_objects()) {
|
||||
if ((FlatPtr)&object == address) {
|
||||
bool success = object.set_property(request.get("name").to_string(), request.get("value"));
|
||||
bool success = object.set_property(request.get("name"sv).to_string(), request.get("value"sv));
|
||||
JsonObject response;
|
||||
response.set("type", "SetProperty");
|
||||
response.set("success", success);
|
||||
|
|
|
@ -87,7 +87,7 @@ template<>
|
|||
struct Formatter<Core::FileWatcherEvent> : Formatter<FormatString> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Core::FileWatcherEvent const& value)
|
||||
{
|
||||
return Formatter<FormatString>::format(builder, "FileWatcherEvent(\"{}\", {})", value.event_path, value.type);
|
||||
return Formatter<FormatString>::format(builder, "FileWatcherEvent(\"{}\", {})"sv, value.event_path, value.type);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -95,22 +95,22 @@ template<>
|
|||
struct Formatter<Core::FileWatcherEvent::Type> : Formatter<FormatString> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Core::FileWatcherEvent::Type const& value)
|
||||
{
|
||||
char const* type;
|
||||
StringView type;
|
||||
switch (value) {
|
||||
case Core::FileWatcherEvent::Type::ChildCreated:
|
||||
type = "ChildCreated";
|
||||
type = "ChildCreated"sv;
|
||||
break;
|
||||
case Core::FileWatcherEvent::Type::ChildDeleted:
|
||||
type = "ChildDeleted";
|
||||
type = "ChildDeleted"sv;
|
||||
break;
|
||||
case Core::FileWatcherEvent::Type::Deleted:
|
||||
type = "Deleted";
|
||||
type = "Deleted"sv;
|
||||
break;
|
||||
case Core::FileWatcherEvent::Type::ContentModified:
|
||||
type = "ContentModified";
|
||||
type = "ContentModified"sv;
|
||||
break;
|
||||
case Core::FileWatcherEvent::Type::MetadataModified:
|
||||
type = "MetadataModified";
|
||||
type = "MetadataModified"sv;
|
||||
break;
|
||||
default:
|
||||
VERIFY_NOT_REACHED();
|
||||
|
|
|
@ -120,7 +120,7 @@ ErrorOr<NonnullOwnPtr<Stream::LocalSocket>> LocalServer::accept()
|
|||
int accepted_fd = ::accept(m_fd, (sockaddr*)&un, &un_size);
|
||||
#endif
|
||||
if (accepted_fd < 0) {
|
||||
return Error::from_syscall("accept", -errno);
|
||||
return Error::from_syscall("accept"sv, -errno);
|
||||
}
|
||||
|
||||
#ifdef AK_OS_MACOS
|
||||
|
|
|
@ -53,54 +53,54 @@ void MimeData::set_text(String const& text)
|
|||
|
||||
String guess_mime_type_based_on_filename(StringView path)
|
||||
{
|
||||
if (path.ends_with(".pbm", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".pbm"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "image/x‑portable‑bitmap";
|
||||
if (path.ends_with(".pgm", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".pgm"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "image/x‑portable‑graymap";
|
||||
if (path.ends_with(".png", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".png"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "image/png";
|
||||
if (path.ends_with(".ppm", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".ppm"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "image/x‑portable‑pixmap";
|
||||
if (path.ends_with(".gif", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".gif"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "image/gif";
|
||||
if (path.ends_with(".bmp", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".bmp"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "image/bmp";
|
||||
if (path.ends_with(".jpg", CaseSensitivity::CaseInsensitive) || path.ends_with(".jpeg", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".jpg"sv, CaseSensitivity::CaseInsensitive) || path.ends_with(".jpeg"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "image/jpeg";
|
||||
if (path.ends_with(".qoi", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".qoi"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "image/x-qoi";
|
||||
if (path.ends_with(".svg", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".svg"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "image/svg+xml";
|
||||
if (path.ends_with(".md", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".md"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "text/markdown";
|
||||
if (path.ends_with(".html", CaseSensitivity::CaseInsensitive) || path.ends_with(".htm", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".html"sv, CaseSensitivity::CaseInsensitive) || path.ends_with(".htm"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "text/html";
|
||||
if (path.ends_with(".css", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".css"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "text/css";
|
||||
if (path.ends_with(".js", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".js"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "application/javascript";
|
||||
if (path.ends_with(".json", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".json"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "application/json";
|
||||
if (path.ends_with(".zip", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".zip"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "application/zip";
|
||||
if (path.ends_with(".md", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".md"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "text/markdown";
|
||||
if (path.ends_with("/", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with("/"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "text/html";
|
||||
if (path.ends_with(".csv", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".csv"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "text/csv";
|
||||
if (path.ends_with(".sheets", CaseSensitivity::CaseInsensitive))
|
||||
if (path.ends_with(".sheets"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "application/x-sheets+json";
|
||||
// FIXME: Share this, TextEditor and HackStudio language detection somehow.
|
||||
auto basename = LexicalPath::basename(path);
|
||||
if (path.ends_with(".cpp", CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".c", CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".hpp", CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".h", CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".gml", CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".ini", CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".ipc", CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".txt", CaseSensitivity::CaseInsensitive)
|
||||
if (path.ends_with(".cpp"sv, CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".c"sv, CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".hpp"sv, CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".h"sv, CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".gml"sv, CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".ini"sv, CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".ipc"sv, CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".txt"sv, CaseSensitivity::CaseInsensitive)
|
||||
|| basename == "CMakeLists.txt"
|
||||
|| basename == ".history"
|
||||
|| basename == ".shellrc")
|
||||
|
|
|
@ -22,18 +22,18 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
#define REGISTER_ABSTRACT_CORE_OBJECT(namespace_, class_name) \
|
||||
namespace Core { \
|
||||
namespace Registration { \
|
||||
Core::ObjectClassRegistration registration_##class_name(#namespace_ "::" #class_name, []() { return RefPtr<Object>(); }); \
|
||||
} \
|
||||
#define REGISTER_ABSTRACT_CORE_OBJECT(namespace_, class_name) \
|
||||
namespace Core { \
|
||||
namespace Registration { \
|
||||
Core::ObjectClassRegistration registration_##class_name(#namespace_ "::" #class_name##sv, []() { return RefPtr<Object>(); }); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define REGISTER_CORE_OBJECT(namespace_, class_name) \
|
||||
namespace Core { \
|
||||
namespace Registration { \
|
||||
Core::ObjectClassRegistration registration_##class_name(#namespace_ "::" #class_name, []() { return namespace_::class_name::construct(); }); \
|
||||
} \
|
||||
#define REGISTER_CORE_OBJECT(namespace_, class_name) \
|
||||
namespace Core { \
|
||||
namespace Registration { \
|
||||
Core::ObjectClassRegistration registration_##class_name(#namespace_ "::" #class_name##sv, []() { return namespace_::class_name::construct(); }); \
|
||||
} \
|
||||
}
|
||||
|
||||
class ObjectClassRegistration {
|
||||
|
@ -67,7 +67,7 @@ enum class TimerShouldFireWhenNotVisible {
|
|||
|
||||
#define C_OBJECT(klass) \
|
||||
public: \
|
||||
virtual StringView class_name() const override { return #klass; } \
|
||||
virtual StringView class_name() const override { return #klass##sv; } \
|
||||
template<typename Klass = klass, class... Args> \
|
||||
static NonnullRefPtr<klass> construct(Args&&... args) \
|
||||
{ \
|
||||
|
@ -81,7 +81,7 @@ public:
|
|||
|
||||
#define C_OBJECT_ABSTRACT(klass) \
|
||||
public: \
|
||||
virtual StringView class_name() const override { return #klass; }
|
||||
virtual StringView class_name() const override { return #klass##sv; }
|
||||
|
||||
class Object
|
||||
: public RefCounted<Object>
|
||||
|
@ -215,7 +215,7 @@ template<>
|
|||
struct AK::Formatter<Core::Object> : AK::Formatter<FormatString> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Core::Object const& value)
|
||||
{
|
||||
return AK::Formatter<FormatString>::format(builder, "{}({})", value.class_name(), &value);
|
||||
return AK::Formatter<FormatString>::format(builder, "{}({})"sv, value.class_name(), &value);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -306,28 +306,28 @@ T* Object::find_descendant_of_type_named(String const& name) requires IsBaseOf<O
|
|||
}, \
|
||||
{});
|
||||
|
||||
#define REGISTER_RECT_PROPERTY(property_name, getter, setter) \
|
||||
register_property( \
|
||||
property_name, \
|
||||
[this] { \
|
||||
auto rect = this->getter(); \
|
||||
JsonObject rect_object; \
|
||||
rect_object.set("x", rect.x()); \
|
||||
rect_object.set("y", rect.y()); \
|
||||
rect_object.set("width", rect.width()); \
|
||||
rect_object.set("height", rect.height()); \
|
||||
return rect_object; \
|
||||
}, \
|
||||
[this](auto& value) { \
|
||||
if (!value.is_object()) \
|
||||
return false; \
|
||||
Gfx::IntRect rect; \
|
||||
rect.set_x(value.as_object().get("x").to_i32()); \
|
||||
rect.set_y(value.as_object().get("y").to_i32()); \
|
||||
rect.set_width(value.as_object().get("width").to_i32()); \
|
||||
rect.set_height(value.as_object().get("height").to_i32()); \
|
||||
setter(rect); \
|
||||
return true; \
|
||||
#define REGISTER_RECT_PROPERTY(property_name, getter, setter) \
|
||||
register_property( \
|
||||
property_name, \
|
||||
[this] { \
|
||||
auto rect = this->getter(); \
|
||||
JsonObject rect_object; \
|
||||
rect_object.set("x"sv, rect.x()); \
|
||||
rect_object.set("y"sv, rect.y()); \
|
||||
rect_object.set("width"sv, rect.width()); \
|
||||
rect_object.set("height"sv, rect.height()); \
|
||||
return rect_object; \
|
||||
}, \
|
||||
[this](auto& value) { \
|
||||
if (!value.is_object()) \
|
||||
return false; \
|
||||
Gfx::IntRect rect; \
|
||||
rect.set_x(value.as_object().get("x"sv).to_i32()); \
|
||||
rect.set_y(value.as_object().get("y"sv).to_i32()); \
|
||||
rect.set_width(value.as_object().get("width"sv).to_i32()); \
|
||||
rect.set_height(value.as_object().get("height"sv).to_i32()); \
|
||||
setter(rect); \
|
||||
return true; \
|
||||
});
|
||||
|
||||
#define REGISTER_SIZE_PROPERTY(property_name, getter, setter) \
|
||||
|
|
|
@ -39,56 +39,56 @@ Optional<AllProcessesStatistics> ProcessStatisticsReader::get_all(RefPtr<Core::F
|
|||
return {};
|
||||
|
||||
auto& json_obj = json.value().as_object();
|
||||
json_obj.get("processes").as_array().for_each([&](auto& value) {
|
||||
json_obj.get("processes"sv).as_array().for_each([&](auto& value) {
|
||||
const JsonObject& process_object = value.as_object();
|
||||
Core::ProcessStatistics process;
|
||||
|
||||
// kernel data first
|
||||
process.pid = process_object.get("pid").to_u32();
|
||||
process.pgid = process_object.get("pgid").to_u32();
|
||||
process.pgp = process_object.get("pgp").to_u32();
|
||||
process.sid = process_object.get("sid").to_u32();
|
||||
process.uid = process_object.get("uid").to_u32();
|
||||
process.gid = process_object.get("gid").to_u32();
|
||||
process.ppid = process_object.get("ppid").to_u32();
|
||||
process.nfds = process_object.get("nfds").to_u32();
|
||||
process.kernel = process_object.get("kernel").to_bool();
|
||||
process.name = process_object.get("name").to_string();
|
||||
process.executable = process_object.get("executable").to_string();
|
||||
process.tty = process_object.get("tty").to_string();
|
||||
process.pledge = process_object.get("pledge").to_string();
|
||||
process.veil = process_object.get("veil").to_string();
|
||||
process.amount_virtual = process_object.get("amount_virtual").to_u32();
|
||||
process.amount_resident = process_object.get("amount_resident").to_u32();
|
||||
process.amount_shared = process_object.get("amount_shared").to_u32();
|
||||
process.amount_dirty_private = process_object.get("amount_dirty_private").to_u32();
|
||||
process.amount_clean_inode = process_object.get("amount_clean_inode").to_u32();
|
||||
process.amount_purgeable_volatile = process_object.get("amount_purgeable_volatile").to_u32();
|
||||
process.amount_purgeable_nonvolatile = process_object.get("amount_purgeable_nonvolatile").to_u32();
|
||||
process.pid = process_object.get("pid"sv).to_u32();
|
||||
process.pgid = process_object.get("pgid"sv).to_u32();
|
||||
process.pgp = process_object.get("pgp"sv).to_u32();
|
||||
process.sid = process_object.get("sid"sv).to_u32();
|
||||
process.uid = process_object.get("uid"sv).to_u32();
|
||||
process.gid = process_object.get("gid"sv).to_u32();
|
||||
process.ppid = process_object.get("ppid"sv).to_u32();
|
||||
process.nfds = process_object.get("nfds"sv).to_u32();
|
||||
process.kernel = process_object.get("kernel"sv).to_bool();
|
||||
process.name = process_object.get("name"sv).to_string();
|
||||
process.executable = process_object.get("executable"sv).to_string();
|
||||
process.tty = process_object.get("tty"sv).to_string();
|
||||
process.pledge = process_object.get("pledge"sv).to_string();
|
||||
process.veil = process_object.get("veil"sv).to_string();
|
||||
process.amount_virtual = process_object.get("amount_virtual"sv).to_u32();
|
||||
process.amount_resident = process_object.get("amount_resident"sv).to_u32();
|
||||
process.amount_shared = process_object.get("amount_shared"sv).to_u32();
|
||||
process.amount_dirty_private = process_object.get("amount_dirty_private"sv).to_u32();
|
||||
process.amount_clean_inode = process_object.get("amount_clean_inode"sv).to_u32();
|
||||
process.amount_purgeable_volatile = process_object.get("amount_purgeable_volatile"sv).to_u32();
|
||||
process.amount_purgeable_nonvolatile = process_object.get("amount_purgeable_nonvolatile"sv).to_u32();
|
||||
|
||||
auto& thread_array = process_object.get_ptr("threads")->as_array();
|
||||
auto& thread_array = process_object.get_ptr("threads"sv)->as_array();
|
||||
process.threads.ensure_capacity(thread_array.size());
|
||||
thread_array.for_each([&](auto& value) {
|
||||
auto& thread_object = value.as_object();
|
||||
Core::ThreadStatistics thread;
|
||||
thread.tid = thread_object.get("tid").to_u32();
|
||||
thread.times_scheduled = thread_object.get("times_scheduled").to_u32();
|
||||
thread.name = thread_object.get("name").to_string();
|
||||
thread.state = thread_object.get("state").to_string();
|
||||
thread.time_user = thread_object.get("time_user").to_u64();
|
||||
thread.time_kernel = thread_object.get("time_kernel").to_u64();
|
||||
thread.cpu = thread_object.get("cpu").to_u32();
|
||||
thread.priority = thread_object.get("priority").to_u32();
|
||||
thread.syscall_count = thread_object.get("syscall_count").to_u32();
|
||||
thread.inode_faults = thread_object.get("inode_faults").to_u32();
|
||||
thread.zero_faults = thread_object.get("zero_faults").to_u32();
|
||||
thread.cow_faults = thread_object.get("cow_faults").to_u32();
|
||||
thread.unix_socket_read_bytes = thread_object.get("unix_socket_read_bytes").to_u32();
|
||||
thread.unix_socket_write_bytes = thread_object.get("unix_socket_write_bytes").to_u32();
|
||||
thread.ipv4_socket_read_bytes = thread_object.get("ipv4_socket_read_bytes").to_u32();
|
||||
thread.ipv4_socket_write_bytes = thread_object.get("ipv4_socket_write_bytes").to_u32();
|
||||
thread.file_read_bytes = thread_object.get("file_read_bytes").to_u32();
|
||||
thread.file_write_bytes = thread_object.get("file_write_bytes").to_u32();
|
||||
thread.tid = thread_object.get("tid"sv).to_u32();
|
||||
thread.times_scheduled = thread_object.get("times_scheduled"sv).to_u32();
|
||||
thread.name = thread_object.get("name"sv).to_string();
|
||||
thread.state = thread_object.get("state"sv).to_string();
|
||||
thread.time_user = thread_object.get("time_user"sv).to_u64();
|
||||
thread.time_kernel = thread_object.get("time_kernel"sv).to_u64();
|
||||
thread.cpu = thread_object.get("cpu"sv).to_u32();
|
||||
thread.priority = thread_object.get("priority"sv).to_u32();
|
||||
thread.syscall_count = thread_object.get("syscall_count"sv).to_u32();
|
||||
thread.inode_faults = thread_object.get("inode_faults"sv).to_u32();
|
||||
thread.zero_faults = thread_object.get("zero_faults"sv).to_u32();
|
||||
thread.cow_faults = thread_object.get("cow_faults"sv).to_u32();
|
||||
thread.unix_socket_read_bytes = thread_object.get("unix_socket_read_bytes"sv).to_u32();
|
||||
thread.unix_socket_write_bytes = thread_object.get("unix_socket_write_bytes"sv).to_u32();
|
||||
thread.ipv4_socket_read_bytes = thread_object.get("ipv4_socket_read_bytes"sv).to_u32();
|
||||
thread.ipv4_socket_write_bytes = thread_object.get("ipv4_socket_write_bytes"sv).to_u32();
|
||||
thread.file_read_bytes = thread_object.get("file_read_bytes"sv).to_u32();
|
||||
thread.file_write_bytes = thread_object.get("file_write_bytes"sv).to_u32();
|
||||
process.threads.append(move(thread));
|
||||
});
|
||||
|
||||
|
@ -97,8 +97,8 @@ Optional<AllProcessesStatistics> ProcessStatisticsReader::get_all(RefPtr<Core::F
|
|||
all_processes_statistics.processes.append(move(process));
|
||||
});
|
||||
|
||||
all_processes_statistics.total_time_scheduled = json_obj.get("total_time").to_u64();
|
||||
all_processes_statistics.total_time_scheduled_kernel = json_obj.get("total_time_kernel").to_u64();
|
||||
all_processes_statistics.total_time_scheduled = json_obj.get("total_time"sv).to_u64();
|
||||
all_processes_statistics.total_time_scheduled_kernel = json_obj.get("total_time_kernel"sv).to_u64();
|
||||
return all_processes_statistics;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,23 +74,23 @@ StringView reply_response_name(Reply reply)
|
|||
{
|
||||
switch (reply) {
|
||||
case Reply::Succeeded:
|
||||
return "Succeeded";
|
||||
return "Succeeded"sv;
|
||||
case Reply::GeneralSocksServerFailure:
|
||||
return "GeneralSocksServerFailure";
|
||||
return "GeneralSocksServerFailure"sv;
|
||||
case Reply::ConnectionNotAllowedByRuleset:
|
||||
return "ConnectionNotAllowedByRuleset";
|
||||
return "ConnectionNotAllowedByRuleset"sv;
|
||||
case Reply::NetworkUnreachable:
|
||||
return "NetworkUnreachable";
|
||||
return "NetworkUnreachable"sv;
|
||||
case Reply::HostUnreachable:
|
||||
return "HostUnreachable";
|
||||
return "HostUnreachable"sv;
|
||||
case Reply::ConnectionRefused:
|
||||
return "ConnectionRefused";
|
||||
return "ConnectionRefused"sv;
|
||||
case Reply::TTLExpired:
|
||||
return "TTLExpired";
|
||||
return "TTLExpired"sv;
|
||||
case Reply::CommandNotSupported:
|
||||
return "CommandNotSupported";
|
||||
return "CommandNotSupported"sv;
|
||||
case Reply::AddressTypeNotSupported:
|
||||
return "AddressTypeNotSupported";
|
||||
return "AddressTypeNotSupported"sv;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ String StandardPaths::desktop_directory()
|
|||
{
|
||||
StringBuilder builder;
|
||||
builder.append(home_directory());
|
||||
builder.append("/Desktop");
|
||||
builder.append("/Desktop"sv);
|
||||
return LexicalPath::canonicalized_path(builder.to_string());
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ String StandardPaths::downloads_directory()
|
|||
{
|
||||
StringBuilder builder;
|
||||
builder.append(home_directory());
|
||||
builder.append("/Downloads");
|
||||
builder.append("/Downloads"sv);
|
||||
return LexicalPath::canonicalized_path(builder.to_string());
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ String StandardPaths::config_directory()
|
|||
{
|
||||
StringBuilder builder;
|
||||
builder.append(home_directory());
|
||||
builder.append("/.config");
|
||||
builder.append("/.config"sv);
|
||||
return LexicalPath::canonicalized_path(builder.to_string());
|
||||
}
|
||||
|
||||
|
|
|
@ -333,7 +333,7 @@ ErrorOr<IPv4Address> Socket::resolve_host(String const& host, SocketType type)
|
|||
int rc = getaddrinfo(host.characters(), nullptr, &hints, &results);
|
||||
if (rc != 0) {
|
||||
if (rc == EAI_SYSTEM) {
|
||||
return Error::from_syscall("getaddrinfo", -errno);
|
||||
return Error::from_syscall("getaddrinfo"sv, -errno);
|
||||
}
|
||||
|
||||
auto const* error_string = gai_strerror(rc);
|
||||
|
@ -423,7 +423,7 @@ ErrorOr<bool> PosixSocketHelper::can_read_without_blocking(int timeout) const
|
|||
} while (rc < 0 && errno == EINTR);
|
||||
|
||||
if (rc < 0) {
|
||||
return Error::from_syscall("poll", -errno);
|
||||
return Error::from_syscall("poll"sv, -errno);
|
||||
}
|
||||
|
||||
return (the_fd.revents & POLLIN) > 0;
|
||||
|
|
|
@ -44,7 +44,7 @@ static int memfd_create(char const* name, unsigned int flags)
|
|||
|
||||
#define HANDLE_SYSCALL_RETURN_VALUE(syscall_name, rc, success_value) \
|
||||
if ((rc) < 0) { \
|
||||
return Error::from_syscall(syscall_name, rc); \
|
||||
return Error::from_syscall(syscall_name##sv, rc); \
|
||||
} \
|
||||
return success_value;
|
||||
|
||||
|
@ -75,7 +75,7 @@ ErrorOr<void> pledge(StringView promises, StringView execpromises)
|
|||
{ execpromises.characters_without_null_termination(), execpromises.length() },
|
||||
};
|
||||
int rc = syscall(SC_pledge, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("pledge"sv, rc, {});
|
||||
HANDLE_SYSCALL_RETURN_VALUE("pledge", rc, {});
|
||||
}
|
||||
|
||||
ErrorOr<void> unveil(StringView path, StringView permissions)
|
||||
|
@ -85,7 +85,7 @@ ErrorOr<void> unveil(StringView path, StringView permissions)
|
|||
{ permissions.characters_without_null_termination(), permissions.length() },
|
||||
};
|
||||
int rc = syscall(SC_unveil, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("unveil"sv, rc, {});
|
||||
HANDLE_SYSCALL_RETURN_VALUE("unveil", rc, {});
|
||||
}
|
||||
|
||||
ErrorOr<void> sendfd(int sockfd, int fd)
|
||||
|
@ -342,7 +342,7 @@ ErrorOr<int> openat(int fd, StringView path, int options, mode_t mode)
|
|||
#ifdef __serenity__
|
||||
Syscall::SC_open_params params { fd, { path.characters_without_null_termination(), path.length() }, options, mode };
|
||||
int rc = syscall(SC_open, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("open"sv, rc, rc);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("open", rc, rc);
|
||||
#else
|
||||
// NOTE: We have to ensure that the path is null-terminated.
|
||||
String path_string = path;
|
||||
|
@ -376,7 +376,7 @@ ErrorOr<struct stat> stat(StringView path)
|
|||
#ifdef __serenity__
|
||||
Syscall::SC_stat_params params { { path.characters_without_null_termination(), path.length() }, &st, AT_FDCWD, true };
|
||||
int rc = syscall(SC_stat, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("stat"sv, rc, st);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("stat", rc, st);
|
||||
#else
|
||||
String path_string = path;
|
||||
if (::stat(path_string.characters(), &st) < 0)
|
||||
|
@ -394,7 +394,7 @@ ErrorOr<struct stat> lstat(StringView path)
|
|||
#ifdef __serenity__
|
||||
Syscall::SC_stat_params params { { path.characters_without_null_termination(), path.length() }, &st, AT_FDCWD, false };
|
||||
int rc = syscall(SC_stat, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("lstat"sv, rc, st);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("lstat", rc, st);
|
||||
#else
|
||||
String path_string = path;
|
||||
if (::stat(path_string.characters(), &st) < 0)
|
||||
|
@ -532,7 +532,7 @@ ErrorOr<void> chmod(StringView pathname, mode_t mode)
|
|||
true
|
||||
};
|
||||
int rc = syscall(SC_chmod, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("chmod"sv, rc, {});
|
||||
HANDLE_SYSCALL_RETURN_VALUE("chmod", rc, {});
|
||||
#else
|
||||
String path = pathname;
|
||||
if (::chmod(path.characters(), mode) < 0)
|
||||
|
@ -563,7 +563,7 @@ ErrorOr<void> lchown(StringView pathname, uid_t uid, gid_t gid)
|
|||
#ifdef __serenity__
|
||||
Syscall::SC_chown_params params = { { pathname.characters_without_null_termination(), pathname.length() }, uid, gid, AT_FDCWD, false };
|
||||
int rc = syscall(SC_chown, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("chown"sv, rc, {});
|
||||
HANDLE_SYSCALL_RETURN_VALUE("chown", rc, {});
|
||||
#else
|
||||
String path = pathname;
|
||||
if (::chown(path.characters(), uid, gid) < 0)
|
||||
|
@ -580,7 +580,7 @@ ErrorOr<void> chown(StringView pathname, uid_t uid, gid_t gid)
|
|||
#ifdef __serenity__
|
||||
Syscall::SC_chown_params params = { { pathname.characters_without_null_termination(), pathname.length() }, uid, gid, AT_FDCWD, true };
|
||||
int rc = syscall(SC_chown, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("chown"sv, rc, {});
|
||||
HANDLE_SYSCALL_RETURN_VALUE("chown", rc, {});
|
||||
#else
|
||||
String path = pathname;
|
||||
if (::lchown(path.characters(), uid, gid) < 0)
|
||||
|
@ -653,7 +653,7 @@ ErrorOr<void> clock_settime(clockid_t clock_id, struct timespec* ts)
|
|||
{
|
||||
#ifdef __serenity__
|
||||
int rc = syscall(SC_clock_settime, clock_id, ts);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("clocksettime"sv, rc, {});
|
||||
HANDLE_SYSCALL_RETURN_VALUE("clocksettime", rc, {});
|
||||
#else
|
||||
if (::clock_settime(clock_id, ts) < 0)
|
||||
return Error::from_syscall("clocksettime"sv, -errno);
|
||||
|
@ -683,7 +683,7 @@ ErrorOr<off_t> lseek(int fd, off_t offset, int whence)
|
|||
{
|
||||
off_t rc = ::lseek(fd, offset, whence);
|
||||
if (rc < 0)
|
||||
return Error::from_syscall("lseek", -errno);
|
||||
return Error::from_syscall("lseek"sv, -errno);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -693,7 +693,7 @@ ErrorOr<void> endgrent()
|
|||
swap(old_errno, errno);
|
||||
::endgrent();
|
||||
if (errno != 0)
|
||||
return Error::from_syscall("endgrent", -errno);
|
||||
return Error::from_syscall("endgrent"sv, -errno);
|
||||
errno = old_errno;
|
||||
return {};
|
||||
}
|
||||
|
@ -777,7 +777,7 @@ ErrorOr<void> symlink(StringView target, StringView link_path)
|
|||
.linkpath = { link_path.characters_without_null_termination(), link_path.length() },
|
||||
};
|
||||
int rc = syscall(SC_symlink, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("symlink"sv, rc, {});
|
||||
HANDLE_SYSCALL_RETURN_VALUE("symlink", rc, {});
|
||||
#else
|
||||
String target_string = target;
|
||||
String link_path_string = link_path;
|
||||
|
@ -793,7 +793,7 @@ ErrorOr<void> mkdir(StringView path, mode_t mode)
|
|||
return Error::from_errno(EFAULT);
|
||||
#ifdef __serenity__
|
||||
int rc = syscall(SC_mkdir, path.characters_without_null_termination(), path.length(), mode);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("mkdir"sv, rc, {});
|
||||
HANDLE_SYSCALL_RETURN_VALUE("mkdir", rc, {});
|
||||
#else
|
||||
String path_string = path;
|
||||
if (::mkdir(path_string.characters(), mode) < 0)
|
||||
|
@ -808,7 +808,7 @@ ErrorOr<void> chdir(StringView path)
|
|||
return Error::from_errno(EFAULT);
|
||||
#ifdef __serenity__
|
||||
int rc = syscall(SC_chdir, path.characters_without_null_termination(), path.length());
|
||||
HANDLE_SYSCALL_RETURN_VALUE("chdir"sv, rc, {});
|
||||
HANDLE_SYSCALL_RETURN_VALUE("chdir", rc, {});
|
||||
#else
|
||||
String path_string = path;
|
||||
if (::chdir(path_string.characters()) < 0)
|
||||
|
@ -823,7 +823,7 @@ ErrorOr<void> rmdir(StringView path)
|
|||
return Error::from_errno(EFAULT);
|
||||
#ifdef __serenity__
|
||||
int rc = syscall(SC_rmdir, path.characters_without_null_termination(), path.length());
|
||||
HANDLE_SYSCALL_RETURN_VALUE("rmdir"sv, rc, {});
|
||||
HANDLE_SYSCALL_RETURN_VALUE("rmdir", rc, {});
|
||||
#else
|
||||
String path_string = path;
|
||||
if (::rmdir(path_string.characters()) < 0)
|
||||
|
@ -859,7 +859,7 @@ ErrorOr<void> rename(StringView old_path, StringView new_path)
|
|||
.new_path = { new_path.characters_without_null_termination(), new_path.length() },
|
||||
};
|
||||
int rc = syscall(SC_rename, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("rename"sv, rc, {});
|
||||
HANDLE_SYSCALL_RETURN_VALUE("rename", rc, {});
|
||||
#else
|
||||
String old_path_string = old_path;
|
||||
String new_path_string = new_path;
|
||||
|
@ -876,7 +876,7 @@ ErrorOr<void> unlink(StringView path)
|
|||
|
||||
#ifdef __serenity__
|
||||
int rc = syscall(SC_unlink, AT_FDCWD, path.characters_without_null_termination(), path.length(), 0);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("unlink"sv, rc, {});
|
||||
HANDLE_SYSCALL_RETURN_VALUE("unlink", rc, {});
|
||||
#else
|
||||
String path_string = path;
|
||||
if (::unlink(path_string.characters()) < 0)
|
||||
|
@ -895,7 +895,7 @@ ErrorOr<void> utime(StringView path, Optional<struct utimbuf> maybe_buf)
|
|||
buf = &maybe_buf.value();
|
||||
#ifdef __serenity__
|
||||
int rc = syscall(SC_utime, path.characters_without_null_termination(), path.length(), buf);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("utime"sv, rc, {});
|
||||
HANDLE_SYSCALL_RETURN_VALUE("utime", rc, {});
|
||||
#else
|
||||
String path_string = path;
|
||||
if (::utime(path_string.characters(), buf) < 0)
|
||||
|
@ -909,7 +909,7 @@ ErrorOr<struct utsname> uname()
|
|||
utsname uts;
|
||||
#ifdef __serenity__
|
||||
int rc = syscall(SC_uname, &uts);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("uname"sv, rc, uts);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("uname", rc, uts);
|
||||
#else
|
||||
if (::uname(&uts) < 0)
|
||||
return Error::from_syscall("uname"sv, -errno);
|
||||
|
@ -921,7 +921,7 @@ ErrorOr<void> adjtime(const struct timeval* delta, struct timeval* old_delta)
|
|||
{
|
||||
#ifdef __serenity__
|
||||
int rc = syscall(SC_adjtime, delta, old_delta);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("adjtime"sv, rc, {});
|
||||
HANDLE_SYSCALL_RETURN_VALUE("adjtime", rc, {});
|
||||
#else
|
||||
if (::adjtime(delta, old_delta) < 0)
|
||||
return Error::from_syscall("adjtime"sv, -errno);
|
||||
|
@ -973,7 +973,7 @@ ErrorOr<void> exec(StringView filename, Span<StringView> arguments, SearchInPath
|
|||
auto const* path_ptr = getenv("PATH");
|
||||
StringView path { path_ptr, strlen(path_ptr) };
|
||||
if (path.is_empty())
|
||||
path = "/bin:/usr/bin";
|
||||
path = "/bin:/usr/bin"sv;
|
||||
auto parts = path.split_view(':');
|
||||
for (auto& part : parts) {
|
||||
auto candidate = String::formatted("{}/{}", part, filename);
|
||||
|
@ -1214,7 +1214,7 @@ ErrorOr<void> mknod(StringView pathname, mode_t mode, dev_t dev)
|
|||
#ifdef __serenity__
|
||||
Syscall::SC_mknod_params params { { pathname.characters_without_null_termination(), pathname.length() }, mode, dev };
|
||||
int rc = syscall(SC_mknod, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("mknod"sv, rc, {});
|
||||
HANDLE_SYSCALL_RETURN_VALUE("mknod", rc, {});
|
||||
#else
|
||||
String path_string = pathname;
|
||||
if (::mknod(path_string.characters(), mode, dev) < 0)
|
||||
|
@ -1238,7 +1238,7 @@ ErrorOr<void> setenv(StringView name, StringView value, bool overwrite)
|
|||
auto const rc = ::setenv(name_string.characters(), value_string.characters(), overwrite);
|
||||
#endif
|
||||
if (rc < 0)
|
||||
return Error::from_syscall("setenv", -errno);
|
||||
return Error::from_syscall("setenv"sv, -errno);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -1246,7 +1246,7 @@ ErrorOr<int> posix_openpt(int flags)
|
|||
{
|
||||
int const rc = ::posix_openpt(flags);
|
||||
if (rc < 0)
|
||||
return Error::from_syscall("posix_openpt", -errno);
|
||||
return Error::from_syscall("posix_openpt"sv, -errno);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -1254,7 +1254,7 @@ ErrorOr<void> grantpt(int fildes)
|
|||
{
|
||||
auto const rc = ::grantpt(fildes);
|
||||
if (rc < 0)
|
||||
return Error::from_syscall("grantpt", -errno);
|
||||
return Error::from_syscall("grantpt"sv, -errno);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -1262,7 +1262,7 @@ ErrorOr<void> unlockpt(int fildes)
|
|||
{
|
||||
auto const rc = ::unlockpt(fildes);
|
||||
if (rc < 0)
|
||||
return Error::from_syscall("unlockpt", -errno);
|
||||
return Error::from_syscall("unlockpt"sv, -errno);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -1273,7 +1273,7 @@ ErrorOr<void> access(StringView pathname, int mode)
|
|||
|
||||
#ifdef __serenity__
|
||||
int rc = ::syscall(Syscall::SC_access, pathname.characters_without_null_termination(), pathname.length(), mode);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("access"sv, rc, {});
|
||||
HANDLE_SYSCALL_RETURN_VALUE("access", rc, {});
|
||||
#else
|
||||
String path_string = pathname;
|
||||
if (::access(path_string.characters(), mode) < 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue