diff --git a/src/ask-password/ask-password.c b/src/ask-password/ask-password.c index 551dcb8b27..55ff91d76c 100644 --- a/src/ask-password/ask-password.c +++ b/src/ask-password/ask-password.c @@ -376,7 +376,7 @@ static int vl_method_ask(sd_varlink *link, sd_json_variant *parameters, sd_varli static int vl_server(void) { _cleanup_(sd_varlink_server_unrefp) sd_varlink_server *varlink_server = NULL; - _cleanup_(hashmap_freep) Hashmap *polkit_registry = NULL; + _cleanup_hashmap_free_ Hashmap *polkit_registry = NULL; int r; r = varlink_server_new(&varlink_server, SD_VARLINK_SERVER_INHERIT_USERDATA, /* userdata= */ &polkit_registry); diff --git a/src/basic/capability-util.h b/src/basic/capability-util.h index bd8477f4fc..e4104c5da5 100644 --- a/src/basic/capability-util.h +++ b/src/basic/capability-util.h @@ -43,12 +43,6 @@ int keep_capability(cap_value_t cv); DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(cap_t, cap_free, NULL); #define _cleanup_cap_free_ _cleanup_(cap_freep) -static inline void cap_free_charpp(char **p) { - if (*p) - cap_free(*p); -} -#define _cleanup_cap_free_charp_ _cleanup_(cap_free_charpp) - static inline uint64_t all_capabilities(void) { return UINT64_MAX >> (63 - cap_last_cap()); } diff --git a/src/basic/namespace-util.c b/src/basic/namespace-util.c index 6c559e4bf8..99cece1674 100644 --- a/src/basic/namespace-util.c +++ b/src/basic/namespace-util.c @@ -558,7 +558,7 @@ int userns_acquire(const char *uid_map, const char *gid_map) { } int userns_enter_and_pin(int userns_fd, pid_t *ret_pid) { - _cleanup_(close_pairp) int pfd[2] = EBADF_PAIR; + _cleanup_close_pair_ int pfd[2] = EBADF_PAIR; _cleanup_(sigkill_waitp) pid_t pid = 0; ssize_t n; char x; diff --git a/src/boot/boot.c b/src/boot/boot.c index a4e0b5551f..4f33d9dbe7 100644 --- a/src/boot/boot.c +++ b/src/boot/boot.c @@ -683,7 +683,7 @@ static bool menu_run( bool new_mode = true, clear = true; bool refresh = true, highlight = false; size_t x_start = 0, y_start = 0, y_status = 0, x_max, y_max; - _cleanup_(strv_freep) char16_t **lines = NULL; + _cleanup_strv_free_ char16_t **lines = NULL; _cleanup_free_ char16_t *clearline = NULL, *separator = NULL, *status = NULL; uint64_t timeout_efivar_saved = config->timeout_sec_efivar; uint32_t timeout_remain = config->timeout_sec == TIMEOUT_MENU_FORCE ? 0 : config->timeout_sec; @@ -1373,7 +1373,7 @@ static void boot_entry_parse_tries( static EFI_STATUS boot_entry_bump_counters(BootEntry *entry) { _cleanup_free_ char16_t* old_path = NULL, *new_path = NULL; - _cleanup_(file_closep) EFI_FILE *handle = NULL; + _cleanup_file_close_ EFI_FILE *handle = NULL; _cleanup_free_ EFI_FILE_INFO *file_info = NULL; size_t file_info_size; EFI_STATUS err; @@ -1386,7 +1386,7 @@ static EFI_STATUS boot_entry_bump_counters(BootEntry *entry) { if (!entry->path || !entry->current_name || !entry->next_name) return EFI_SUCCESS; - _cleanup_(file_closep) EFI_FILE *root = NULL; + _cleanup_file_close_ EFI_FILE *root = NULL; err = open_volume(entry->device, &root); if (err != EFI_SUCCESS) return log_error_status(err, "Error opening entry root path: %m"); @@ -1524,7 +1524,7 @@ static void boot_entry_add_type1( return; /* check existence */ - _cleanup_(file_closep) EFI_FILE *handle = NULL; + _cleanup_file_close_ EFI_FILE *handle = NULL; err = root_dir->Open(root_dir, &handle, entry->loader, EFI_FILE_MODE_READ, 0ULL); if (err != EFI_SUCCESS) return; @@ -1651,7 +1651,7 @@ static void config_load_type1_entries( EFI_FILE *root_dir, const char16_t *loaded_image_path) { - _cleanup_(file_closep) EFI_FILE *entries_dir = NULL; + _cleanup_file_close_ EFI_FILE *entries_dir = NULL; _cleanup_free_ EFI_FILE_INFO *f = NULL; size_t f_size = 0; EFI_STATUS err; @@ -1906,7 +1906,7 @@ static bool is_sd_boot(EFI_FILE *root_dir, const char16_t *loader_path) { assert(root_dir); assert(loader_path); - _cleanup_(file_closep) EFI_FILE *handle = NULL; + _cleanup_file_close_ EFI_FILE *handle = NULL; err = root_dir->Open(root_dir, &handle, (char16_t *) loader_path, EFI_FILE_MODE_READ, 0ULL); if (err != EFI_SUCCESS) return false; @@ -1969,7 +1969,7 @@ static BootEntry* config_add_entry_loader_auto( } /* check existence */ - _cleanup_(file_closep) EFI_FILE *handle = NULL; + _cleanup_file_close_ EFI_FILE *handle = NULL; EFI_STATUS err = root_dir->Open(root_dir, &handle, (char16_t *) loader, EFI_FILE_MODE_READ, 0ULL); if (err != EFI_SUCCESS) return NULL; @@ -2006,7 +2006,7 @@ static void config_add_entry_osx(Config *config) { return; for (size_t i = 0; i < n_handles; i++) { - _cleanup_(file_closep) EFI_FILE *root = NULL; + _cleanup_file_close_ EFI_FILE *root = NULL; if (open_volume(handles[i], &root) != EFI_SUCCESS) continue; @@ -2163,7 +2163,7 @@ static void boot_entry_add_type2( assert(path); assert(filename); - _cleanup_(file_closep) EFI_FILE *handle = NULL; + _cleanup_file_close_ EFI_FILE *handle = NULL; err = dir->Open(dir, &handle, (char16_t *) filename, EFI_FILE_MODE_READ, 0ULL); if (err != EFI_SUCCESS) return; @@ -2363,7 +2363,7 @@ static void config_load_type2_entries( EFI_HANDLE *device, EFI_FILE *root_dir) { - _cleanup_(file_closep) EFI_FILE *linux_dir = NULL; + _cleanup_file_close_ EFI_FILE *linux_dir = NULL; _cleanup_free_ EFI_FILE_INFO *f = NULL; size_t f_size = 0; EFI_STATUS err; @@ -2402,7 +2402,7 @@ static void config_load_xbootldr( Config *config, EFI_HANDLE *device) { - _cleanup_(file_closep) EFI_FILE *root_dir = NULL; + _cleanup_file_close_ EFI_FILE *root_dir = NULL; EFI_HANDLE new_device = NULL; /* avoid false maybe-uninitialized warning */ EFI_STATUS err; @@ -2454,7 +2454,7 @@ static EFI_STATUS initrd_prepare( else options = xasprintf("initrd=%ls", *i); - _cleanup_(file_closep) EFI_FILE *handle = NULL; + _cleanup_file_close_ EFI_FILE *handle = NULL; err = root->Open(root, &handle, *i, EFI_FILE_MODE_READ, 0); if (err != EFI_SUCCESS) return err; @@ -2475,7 +2475,7 @@ static EFI_STATUS initrd_prepare( uint8_t *p = PHYSICAL_ADDRESS_TO_POINTER(pages.addr); STRV_FOREACH(i, entry->initrd) { - _cleanup_(file_closep) EFI_FILE *handle = NULL; + _cleanup_file_close_ EFI_FILE *handle = NULL; err = root->Open(root, &handle, *i, EFI_FILE_MODE_READ, 0); if (err != EFI_SUCCESS) return err; @@ -2538,7 +2538,7 @@ static EFI_STATUS image_start( if (entry->call) (void) entry->call(); - _cleanup_(file_closep) EFI_FILE *image_root = NULL; + _cleanup_file_close_ EFI_FILE *image_root = NULL; err = open_volume(entry->device, &image_root); if (err != EFI_SUCCESS) return log_error_status(err, "Error opening root path: %m"); @@ -2696,7 +2696,7 @@ static void save_selected_entry(const Config *config, const BootEntry *entry) { static EFI_STATUS secure_boot_discover_keys(Config *config, EFI_FILE *root_dir) { EFI_STATUS err; - _cleanup_(file_closep) EFI_FILE *keys_basedir = NULL; + _cleanup_file_close_ EFI_FILE *keys_basedir = NULL; if (!IN_SET(secure_boot_mode(), SECURE_BOOT_SETUP, SECURE_BOOT_AUDIT)) return EFI_SUCCESS; @@ -2868,7 +2868,7 @@ static EFI_STATUS discover_root_dir(EFI_LOADED_IMAGE_PROTOCOL *loaded_image, EFI static EFI_STATUS run(EFI_HANDLE image) { EFI_LOADED_IMAGE_PROTOCOL *loaded_image; - _cleanup_(file_closep) EFI_FILE *root_dir = NULL; + _cleanup_file_close_ EFI_FILE *root_dir = NULL; _cleanup_(config_free) Config config = {}; EFI_STATUS err; uint64_t init_usec; diff --git a/src/boot/cpio.c b/src/boot/cpio.c index ba439740f7..fc5e303d7e 100644 --- a/src/boot/cpio.c +++ b/src/boot/cpio.c @@ -314,11 +314,11 @@ EFI_STATUS pack_cpio( struct iovec *ret_buffer, bool *ret_measured) { - _cleanup_(file_closep) EFI_FILE *root = NULL, *extra_dir = NULL; + _cleanup_file_close_ EFI_FILE *root = NULL, *extra_dir = NULL; size_t dirent_size = 0, buffer_size = 0, n_items = 0, n_allocated = 0; _cleanup_free_ char16_t *rel_dropin_dir = NULL; _cleanup_free_ EFI_FILE_INFO *dirent = NULL; - _cleanup_(strv_freep) char16_t **items = NULL; + _cleanup_strv_free_ char16_t **items = NULL; _cleanup_free_ void *buffer = NULL; uint32_t inode = 1; /* inode counter, so that each item gets a new inode */ EFI_STATUS err; diff --git a/src/boot/devicetree.c b/src/boot/devicetree.c index 2ec5ca28dd..85fc07c49f 100644 --- a/src/boot/devicetree.c +++ b/src/boot/devicetree.c @@ -63,7 +63,7 @@ static EFI_STATUS devicetree_fixup(struct devicetree_state *state, size_t len) { } EFI_STATUS devicetree_install(struct devicetree_state *state, EFI_FILE *root_dir, char16_t *name) { - _cleanup_(file_closep) EFI_FILE *handle = NULL; + _cleanup_file_close_ EFI_FILE *handle = NULL; _cleanup_free_ EFI_FILE_INFO *info = NULL; size_t len; EFI_STATUS err; diff --git a/src/boot/drivers.c b/src/boot/drivers.c index 067455771f..078c6cb993 100644 --- a/src/boot/drivers.c +++ b/src/boot/drivers.c @@ -73,7 +73,7 @@ EFI_STATUS load_drivers( EFI_LOADED_IMAGE_PROTOCOL *loaded_image, EFI_FILE *root_dir) { - _cleanup_(file_closep) EFI_FILE *drivers_dir = NULL; + _cleanup_file_close_ EFI_FILE *drivers_dir = NULL; _cleanup_free_ EFI_FILE_INFO *dirent = NULL; size_t dirent_size = 0, n_succeeded = 0; EFI_STATUS err; diff --git a/src/boot/random-seed.c b/src/boot/random-seed.c index 88fda5184a..9837a85ccd 100644 --- a/src/boot/random-seed.c +++ b/src/boot/random-seed.c @@ -121,7 +121,7 @@ EFI_STATUS process_random_seed(EFI_FILE *root_dir) { _cleanup_free_ struct linux_efi_random_seed *new_seed_table = NULL; struct linux_efi_random_seed *previous_seed_table = NULL; _cleanup_free_ void *seed = NULL, *system_token = NULL; - _cleanup_(file_closep) EFI_FILE *handle = NULL; + _cleanup_file_close_ EFI_FILE *handle = NULL; _cleanup_free_ EFI_FILE_INFO *info = NULL; struct sha256_ctx hash; uint64_t uefi_monotonic_counter = 0; diff --git a/src/boot/secure-boot.c b/src/boot/secure-boot.c index dc61457512..fc8b96ef44 100644 --- a/src/boot/secure-boot.c +++ b/src/boot/secure-boot.c @@ -115,7 +115,7 @@ EFI_STATUS secure_boot_enroll_at(EFI_FILE *root_dir, const char16_t *path, bool printf("\n"); } - _cleanup_(file_closep) EFI_FILE *dir = NULL; + _cleanup_file_close_ EFI_FILE *dir = NULL; err = open_directory(root_dir, path, &dir); if (err != EFI_SUCCESS) diff --git a/src/boot/shim.c b/src/boot/shim.c index 5928553471..514a1d0eda 100644 --- a/src/boot/shim.c +++ b/src/boot/shim.c @@ -56,7 +56,7 @@ static bool shim_validate( if (err != EFI_SUCCESS) return false; - _cleanup_(file_closep) EFI_FILE *root = NULL; + _cleanup_file_close_ EFI_FILE *root = NULL; err = open_volume(device_handle, &root); if (err != EFI_SUCCESS) return false; diff --git a/src/boot/stub.c b/src/boot/stub.c index cf990df2e7..e74b7db95a 100644 --- a/src/boot/stub.c +++ b/src/boot/stub.c @@ -294,7 +294,7 @@ static EFI_STATUS load_addons_from_dir( size_t *n_items, size_t *n_allocated) { - _cleanup_(file_closep) EFI_FILE *extra_dir = NULL; + _cleanup_file_close_ EFI_FILE *extra_dir = NULL; _cleanup_free_ EFI_FILE_INFO *dirent = NULL; size_t dirent_size = 0; EFI_STATUS err; @@ -547,8 +547,8 @@ static EFI_STATUS load_addons( NamedAddon **ucode_addons, /* Ditto */ size_t *n_ucode_addons) { - _cleanup_(strv_freep) char16_t **items = NULL; - _cleanup_(file_closep) EFI_FILE *root = NULL; + _cleanup_strv_free_ char16_t **items = NULL; + _cleanup_file_close_ EFI_FILE *root = NULL; size_t n_items = 0, n_allocated = 0; EFI_STATUS err; @@ -718,7 +718,7 @@ static void refresh_random_seed(EFI_LOADED_IMAGE_PROTOCOL *loaded_image) { if (FLAGS_SET(loader_features, EFI_LOADER_FEATURE_RANDOM_SEED)) return; - _cleanup_(file_closep) EFI_FILE *esp_dir = NULL; + _cleanup_file_close_ EFI_FILE *esp_dir = NULL; err = partition_open(MAKE_GUID_PTR(ESP), loaded_image->DeviceHandle, NULL, &esp_dir); if (err != EFI_SUCCESS) /* Non-fatal on failure, so that we still boot without it. */ return; diff --git a/src/boot/util.c b/src/boot/util.c index ae1ad12e7b..395c1f2abc 100644 --- a/src/boot/util.c +++ b/src/boot/util.c @@ -172,7 +172,7 @@ EFI_STATUS file_read( assert(name); assert(ret); - _cleanup_(file_closep) EFI_FILE *handle = NULL; + _cleanup_file_close_ EFI_FILE *handle = NULL; err = dir->Open(dir, &handle, (char16_t*) name, EFI_FILE_MODE_READ, 0ULL); if (err != EFI_SUCCESS) return err; @@ -313,7 +313,7 @@ EFI_STATUS open_directory( const char16_t *path, EFI_FILE **ret) { - _cleanup_(file_closep) EFI_FILE *dir = NULL; + _cleanup_file_close_ EFI_FILE *dir = NULL; _cleanup_free_ EFI_FILE_INFO *file_info = NULL; EFI_STATUS err; diff --git a/src/boot/util.h b/src/boot/util.h index 90da8ad69d..49ba119613 100644 --- a/src/boot/util.h +++ b/src/boot/util.h @@ -140,6 +140,8 @@ static inline void file_closep(EFI_FILE **handle) { (*handle)->Close(*handle); } +#define _cleanup_file_close_ _cleanup_(file_closep) + static inline void unload_imagep(EFI_HANDLE *image) { if (*image) (void) BS->UnloadImage(*image); @@ -167,6 +169,8 @@ static inline void strv_freep(char16_t ***p) { strv_free(*p); } +#define _cleanup_strv_free_ _cleanup_(strv_freep) + EFI_STATUS open_directory(EFI_FILE *root_dir, const char16_t *path, EFI_FILE **ret); /* Conversion between EFI_PHYSICAL_ADDRESS and pointers is not obvious. The former is always 64-bit, even on diff --git a/src/boot/vmm.c b/src/boot/vmm.c index fea4c446c0..29dbd6ffdb 100644 --- a/src/boot/vmm.c +++ b/src/boot/vmm.c @@ -85,7 +85,7 @@ EFI_STATUS vmm_open(EFI_HANDLE *ret_vmm_dev, EFI_FILE **ret_vmm_dir) { dp_err = efivar_get_raw(MAKE_GUID_PTR(VMM_BOOT_ORDER), order_str, (void**) &dp, NULL); for (size_t i = 0; i < n_handles; i++) { - _cleanup_(file_closep) EFI_FILE *root_dir = NULL, *efi_dir = NULL; + _cleanup_file_close_ EFI_FILE *root_dir = NULL, *efi_dir = NULL; EFI_DEVICE_PATH *fs; err = BS->HandleProtocol( diff --git a/src/core/exec-invoke.c b/src/core/exec-invoke.c index b48f5277bc..24e700a289 100644 --- a/src/core/exec-invoke.c +++ b/src/core/exec-invoke.c @@ -1120,7 +1120,7 @@ static int ask_password_conv( .until = usec_add(now(CLOCK_MONOTONIC), 15 * USEC_PER_SEC), }; - _cleanup_(strv_free_erasep) char **acquired = NULL; + _cleanup_strv_free_erase_ char **acquired = NULL; r = ask_password_auto( &req, ASK_PASSWORD_ACCEPT_CACHED| diff --git a/src/creds/creds.c b/src/creds/creds.c index bf76e4acf0..b10c36e66f 100644 --- a/src/creds/creds.c +++ b/src/creds/creds.c @@ -1425,7 +1425,7 @@ static int run(int argc, char *argv[]) { if (arg_varlink) { _cleanup_(sd_varlink_server_unrefp) sd_varlink_server *varlink_server = NULL; - _cleanup_(hashmap_freep) Hashmap *polkit_registry = NULL; + _cleanup_hashmap_free_ Hashmap *polkit_registry = NULL; /* Invocation as Varlink service */ diff --git a/src/import/importd.c b/src/import/importd.c index 72c0e4a95a..414994ee30 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -1371,7 +1371,7 @@ static int method_list_images(sd_bus_message *msg, void *userdata, sd_bus_error class < 0 ? (c < _IMAGE_CLASS_MAX) : (c == class); c++) { - _cleanup_(hashmap_freep) Hashmap *h = NULL; + _cleanup_hashmap_free_ Hashmap *h = NULL; h = hashmap_new(&image_hash_ops); if (!h) diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c index ecaf5b33b4..d5098ba650 100644 --- a/src/libsystemd/sd-bus/bus-socket.c +++ b/src/libsystemd/sd-bus/bus-socket.c @@ -1010,7 +1010,7 @@ static int bind_description(sd_bus *b, int fd, int family) { } static int connect_as(int fd, const struct sockaddr *sa, socklen_t salen, uid_t uid, gid_t gid) { - _cleanup_(close_pairp) int pfd[2] = EBADF_PAIR; + _cleanup_close_pair_ int pfd[2] = EBADF_PAIR; ssize_t n; int r; diff --git a/src/libsystemd/sd-varlink/sd-varlink-idl.c b/src/libsystemd/sd-varlink/sd-varlink-idl.c index 1349fd36ab..c7126ac6e6 100644 --- a/src/libsystemd/sd-varlink/sd-varlink-idl.c +++ b/src/libsystemd/sd-varlink/sd-varlink-idl.c @@ -1607,7 +1607,7 @@ static int varlink_idl_symbol_consistent( const sd_varlink_symbol *symbol, int level) { - _cleanup_(set_freep) Set *input_set = NULL, *output_set = NULL; + _cleanup_set_free_ Set *input_set = NULL, *output_set = NULL; const char *symbol_name; int r; @@ -1654,7 +1654,7 @@ static int varlink_idl_symbol_consistent( } int varlink_idl_consistent(const sd_varlink_interface *interface, int level) { - _cleanup_(set_freep) Set *name_set = NULL; + _cleanup_set_free_ Set *name_set = NULL; int r; assert(interface); diff --git a/src/login/pam_systemd_loadkey.c b/src/login/pam_systemd_loadkey.c index 3b11d76453..f62007d155 100644 --- a/src/login/pam_systemd_loadkey.c +++ b/src/login/pam_systemd_loadkey.c @@ -73,7 +73,7 @@ _public_ PAM_EXTERN int pam_sm_authenticate( /* Split the key by NUL. Set the last item as authtok. */ - _cleanup_(strv_free_erasep) char **passwords = strv_parse_nulstr(p, n); + _cleanup_strv_free_erase_ char **passwords = strv_parse_nulstr(p, n); if (!passwords) return pam_log_oom(handle); diff --git a/src/mountfsd/mountwork.c b/src/mountfsd/mountwork.c index 9b674c83b5..31f2d47546 100644 --- a/src/mountfsd/mountwork.c +++ b/src/mountfsd/mountwork.c @@ -567,7 +567,7 @@ static int process_connection(sd_varlink_server *server, int _fd) { static int run(int argc, char *argv[]) { usec_t start_time, listen_idle_usec, last_busy_usec = USEC_INFINITY; _cleanup_(sd_varlink_server_unrefp) sd_varlink_server *server = NULL; - _cleanup_(hashmap_freep) Hashmap *polkit_registry = NULL; + _cleanup_hashmap_free_ Hashmap *polkit_registry = NULL; _cleanup_(pidref_done) PidRef parent = PIDREF_NULL; unsigned n_iterations = 0; int m, listen_fd, r; diff --git a/src/nsresourced/nsresourced-manager.c b/src/nsresourced/nsresourced-manager.c index ab1cd0a7c1..152b506da5 100644 --- a/src/nsresourced/nsresourced-manager.c +++ b/src/nsresourced/nsresourced-manager.c @@ -595,7 +595,7 @@ static int manager_setup_bpf(Manager *m) { #endif int manager_startup(Manager *m) { - _cleanup_(set_freep) Set *fdstore_inodes = NULL, *registry_inodes = NULL; + _cleanup_set_free_ Set *fdstore_inodes = NULL, *registry_inodes = NULL; void *p; int r; diff --git a/src/pcrlock/pcrlock.c b/src/pcrlock/pcrlock.c index 2d46b31b58..002ca43edb 100644 --- a/src/pcrlock/pcrlock.c +++ b/src/pcrlock/pcrlock.c @@ -4548,7 +4548,7 @@ static int make_policy(bool force, RecoveryPinMode recovery_pin_mode) { if (r < 0) return log_error_errno(r, "Failed to acquire PIN from environment: %m"); if (r == 0) { - _cleanup_(strv_free_erasep) char **l = NULL; + _cleanup_strv_free_erase_ char **l = NULL; AskPasswordRequest req = { .tty_fd = -EBADF, diff --git a/src/resolve/resolved-dns-stream.c b/src/resolve/resolved-dns-stream.c index e57af66221..0696857802 100644 --- a/src/resolve/resolved-dns-stream.c +++ b/src/resolve/resolved-dns-stream.c @@ -612,7 +612,7 @@ DEFINE_PRIVATE_HASH_OPS_WITH_KEY_DESTRUCTOR( dns_stream_unref); int dns_stream_disconnect_all(Manager *m) { - _cleanup_(set_freep) Set *closed = NULL; + _cleanup_set_free_ Set *closed = NULL; int r; assert(m); diff --git a/src/shared/openssl-util.c b/src/shared/openssl-util.c index b60fc67b26..302cf3d0f6 100644 --- a/src/shared/openssl-util.c +++ b/src/shared/openssl-util.c @@ -1398,7 +1398,7 @@ static int openssl_ask_password_ui_read(UI *ui, UI_STRING *uis) { req->message = UI_get0_output_string(uis); - _cleanup_(strv_freep) char **l = NULL; + _cleanup_strv_free_ char **l = NULL; r = ask_password_auto(req, ASK_PASSWORD_ACCEPT_CACHED|ASK_PASSWORD_PUSH_CACHE, &l); if (r < 0) { log_error_errno(r, "Failed to query for PIN: %m"); diff --git a/src/shared/selinux-util.c b/src/shared/selinux-util.c index ff49e219a0..27ed339ff8 100644 --- a/src/shared/selinux-util.c +++ b/src/shared/selinux-util.c @@ -31,7 +31,6 @@ #if HAVE_SELINUX DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(context_t, context_free, NULL); -#define _cleanup_context_free_ _cleanup_(context_freep) typedef enum Initialized { UNINITIALIZED, @@ -471,7 +470,7 @@ int mac_selinux_get_our_label(char **ret) { int mac_selinux_get_child_mls_label(int socket_fd, const char *exe, const char *exec_label, char **ret_label) { #if HAVE_SELINUX _cleanup_freecon_ char *mycon = NULL, *peercon = NULL, *fcon = NULL; - _cleanup_context_free_ context_t pcon = NULL, bcon = NULL; + _cleanup_(context_freep) context_t pcon = NULL, bcon = NULL; const char *range = NULL, *bcon_str = NULL; security_class_t sclass; int r; diff --git a/src/test/test-cap-list.c b/src/test/test-cap-list.c index 49be4a2d27..0fb2f31ed2 100644 --- a/src/test/test-cap-list.c +++ b/src/test/test-cap-list.c @@ -12,6 +12,11 @@ #include "strv.h" #include "tests.h" +static inline void cap_free_charpp(char **p) { + if (*p) + cap_free(*p); +} + /* verify the capability parser */ TEST(cap_list) { assert_se(!capability_to_name(-1)); @@ -46,7 +51,7 @@ TEST(cap_list) { assert_se(capability_from_name("-1") == -EINVAL); for (int i = 0; i < capability_list_length(); i++) { - _cleanup_cap_free_charp_ char *a = NULL; + _cleanup_(cap_free_charpp) char *a = NULL; const char *b; unsigned u; diff --git a/src/test/test-hashmap-plain.c b/src/test/test-hashmap-plain.c index e1485a84d4..81effec21a 100644 --- a/src/test/test-hashmap-plain.c +++ b/src/test/test-hashmap-plain.c @@ -646,7 +646,7 @@ TEST(hashmap_get) { } TEST(hashmap_get2) { - _cleanup_(hashmap_free_free_freep) Hashmap *m = NULL; + _cleanup_hashmap_free_free_free_ Hashmap *m = NULL; char *r; char *val; char key_orig[] = "Key 1";