mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:14:58 +00:00
Userland: Convert command line arguments to String/StringView
StringView was used where possible. Some utilities still use libc functions which expect null-terminated strings, so String objects were used there instead.
This commit is contained in:
parent
fded8f861d
commit
60f6bc902b
25 changed files with 101 additions and 100 deletions
|
@ -15,8 +15,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
{
|
||||
Core::ArgsParser args_parser;
|
||||
|
||||
char const* pid_argument = nullptr;
|
||||
char const* cmd_argument = nullptr;
|
||||
StringView pid_argument {};
|
||||
StringView cmd_argument {};
|
||||
bool wait = false;
|
||||
bool free = false;
|
||||
bool enable = false;
|
||||
|
@ -69,7 +69,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
exit(0);
|
||||
}
|
||||
|
||||
if (!pid_argument && !cmd_argument && !all_processes) {
|
||||
if (pid_argument.is_empty() && cmd_argument.is_empty() && !all_processes) {
|
||||
args_parser.print_usage(stdout, arguments.argv[0]);
|
||||
print_types();
|
||||
return 0;
|
||||
|
@ -78,13 +78,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
if (!seen_event_type_arg)
|
||||
event_mask |= PERF_EVENT_SAMPLE;
|
||||
|
||||
if (pid_argument || all_processes) {
|
||||
if (!pid_argument.is_empty() || all_processes) {
|
||||
if (!(enable ^ disable ^ wait ^ free)) {
|
||||
warnln("-p <PID> requires -e xor -d xor -w xor -f.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
pid_t pid = all_processes ? -1 : atoi(pid_argument);
|
||||
// FIXME: Handle error case.
|
||||
pid_t pid = all_processes ? -1 : pid_argument.to_int().release_value();
|
||||
|
||||
if (wait || enable) {
|
||||
TRY(Core::System::profiling_enable(pid, event_mask));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue