mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
adjtime: Drop unnecessary privileges unconditionally
Furthermore, this simplifies the control flow.
This commit is contained in:
parent
4e4db65e26
commit
3371a27018
Notes:
sideshowbarker
2024-07-18 02:05:54 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/3371a27018e Pull-request: https://github.com/SerenityOS/serenity/pull/10547 Reviewed-by: https://github.com/nico ✅
1 changed files with 8 additions and 8 deletions
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue