adjtime: Drop unnecessary privileges unconditionally

Furthermore, this simplifies the control flow.
This commit is contained in:
Ben Wiederhake 2021-10-16 00:01:58 +02:00 committed by Linus Groh
parent 4e4db65e26
commit 3371a27018
Notes: sideshowbarker 2024-07-18 02:05:54 +09:00

View file

@ -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<long>(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");