mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:27:45 +00:00
adjtime: Drop unnecessary privileges unconditionally
Furthermore, this simplifies the control flow.
This commit is contained in:
parent
4e4db65e26
commit
3371a27018
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.add_option(delta, "Adjust system time by this many seconds", "set", 's', "delta_seconds");
|
||||||
args_parser.parse(argc, argv);
|
args_parser.parse(argc, argv);
|
||||||
|
|
||||||
if (__builtin_isnan(delta)) {
|
if (!__builtin_isnan(delta)) {
|
||||||
#ifdef __serenity__
|
|
||||||
if (pledge("stdio", nullptr) < 0) {
|
|
||||||
perror("pledge");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
} else {
|
|
||||||
long delta_us = static_cast<long>(round(delta * 1'000'000));
|
long delta_us = static_cast<long>(round(delta * 1'000'000));
|
||||||
timeval delta_timeval;
|
timeval delta_timeval;
|
||||||
delta_timeval.tv_sec = delta_us / 1'000'000;
|
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;
|
timeval remaining_delta_timeval;
|
||||||
if (adjtime(nullptr, &remaining_delta_timeval) < 0) {
|
if (adjtime(nullptr, &remaining_delta_timeval) < 0) {
|
||||||
perror("adjtime get");
|
perror("adjtime get");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue