summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/basic/efivars.c11
-rw-r--r--src/basic/signal-util.c2
-rw-r--r--src/basic/time-util.h4
3 files changed, 9 insertions, 8 deletions
diff --git a/src/basic/efivars.c b/src/basic/efivars.c
index fdc6c439bb..43f498de0f 100644
--- a/src/basic/efivars.c
+++ b/src/basic/efivars.c
@@ -177,12 +177,13 @@ static int efi_verify_variable(const char *variable, uint32_t attr, const void *
}
int efi_set_variable(const char *variable, const void *value, size_t size) {
+ static const uint32_t attr = EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS;
+
struct var {
uint32_t attr;
char buf[];
} _packed_ * _cleanup_free_ buf = NULL;
_cleanup_close_ int fd = -EBADF;
- uint32_t attr = EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS|EFI_VARIABLE_RUNTIME_ACCESS;
bool saved_flags_valid = false;
unsigned saved_flags;
int r;
@@ -190,14 +191,14 @@ int efi_set_variable(const char *variable, const void *value, size_t size) {
assert(variable);
assert(value || size == 0);
- const char *p = strjoina("/sys/firmware/efi/efivars/", variable);
-
/* size 0 means removal, empty variable would not be enough for that */
if (size > 0 && efi_verify_variable(variable, attr, value, size) > 0) {
log_debug("Variable '%s' is already in wanted state, skipping write.", variable);
return 0;
}
+ const char *p = strjoina("/sys/firmware/efi/efivars/", variable);
+
/* Newer efivarfs protects variables that are not in an allow list with FS_IMMUTABLE_FL by default,
* to protect them for accidental removal and modification. We are not changing these variables
* accidentally however, hence let's unset the bit first. */
@@ -238,10 +239,10 @@ int efi_set_variable(const char *variable, const void *value, size_t size) {
/* For some reason efivarfs doesn't update mtime automatically. Let's do it manually then. This is
* useful for processes that cache EFI variables to detect when changes occurred. */
- if (futimens(fd, (struct timespec[2]) {
+ if (futimens(fd, (const struct timespec[2]) {
{ .tv_nsec = UTIME_NOW },
{ .tv_nsec = UTIME_NOW }
- }) < 0)
+ }) < 0)
log_debug_errno(errno, "Failed to update mtime/atime on %s, ignoring: %m", p);
r = 0;
diff --git a/src/basic/signal-util.c b/src/basic/signal-util.c
index 661ad00b11..27d094b7bd 100644
--- a/src/basic/signal-util.c
+++ b/src/basic/signal-util.c
@@ -268,7 +268,7 @@ int pop_pending_signal_internal(int sig, ...) {
if (r < 0)
return r;
- r = sigtimedwait(&ss, NULL, &(struct timespec) { 0, 0 });
+ r = sigtimedwait(&ss, NULL, &(const struct timespec) {});
if (r < 0) {
if (errno == EAGAIN)
return 0;
diff --git a/src/basic/time-util.h b/src/basic/time-util.h
index a3c219ecdd..ebcdc41118 100644
--- a/src/basic/time-util.h
+++ b/src/basic/time-util.h
@@ -71,8 +71,8 @@ typedef enum TimestampStyle {
#define TIME_T_MAX (time_t)((UINTMAX_C(1) << ((sizeof(time_t) << 3) - 1)) - 1)
-#define DUAL_TIMESTAMP_NULL ((struct dual_timestamp) {})
-#define TRIPLE_TIMESTAMP_NULL ((struct triple_timestamp) {})
+#define DUAL_TIMESTAMP_NULL ((dual_timestamp) {})
+#define TRIPLE_TIMESTAMP_NULL ((triple_timestamp) {})
usec_t now(clockid_t clock);
nsec_t now_nsec(clockid_t clock);