mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 08:28:11 +00:00
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 :^)
This commit is contained in:
parent
60908adcbe
commit
500044906d
43 changed files with 122 additions and 145 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue