mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:48:12 +00:00
Kernel: Make a bunch of "char const* to_string()" return StringView
This commit is contained in:
parent
f35108fc31
commit
af46f2214c
4 changed files with 34 additions and 33 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Userspace.h>
|
||||
|
||||
|
@ -206,19 +207,19 @@ enum Function {
|
|||
__Count
|
||||
};
|
||||
|
||||
constexpr const char* to_string(Function function)
|
||||
constexpr StringView to_string(Function function)
|
||||
{
|
||||
switch (function) {
|
||||
#undef __ENUMERATE_SYSCALL
|
||||
#define __ENUMERATE_SYSCALL(sys_call, needs_lock) \
|
||||
case SC_##sys_call: \
|
||||
return #sys_call;
|
||||
return #sys_call##sv;
|
||||
ENUMERATE_SYSCALLS(__ENUMERATE_SYSCALL)
|
||||
#undef __ENUMERATE_SYSCALL
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "Unknown";
|
||||
return "Unknown"sv;
|
||||
}
|
||||
|
||||
#ifdef __serenity__
|
||||
|
|
|
@ -51,17 +51,17 @@ public:
|
|||
Connecting
|
||||
};
|
||||
|
||||
static const char* to_string(SetupState setup_state)
|
||||
static StringView to_string(SetupState setup_state)
|
||||
{
|
||||
switch (setup_state) {
|
||||
case SetupState::Unstarted:
|
||||
return "Unstarted";
|
||||
return "Unstarted"sv;
|
||||
case SetupState::InProgress:
|
||||
return "InProgress";
|
||||
return "InProgress"sv;
|
||||
case SetupState::Completed:
|
||||
return "Completed";
|
||||
return "Completed"sv;
|
||||
default:
|
||||
return "None";
|
||||
return "None"sv;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,19 +28,19 @@ public:
|
|||
Passive,
|
||||
};
|
||||
|
||||
static const char* to_string(Direction direction)
|
||||
static StringView to_string(Direction direction)
|
||||
{
|
||||
switch (direction) {
|
||||
case Direction::Unspecified:
|
||||
return "Unspecified";
|
||||
return "Unspecified"sv;
|
||||
case Direction::Outgoing:
|
||||
return "Outgoing";
|
||||
return "Outgoing"sv;
|
||||
case Direction::Incoming:
|
||||
return "Incoming";
|
||||
return "Incoming"sv;
|
||||
case Direction::Passive:
|
||||
return "Passive";
|
||||
return "Passive"sv;
|
||||
default:
|
||||
return "None";
|
||||
return "None"sv;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,31 +58,31 @@ public:
|
|||
TimeWait,
|
||||
};
|
||||
|
||||
static const char* to_string(State state)
|
||||
static StringView to_string(State state)
|
||||
{
|
||||
switch (state) {
|
||||
case State::Closed:
|
||||
return "Closed";
|
||||
return "Closed"sv;
|
||||
case State::Listen:
|
||||
return "Listen";
|
||||
return "Listen"sv;
|
||||
case State::SynSent:
|
||||
return "SynSent";
|
||||
return "SynSent"sv;
|
||||
case State::SynReceived:
|
||||
return "SynReceived";
|
||||
return "SynReceived"sv;
|
||||
case State::Established:
|
||||
return "Established";
|
||||
return "Established"sv;
|
||||
case State::CloseWait:
|
||||
return "CloseWait";
|
||||
return "CloseWait"sv;
|
||||
case State::LastAck:
|
||||
return "LastAck";
|
||||
return "LastAck"sv;
|
||||
case State::FinWait1:
|
||||
return "FinWait1";
|
||||
return "FinWait1"sv;
|
||||
case State::FinWait2:
|
||||
return "FinWait2";
|
||||
return "FinWait2"sv;
|
||||
case State::Closing:
|
||||
return "Closing";
|
||||
return "Closing"sv;
|
||||
case State::TimeWait:
|
||||
return "TimeWait";
|
||||
return "TimeWait"sv;
|
||||
default:
|
||||
return "None";
|
||||
}
|
||||
|
@ -96,19 +96,19 @@ public:
|
|||
RetransmitTimeout,
|
||||
};
|
||||
|
||||
static const char* to_string(Error error)
|
||||
static StringView to_string(Error error)
|
||||
{
|
||||
switch (error) {
|
||||
case Error::None:
|
||||
return "None";
|
||||
return "None"sv;
|
||||
case Error::FINDuringConnect:
|
||||
return "FINDuringConnect";
|
||||
return "FINDuringConnect"sv;
|
||||
case Error::RSTDuringConnect:
|
||||
return "RSTDuringConnect";
|
||||
return "RSTDuringConnect"sv;
|
||||
case Error::UnexpectedFlagsDuringConnect:
|
||||
return "UnexpectedFlagsDuringConnect";
|
||||
return "UnexpectedFlagsDuringConnect"sv;
|
||||
default:
|
||||
return "Invalid";
|
||||
return "Invalid"sv;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ int main(int argc, char** argv)
|
|||
|
||||
if (arg[0] > Syscall::Function::__Count) {
|
||||
for (int sc = 0; sc < Syscall::Function::__Count; ++sc) {
|
||||
if (strcmp(Syscall::to_string((Syscall::Function)sc), (char*)arg[0]) == 0) {
|
||||
if (Syscall::to_string((Syscall::Function)sc) == (char const*)arg[0]) {
|
||||
arg[0] = sc;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue