From 3371a27018ed9c73ef0b7350dbca97e93c4383fb Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sat, 16 Oct 2021 00:01:58 +0200 Subject: [PATCH] adjtime: Drop unnecessary privileges unconditionally Furthermore, this simplifies the control flow. --- Userland/Utilities/adjtime.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Userland/Utilities/adjtime.cpp b/Userland/Utilities/adjtime.cpp index f721c782ab..0d2f60478f 100644 --- a/Userland/Utilities/adjtime.cpp +++ b/Userland/Utilities/adjtime.cpp @@ -23,14 +23,7 @@ int main(int argc, char** argv) args_parser.add_option(delta, "Adjust system time by this many seconds", "set", 's', "delta_seconds"); args_parser.parse(argc, argv); - if (__builtin_isnan(delta)) { -#ifdef __serenity__ - if (pledge("stdio", nullptr) < 0) { - perror("pledge"); - return 1; - } -#endif - } else { + if (!__builtin_isnan(delta)) { long delta_us = static_cast(round(delta * 1'000'000)); timeval delta_timeval; delta_timeval.tv_sec = delta_us / 1'000'000; @@ -45,6 +38,13 @@ int main(int argc, char** argv) } } +#ifdef __serenity__ + if (pledge("stdio", nullptr) < 0) { + perror("pledge"); + return 1; + } +#endif + timeval remaining_delta_timeval; if (adjtime(nullptr, &remaining_delta_timeval) < 0) { perror("adjtime get");