summaryrefslogtreecommitdiff
path: root/Userland/Utilities/useradd.cpp
diff options
context:
space:
mode:
authorAli Mohammad Pur <ali.mpfard@gmail.com>2023-03-01 00:11:43 +0330
committerAndreas Kling <kling@serenityos.org>2023-03-01 10:47:19 +0100
commit500044906d1b90f1c8b1a2f5675a2f82ab92b758 (patch)
tree7d6aae259b188c1b6879c591eebdfd7f55d9b71c /Userland/Utilities/useradd.cpp
parent60908adcbe2afd611233957bb3126f736eb18e25 (diff)
downloadserenity-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/Utilities/useradd.cpp')
-rw-r--r--Userland/Utilities/useradd.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Utilities/useradd.cpp b/Userland/Utilities/useradd.cpp
index 0bef6ae42b..1eb2fe26ac 100644
--- a/Userland/Utilities/useradd.cpp
+++ b/Userland/Utilities/useradd.cpp
@@ -31,7 +31,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio wpath rpath cpath chown"));
- char const* home_path = nullptr;
+ StringView home_path;
int uid = 0;
int gid = USERS_GID;
bool create_home_dir = false;
@@ -108,7 +108,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
DeprecatedString home;
- if (!home_path)
+ if (home_path.is_empty())
home = DeprecatedString::formatted("/home/{}", username);
else
home = home_path;