diff options
author | Ali Mohammad Pur <ali.mpfard@gmail.com> | 2023-03-01 00:11:43 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-01 10:47:19 +0100 |
commit | 500044906d1b90f1c8b1a2f5675a2f82ab92b758 (patch) | |
tree | 7d6aae259b188c1b6879c591eebdfd7f55d9b71c /Userland/DevTools/Profiler | |
parent | 60908adcbe2afd611233957bb3126f736eb18e25 (diff) | |
download | serenity-500044906d1b90f1c8b1a2f5675a2f82ab92b758.zip |
LibCore+Everywhere: Remove ArgsParser::add*(char const*&)
This is not guaranteed to always work correctly as ArgsParser deals in
StringViews and might have a non-properly-null-terminated string as a
value. As a bonus, using StringView (and DeprecatedString where
necessary) leads to nicer looking code too :^)
Diffstat (limited to 'Userland/DevTools/Profiler')
-rw-r--r-- | Userland/DevTools/Profiler/main.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Userland/DevTools/Profiler/main.cpp b/Userland/DevTools/Profiler/main.cpp index 8269403d28..6fe4abdfdd 100644 --- a/Userland/DevTools/Profiler/main.cpp +++ b/Userland/DevTools/Profiler/main.cpp @@ -47,13 +47,13 @@ static bool generate_profile(pid_t& pid); ErrorOr<int> serenity_main(Main::Arguments arguments) { int pid = 0; - char const* perfcore_file_arg = nullptr; + StringView perfcore_file_arg; Core::ArgsParser args_parser; args_parser.add_option(pid, "PID to profile", "pid", 'p', "PID"); args_parser.add_positional_argument(perfcore_file_arg, "Path of perfcore file", "perfcore-file", Core::ArgsParser::Required::No); args_parser.parse(arguments); - if (pid && perfcore_file_arg) { + if (pid && !perfcore_file_arg.is_empty()) { warnln("-p/--pid option and perfcore-file argument must not be used together!"); return 1; } @@ -62,7 +62,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments) auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-profiler"sv)); DeprecatedString perfcore_file; - if (!perfcore_file_arg) { + if (perfcore_file_arg.is_empty()) { if (!generate_profile(pid)) return 0; perfcore_file = DeprecatedString::formatted("/proc/{}/perf_events", pid); |