From dbef7bcf2935ae2ae2aca77c3757bf33a041219d Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Sat, 24 May 2025 19:49:08 +0200 Subject: [PATCH] shared: Followups for #37575 --- src/shared/btrfs-util.h | 2 +- src/shared/conf-parser.c | 2 +- src/shared/conf-parser.h | 5 ----- src/shared/daemon-util.h | 1 + src/shared/dissect-image.h | 4 ++-- src/shared/seccomp-util.h | 8 +++----- src/shared/sleep-config.c | 4 ++-- src/shared/sleep-config.h | 2 +- src/shared/smack-util.c | 2 +- src/shared/user-record.h | 4 ++-- src/sleep/sleep.c | 2 +- 11 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/shared/btrfs-util.h b/src/shared/btrfs-util.h index 44438bbaf3f..63fc1d0b32d 100644 --- a/src/shared/btrfs-util.h +++ b/src/shared/btrfs-util.h @@ -127,7 +127,7 @@ int btrfs_qgroup_get_quota(const char *path, uint64_t qgroupid, BtrfsQuotaInfo * int btrfs_log_dev_root(int level, int ret, const char *p); -bool btrfs_might_be_subvol(const struct stat *st); +bool btrfs_might_be_subvol(const struct stat *st) _pure_; int btrfs_forget_device(const char *path); diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c index 5a2e253175c..dc9561f9625 100644 --- a/src/shared/conf-parser.c +++ b/src/shared/conf-parser.c @@ -851,7 +851,7 @@ int config_section_new(const char *filename, unsigned line, ConfigSection **ret) return 0; } -int _hashmap_by_section_find_unused_line( +static int _hashmap_by_section_find_unused_line( HashmapBase *entries_by_section, const char *filename, unsigned *ret) { diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h index e3f4666dfb7..2f1b5ffecc6 100644 --- a/src/shared/conf-parser.h +++ b/src/shared/conf-parser.h @@ -150,11 +150,6 @@ void config_section_hash_func(const ConfigSection *c, struct siphash *state); int config_section_compare_func(const ConfigSection *x, const ConfigSection *y); extern const struct hash_ops config_section_hash_ops; -int _hashmap_by_section_find_unused_line( - HashmapBase *entries_by_section, - const char *filename, - unsigned *ret); - int hashmap_by_section_find_unused_line(Hashmap *entries_by_section, const char *filename, unsigned *ret); int ordered_hashmap_by_section_find_unused_line(OrderedHashmap *entries_by_section, const char *filename, unsigned *ret); diff --git a/src/shared/daemon-util.h b/src/shared/daemon-util.h index 6b81fcd75c9..90d4a1689bb 100644 --- a/src/shared/daemon-util.h +++ b/src/shared/daemon-util.h @@ -15,6 +15,7 @@ static inline const char* notify_start(const char *start, const char *stop) { return stop; } +/* This is intended to be used with _cleanup_ attribute. */ static inline void notify_on_cleanup(const char **p) { if (*p) (void) sd_notify(false, *p); diff --git a/src/shared/dissect-image.h b/src/shared/dissect-image.h index 226b6f6428a..54fdd8da0dd 100644 --- a/src/shared/dissect-image.h +++ b/src/shared/dissect-image.h @@ -187,8 +187,8 @@ static inline bool dissected_image_is_bootable_uefi(DissectedImage *m) { return m && m->partitions[PARTITION_ESP].found && dissected_image_is_bootable_os(m); } -bool dissected_image_is_portable(DissectedImage *m); -bool dissected_image_is_initrd(DissectedImage *m); +bool dissected_image_is_portable(DissectedImage *m) _pure_; +bool dissected_image_is_initrd(DissectedImage *m) _pure_; DecryptedImage* decrypted_image_ref(DecryptedImage *p); DecryptedImage* decrypted_image_unref(DecryptedImage *p); diff --git a/src/shared/seccomp-util.h b/src/shared/seccomp-util.h index bd8f1a18770..bde97acbec0 100644 --- a/src/shared/seccomp-util.h +++ b/src/shared/seccomp-util.h @@ -159,8 +159,6 @@ enum { SECCOMP_ERROR_NUMBER_KILL = INT_MAX - 1, }; -bool seccomp_errno_or_action_is_valid(int n); - -int seccomp_parse_errno_or_action(const char *p); - -const char* seccomp_errno_or_action_to_string(int num); +bool seccomp_errno_or_action_is_valid(int n) _const_; +int seccomp_parse_errno_or_action(const char *p) _pure_; +const char* seccomp_errno_or_action_to_string(int num) _const_; diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c index 9a6e258bd8b..3f4aede5371 100644 --- a/src/shared/sleep-config.c +++ b/src/shared/sleep-config.c @@ -181,7 +181,7 @@ int parse_sleep_config(SleepConfig **ret) { return 0; } -bool SLEEP_NEEDS_MEM_SLEEP(const SleepConfig *sc, SleepOperation operation) { +bool sleep_needs_mem_sleep(const SleepConfig *sc, SleepOperation operation) { assert(sc); assert(operation >= 0 && operation < _SLEEP_OPERATION_CONFIG_MAX); @@ -354,7 +354,7 @@ static int sleep_supported_internal( return false; } - if (SLEEP_NEEDS_MEM_SLEEP(sleep_config, operation)) { + if (sleep_needs_mem_sleep(sleep_config, operation)) { r = sleep_mode_supported("/sys/power/mem_sleep", sleep_config->mem_modes); if (r < 0) return r; diff --git a/src/shared/sleep-config.h b/src/shared/sleep-config.h index 07d9848db2c..9463a23d6dc 100644 --- a/src/shared/sleep-config.h +++ b/src/shared/sleep-config.h @@ -41,7 +41,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(SleepConfig*, sleep_config_free); int parse_sleep_config(SleepConfig **sleep_config); -bool SLEEP_NEEDS_MEM_SLEEP(const SleepConfig *sc, SleepOperation operation); +bool sleep_needs_mem_sleep(const SleepConfig *sc, SleepOperation operation) _pure_; typedef enum SleepSupport { SLEEP_SUPPORTED, diff --git a/src/shared/smack-util.c b/src/shared/smack-util.c index 653e73fb94f..cf157fa6e77 100644 --- a/src/shared/smack-util.c +++ b/src/shared/smack-util.c @@ -66,7 +66,7 @@ int mac_smack_read_at(int fd, const char *path, SmackAttr attr, char **ret) { return getxattr_at_malloc(fd, path, smack_attr_to_string(attr), /* at_flags = */ 0, ret, /* ret_size= */ NULL); #else -return -EOPNOTSUPP; + return -EOPNOTSUPP; #endif } diff --git a/src/shared/user-record.h b/src/shared/user-record.h index 870c30b7a82..f411214453f 100644 --- a/src/shared/user-record.h +++ b/src/shared/user-record.h @@ -177,7 +177,7 @@ static inline UserRecordMask USER_RECORD_STRIP_MASK(UserRecordLoadFlags f) { return (f >> 21) & _USER_RECORD_MASK_MAX; } -sd_json_dispatch_flags_t USER_RECORD_LOAD_FLAGS_TO_JSON_DISPATCH_FLAGS(UserRecordLoadFlags flags); +sd_json_dispatch_flags_t USER_RECORD_LOAD_FLAGS_TO_JSON_DISPATCH_FLAGS(UserRecordLoadFlags flags) _const_; typedef struct Pkcs11EncryptedKey { /* The encrypted passphrase, which can be decrypted with the private key indicated below */ @@ -533,7 +533,7 @@ typedef struct UserDBMatch { .uid_max = UID_NOBODY - 1, \ } -bool userdb_match_is_set(const UserDBMatch *match); +bool userdb_match_is_set(const UserDBMatch *match) _pure_; void userdb_match_done(UserDBMatch *match); diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c index 03375a942a8..3f09d2272d3 100644 --- a/src/sleep/sleep.c +++ b/src/sleep/sleep.c @@ -268,7 +268,7 @@ static int execute( if (state_fd < 0) return log_error_errno(errno, "Failed to open /sys/power/state: %m"); - if (SLEEP_NEEDS_MEM_SLEEP(sleep_config, operation)) { + if (sleep_needs_mem_sleep(sleep_config, operation)) { r = write_mode("/sys/power/mem_sleep", sleep_config->mem_modes); if (r < 0) return log_error_errno(r, "Failed to write mode to /sys/power/mem_sleep: %m"); -- 2.47.3