From: Daan De Meyer Date: Wed, 29 Mar 2023 16:03:32 +0000 (+0200) Subject: firstboot: Refactor should_configure() X-Git-Tag: v254-rc1~872^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F27053%2Fhead;p=thirdparty%2Fsystemd.git firstboot: Refactor should_configure() --- diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index 432cab47866..ba7e08913f3 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -230,16 +230,17 @@ static int prompt_loop(const char *text, char **l, unsigned percentage, bool (*i } static int should_configure(int dir_fd, const char *filename) { - int r; - assert(dir_fd >= 0); assert(filename); - r = faccessat(dir_fd, filename, F_OK, AT_SYMLINK_NOFOLLOW); - if (r < 0 && errno != ENOENT) - return log_error_errno(errno, "Failed to access %s: %m", filename); + if (faccessat(dir_fd, filename, F_OK, AT_SYMLINK_NOFOLLOW) < 0) { + if (errno != ENOENT) + return log_error_errno(errno, "Failed to access %s: %m", filename); + + return true; /* missing */ + } - return r < 0 || arg_force; + return arg_force; /* exists, but if --force was given we should still configure the file. */ } static bool locale_is_ok(const char *name) {