]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: reset the cleaned-up variable in cleanup functions
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 16 Feb 2021 13:18:30 +0000 (14:18 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 16 Feb 2021 16:15:11 +0000 (17:15 +0100)
If the cleanup function returns the appropriate type, use that to reset the
variable. For other functions (usually the foreign ones which return void), add
an explicit value to reset to.

This causes a bit of code churn, but I think it might be worth it. In a
following patch static destructors will be called from a fuzzer, and this
change allows them to be called multiple times. But I think such a change might
help with detecting unitialized code reuse too. We hit various bugs like this,
and things are more obvious when a pointer has been set to NULL.

I was worried whether this change increases text size, but it doesn't seem to:

-Dbuildtype=debug:
before "tree-wide: return NULL from freeing functions":
-rwxrwxr-x 1 zbyszek zbyszek 4117672 Feb 16 14:36 build/libsystemd.so.0.30.0*
-rwxrwxr-x 1 zbyszek zbyszek 4494520 Feb 16 15:06 build/systemd*
after "tree-wide: return NULL from freeing functions":
-rwxrwxr-x 1 zbyszek zbyszek 4117672 Feb 16 14:36 build/libsystemd.so.0.30.0*
-rwxrwxr-x 1 zbyszek zbyszek 4494576 Feb 16 15:10 build/systemd*
now:
-rwxrwxr-x 1 zbyszek zbyszek 4117672 Feb 16 14:36 build/libsystemd.so.0.30.0*
-rwxrwxr-x 1 zbyszek zbyszek 4494640 Feb 16 15:15 build/systemd*

-Dbuildtype=release:
before "tree-wide: return NULL from freeing functions":
-rwxrwxr-x 1 zbyszek zbyszek 5252256 Feb 14 14:47 build-rawhide/libsystemd.so.0.30.0*
-rwxrwxr-x 1 zbyszek zbyszek 1834184 Feb 16 15:09 build-rawhide/systemd*
after "tree-wide: return NULL from freeing functions":
-rwxrwxr-x 1 zbyszek zbyszek 5252256 Feb 14 14:47 build-rawhide/libsystemd.so.0.30.0*
-rwxrwxr-x 1 zbyszek zbyszek 1834184 Feb 16 15:10 build-rawhide/systemd*
now:
-rwxrwxr-x 1 zbyszek zbyszek 5252256 Feb 14 14:47 build-rawhide/libsystemd.so.0.30.0*
-rwxrwxr-x 1 zbyszek zbyszek 1834184 Feb 16 15:16 build-rawhide/systemd*

I would expect that the compiler would be able to elide the setting of a
variable if the variable is never used again. And this seems to be the case:
in optimized builds there is no change in size whatsoever. And the change in
size in unoptimized build is negligible.

Something strange is happening with size of libsystemd: it's bigger in
optimized builds. Something to figure out, but unrelated to this patch.

31 files changed:
src/basic/capability-util.h
src/basic/dlfcn-util.h
src/basic/fd-util.h
src/basic/fileio.c
src/basic/gcrypt-util.h
src/basic/macro.h
src/basic/selinux-util.c
src/basic/selinux-util.h
src/core/apparmor-setup.c
src/core/socket.c
src/home/homed-manager.c
src/home/homework-luks.c
src/home/user-record-sign.c
src/import/curl-util.h
src/journal-remote/microhttpd-util.h
src/journal/journalctl.c
src/libsystemd/sd-journal/compress.c
src/partition/repart.c
src/resolve/resolved-dnstls-gnutls.c
src/shared/acl-util.h
src/shared/blkid-util.h
src/shared/cryptsetup-util.h
src/shared/firewall-util-iptables.c
src/shared/libmount-util.h
src/shared/module-util.h
src/shared/mount-util.h
src/shared/openssl-util.h
src/shared/pkcs11-util.h
src/shared/pwquality-util.h
src/shared/seccomp-util.h
src/udev/udev-ctrl.c

index f5ce2905241d8139c05c1187d98feb7c10035ccc..d9489d7883cae7d5f5591d91cf2885d539c77953 100644 (file)
@@ -25,7 +25,7 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities);
 
 int drop_capability(cap_value_t cv);
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(cap_t, cap_free);
+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) {
index e0944f3aaf47e41e676eb7038bb4052309c77e41..aa713d328bc66592676d1a7e62480e5e4f74a276 100644 (file)
@@ -5,7 +5,7 @@
 
 #include "macro.h"
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(void*, dlclose);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(void*, dlclose, NULL);
 
 int dlsym_many_and_warn(void *dl, int level, ...);
 
index 2162537b80889e2776a9018b93b728565a110b8f..f05c2b5a15dc7ab6a03a96535c6b74d6f5d9af4d 100644 (file)
@@ -41,8 +41,8 @@ static inline void fclosep(FILE **f) {
         safe_fclose(*f);
 }
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, pclose);
-DEFINE_TRIVIAL_CLEANUP_FUNC(DIR*, closedir);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(FILE*, pclose, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(DIR*, closedir, NULL);
 
 #define _cleanup_close_ _cleanup_(closep)
 #define _cleanup_fclose_ _cleanup_(fclosep)
index f4708bc05f0fee1d2e592e12c3f8d2e45ea09c3e..21532515fbd7f6c1bac715336f02022c3dde9ccb 100644 (file)
@@ -1146,7 +1146,7 @@ static EndOfLineMarker categorize_eol(char c, ReadLineFlags flags) {
         return EOL_NONE;
 }
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, funlockfile);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(FILE*, funlockfile, NULL);
 
 int read_line_full(FILE *f, size_t limit, ReadLineFlags flags, char **ret) {
         size_t n = 0, allocated = 0, count = 0;
index c07b36cdb9f7588aca2812c499a31569179c6c3c..27dcc72028dcc27113257598baee9f15f0cafaf6 100644 (file)
@@ -14,7 +14,7 @@
 void initialize_libgcrypt(bool secmem);
 int string_hashsum(const char *s, size_t len, int md_algorithm, char **out);
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(gcry_md_hd_t, gcry_md_close);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(gcry_md_hd_t, gcry_md_close, NULL);
 #endif
 
 static inline int string_hashsum_sha224(const char *s, size_t len, char **out) {
index d4e3d3b8fb74ed21b7459166844002f89574d8b5..eebd0769dded2a81aa9a6a059132852137c7a005 100644 (file)
@@ -405,10 +405,20 @@ static inline int __coverity_check_and_return__(int condition) {
                 func(p);                                        \
         }
 
+/* When func() returns the void value (NULL, -1, …) of the appropriate type */
 #define DEFINE_TRIVIAL_CLEANUP_FUNC(type, func)                 \
         static inline void func##p(type *p) {                   \
                 if (*p)                                         \
+                        *p = func(*p);                          \
+        }
+
+/* When func() doesn't return the appropriate type, set variable to empty afterwards */
+#define DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(type, func, empty)     \
+        static inline void func##p(type *p) {                   \
+                if (*p != (empty)) {                            \
                         func(*p);                               \
+                        *p = (empty);                           \
+                }                                               \
         }
 
 #define _DEFINE_TRIVIAL_REF_FUNC(type, name, scope)             \
index bd22500b7ed858e9363d8e921a7b2dd4793c9b6f..cfc8464c66dd1a1cf3ed01bd756a6c0a8260908d 100644 (file)
@@ -29,7 +29,7 @@
 #include "time-util.h"
 
 #if HAVE_SELINUX
-DEFINE_TRIVIAL_CLEANUP_FUNC(context_t, context_free);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(context_t, context_free, NULL);
 #define _cleanup_context_free_ _cleanup_(context_freep)
 
 static int mac_selinux_reload(int seqno);
index 1236d6efdfef09da15b62a454a43211712f8fe40..1095bdef0eec09f32e4c7c9673a21a5a559a424d 100644 (file)
@@ -11,7 +11,7 @@
 #if HAVE_SELINUX
 #include <selinux/selinux.h>
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(char*, freecon);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(char*, freecon, NULL);
 #define _cleanup_freecon_ _cleanup_(freeconp)
 #endif
 
index e856f5c1831e58889aec4260f74eabe91b231535..304a3e6aac21393ac14a2def21311f249a9bb178 100644 (file)
 #include "strv.h"
 
 #if HAVE_APPARMOR
-DEFINE_TRIVIAL_CLEANUP_FUNC(aa_policy_cache *, aa_policy_cache_unref);
-DEFINE_TRIVIAL_CLEANUP_FUNC(aa_features *, aa_features_unref);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(aa_policy_cache *, aa_policy_cache_unref, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(aa_features *, aa_features_unref, NULL);
 #endif
 
 int mac_apparmor_setup(void) {
 #if HAVE_APPARMOR
-        int r;
         _cleanup_(aa_policy_cache_unrefp) aa_policy_cache *policy_cache = NULL;
         _cleanup_(aa_features_unrefp) aa_features *features = NULL;
         const char *current_file;
         _cleanup_free_ char *current_profile = NULL, *cache_dir_path = NULL;
+        int r;
 
         if (!mac_apparmor_use()) {
                 log_debug("AppArmor either not supported by the kernel or disabled.");
index 5631054cceeea60b489459493d47ccf65d6bb9c8..e9cacfdf3a237a264587c0e0f4f3a64f403b0a03 100644 (file)
@@ -1611,7 +1611,7 @@ static int socket_address_listen_in_cgroup(
         return fd;
 }
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(Socket *, socket_close_fds);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(Socket *, socket_close_fds, NULL);
 
 static int socket_open_fds(Socket *orig_s) {
         _cleanup_(socket_close_fdsp) Socket *s = orig_s;
index 91cabd5cef39b13a20a5ce5c29fb5b5031fc56b7..1b13002627f54cf0372c78d710dc5d2736c6edfa 100644 (file)
@@ -1343,7 +1343,7 @@ static int manager_load_key_pair(Manager *m) {
         return 1;
 }
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(EVP_PKEY_CTX*, EVP_PKEY_CTX_free);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(EVP_PKEY_CTX*, EVP_PKEY_CTX_free, NULL);
 
 static int manager_generate_key_pair(Manager *m) {
         _cleanup_(EVP_PKEY_CTX_freep) EVP_PKEY_CTX *ctx = NULL;
@@ -1454,7 +1454,7 @@ int manager_sign_user_record(Manager *m, UserRecord *u, UserRecord **ret, sd_bus
 }
 
 DEFINE_PRIVATE_HASH_OPS_FULL(public_key_hash_ops, char, string_hash_func, string_compare_func, free, EVP_PKEY, EVP_PKEY_free);
-DEFINE_TRIVIAL_CLEANUP_FUNC(EVP_PKEY*, EVP_PKEY_free);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(EVP_PKEY*, EVP_PKEY_free, NULL);
 
 static int manager_load_public_key_one(Manager *m, const char *path) {
         _cleanup_(EVP_PKEY_freep) EVP_PKEY *pkey = NULL;
index c6b34d28d402640c5e76719e52416ae05170393d..1d012c5d02ba7c678a65a57b47b181ed4ef7e7ce 100644 (file)
@@ -1592,10 +1592,10 @@ static int luks_format(
         return 0;
 }
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct fdisk_context*, fdisk_unref_context);
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct fdisk_partition*, fdisk_unref_partition);
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct fdisk_parttype*, fdisk_unref_parttype);
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct fdisk_table*, fdisk_unref_table);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_context*, fdisk_unref_context, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_partition*, fdisk_unref_partition, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_parttype*, fdisk_unref_parttype, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_table*, fdisk_unref_table, NULL);
 
 static int make_partition_table(
                 int fd,
index 8cd3a462513fea312afb7c9ea895a25c3d0a8d22..5ac92255c8b02a54d00f6a8cd4cf9fa389a4ac7a 100644 (file)
@@ -27,7 +27,7 @@ static int user_record_signable_json(UserRecord *ur, char **ret) {
         return json_variant_format(j, 0, ret);
 }
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(EVP_MD_CTX*, EVP_MD_CTX_free);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(EVP_MD_CTX*, EVP_MD_CTX_free, NULL);
 
 int user_record_sign(UserRecord *ur, EVP_PKEY *private_key, UserRecord **ret) {
         _cleanup_(json_variant_unrefp) JsonVariant *encoded = NULL, *v = NULL;
index 4ab52d73a4f1b5becb0318838d2ba53f1ac2abbe..6b4f992fe70d37ff043d63a952f6eb3568219a1d 100644 (file)
@@ -34,6 +34,6 @@ struct curl_slist *curl_slist_new(const char *first, ...) _sentinel_;
 int curl_header_strdup(const void *contents, size_t sz, const char *field, char **value);
 int curl_parse_http_time(const char *t, usec_t *ret);
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(CURL*, curl_easy_cleanup);
-DEFINE_TRIVIAL_CLEANUP_FUNC(CURLM*, curl_multi_cleanup);
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct curl_slist*, curl_slist_free_all);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(CURL*, curl_easy_cleanup, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(CURLM*, curl_multi_cleanup, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct curl_slist*, curl_slist_free_all, NULL);
index 7f90a09c7770253070b343d768c0d40ffe1ff939..a92ba57d0fa88da387ab3e4580576e9796e7c9b3 100644 (file)
@@ -80,5 +80,5 @@ int check_permissions(struct MHD_Connection *connection, int *code, char **hostn
  */
 int setup_gnutls_logger(char **categories);
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct MHD_Daemon*, MHD_stop_daemon);
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct MHD_Response*, MHD_destroy_response);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct MHD_Daemon*, MHD_stop_daemon, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct MHD_Response*, MHD_destroy_response, NULL);
index a1b7bee2a3b218bbc4f29d692e654fef1ede8708..3de3b4e26f06acec5e3c88d69002fa08451d733e 100644 (file)
@@ -166,8 +166,8 @@ typedef struct BootId {
 } BootId;
 
 #if HAVE_PCRE2
-DEFINE_TRIVIAL_CLEANUP_FUNC(pcre2_match_data*, sym_pcre2_match_data_free);
-DEFINE_TRIVIAL_CLEANUP_FUNC(pcre2_code*, sym_pcre2_code_free);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(pcre2_match_data*, sym_pcre2_match_data_free, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(pcre2_code*, sym_pcre2_code_free, NULL);
 
 static int pattern_compile(const char *pattern, unsigned flags, pcre2_code **out) {
         int errorcode, r;
index 429dbadb6c946453b2d9df82ca1b0005c0f62c0b..3ea3328c1e4320a85af1f9b5f91180fbadd95362 100644 (file)
 #include "util.h"
 
 #if HAVE_LZ4
-DEFINE_TRIVIAL_CLEANUP_FUNC(LZ4F_compressionContext_t, LZ4F_freeCompressionContext);
-DEFINE_TRIVIAL_CLEANUP_FUNC(LZ4F_decompressionContext_t, LZ4F_freeDecompressionContext);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(LZ4F_compressionContext_t, LZ4F_freeCompressionContext, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(LZ4F_decompressionContext_t, LZ4F_freeDecompressionContext, NULL);
 #endif
 
 #if HAVE_ZSTD
-DEFINE_TRIVIAL_CLEANUP_FUNC(ZSTD_CCtx *, ZSTD_freeCCtx);
-DEFINE_TRIVIAL_CLEANUP_FUNC(ZSTD_DCtx *, ZSTD_freeDCtx);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(ZSTD_CCtx*, ZSTD_freeCCtx, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(ZSTD_DCtx*, ZSTD_freeDCtx, NULL);
 
 static int zstd_ret_to_errno(size_t ret) {
         switch (ZSTD_getErrorCode(ret)) {
index 78c31187ea4142e0d47dba879bb3390ada9bc6ff..01e60e21334adb379a0401d0fa5a59339d9de138 100644 (file)
@@ -1268,10 +1268,10 @@ static int context_read_definitions(
         return 0;
 }
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct fdisk_context*, fdisk_unref_context);
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct fdisk_partition*, fdisk_unref_partition);
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct fdisk_parttype*, fdisk_unref_parttype);
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct fdisk_table*, fdisk_unref_table);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_context*, fdisk_unref_context, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_partition*, fdisk_unref_partition, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_parttype*, fdisk_unref_parttype, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct fdisk_table*, fdisk_unref_table, NULL);
 
 static int determine_current_padding(
                 struct fdisk_context *c,
index d3edd350b392a05a58695b3f70fa803d14d732c8..e7ccba934e5204b136af00dd457c2b83a74f0d4d 100644 (file)
@@ -11,7 +11,7 @@
 #include "resolved-manager.h"
 
 #define TLS_PROTOCOL_PRIORITY "NORMAL:-VERS-ALL:+VERS-TLS1.3:+VERS-TLS1.2"
-DEFINE_TRIVIAL_CLEANUP_FUNC(gnutls_session_t, gnutls_deinit);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(gnutls_session_t, gnutls_deinit, NULL);
 
 static ssize_t dnstls_stream_writev(gnutls_transport_ptr_t p, const giovec_t *iov, int iovcnt) {
         int r;
index 837e8699ee950a5e629b887693340f6eb1b92518..03595c665152ba5e6936a13be08ef752af7c8cde 100644 (file)
@@ -21,13 +21,13 @@ int fd_add_uid_acl_permission(int fd, uid_t uid, unsigned mask);
 
 /* acl_free takes multiple argument types.
  * Multiple cleanup functions are necessary. */
-DEFINE_TRIVIAL_CLEANUP_FUNC(acl_t, acl_free);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(acl_t, acl_free, NULL);
 #define acl_free_charp acl_free
-DEFINE_TRIVIAL_CLEANUP_FUNC(char*, acl_free_charp);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(char*, acl_free_charp, NULL);
 #define acl_free_uid_tp acl_free
-DEFINE_TRIVIAL_CLEANUP_FUNC(uid_t*, acl_free_uid_tp);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(uid_t*, acl_free_uid_tp, NULL);
 #define acl_free_gid_tp acl_free
-DEFINE_TRIVIAL_CLEANUP_FUNC(gid_t*, acl_free_gid_tp);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(gid_t*, acl_free_gid_tp, NULL);
 
 #else
 #define ACL_READ    0x04
index 3f38e9b3089abde8383d23119c9cf47439ae778b..aa444990fd8b4b83ef6ccc8cff94824cd46fd870 100644 (file)
@@ -6,5 +6,5 @@
 
 #  include "macro.h"
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(blkid_probe, blkid_free_probe);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(blkid_probe, blkid_free_probe, NULL);
 #endif
index 454bfa45327de049e0498144b05f4cf0e0b0bb1e..5ebb0ac576ad4ecfb5f86a2fa6804687d61e25e2 100644 (file)
@@ -50,8 +50,8 @@ static inline int sym_crypt_token_max(_unused_ const char *type) {
 
 int dlopen_cryptsetup(void);
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct crypt_device *, crypt_free);
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct crypt_device *, sym_crypt_free);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct crypt_device *, crypt_free, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct crypt_device *, sym_crypt_free, NULL);
 
 void cryptsetup_enable_logging(struct crypt_device *cd);
 
index fec3000e751e5a3037920874912a9cd6ceca41e6..982c61d8fbd81627bd70bdb219b1628074769608 100644 (file)
@@ -27,7 +27,7 @@
 #include "macro.h"
 #include "socket-util.h"
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct xtc_handle*, iptc_free);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct xtc_handle*, iptc_free, NULL);
 
 static int entry_fill_basics(
                 struct ipt_entry *entry,
index db9728c332a86d1a8131974852362d80eba5a040..cf19c56ed12a8a55d3dde5959eb3dfc55e8af33e 100644 (file)
@@ -8,8 +8,8 @@
 
 #include "macro.h"
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct libmnt_table*, mnt_free_table);
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct libmnt_iter*, mnt_free_iter);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct libmnt_table*, mnt_free_table, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct libmnt_iter*, mnt_free_iter, NULL);
 
 static inline int libmount_parse(
                 const char *path,
index 4db8c5f04ed6bf1ade57ba128180a938db8954aa..8ca6a06a070cd9d0768f797f982509086f749b46 100644 (file)
@@ -7,6 +7,6 @@
 
 DEFINE_TRIVIAL_CLEANUP_FUNC(struct kmod_ctx*, kmod_unref);
 DEFINE_TRIVIAL_CLEANUP_FUNC(struct kmod_module*, kmod_module_unref);
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct kmod_list*, kmod_module_unref_list);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct kmod_list*, kmod_module_unref_list, NULL);
 
 int module_load_and_warn(struct kmod_ctx *ctx, const char *module, bool verbose);
index 849c37e85b1ffbc988a46e9470ac4b7ad2155610..718389768605233971462af33ab8c6c480294fb7 100644 (file)
@@ -45,7 +45,7 @@ int bind_remount_one_with_mountinfo(const char *path, unsigned long new_flags, u
 
 int mount_move_root(const char *path);
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(FILE*, endmntent);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(FILE*, endmntent, NULL);
 #define _cleanup_endmntent_ _cleanup_(endmntentp)
 
 int mount_verbose_full(
index b753a690babb7d05376362020b4caff36737cba7..0f527e74c40982fb3b83c856dfc6f3a6ef17179e 100644 (file)
@@ -6,10 +6,10 @@
 #if HAVE_OPENSSL
 #  include <openssl/pem.h>
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(X509*, X509_free);
-DEFINE_TRIVIAL_CLEANUP_FUNC(X509_NAME*, X509_NAME_free);
-DEFINE_TRIVIAL_CLEANUP_FUNC(EVP_PKEY_CTX*, EVP_PKEY_CTX_free);
-DEFINE_TRIVIAL_CLEANUP_FUNC(EVP_CIPHER_CTX*, EVP_CIPHER_CTX_free);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(X509*, X509_free, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(X509_NAME*, X509_NAME_free, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(EVP_PKEY_CTX*, EVP_PKEY_CTX_free, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(EVP_CIPHER_CTX*, EVP_CIPHER_CTX_free, NULL);
 
 int rsa_encrypt_bytes(EVP_PKEY *pkey, const void *decrypted_key, size_t decrypted_key_size, void **ret_encrypt_key, size_t *ret_encrypt_key_size);
 
index 3fa2505deb3182d0d0b93915001e4491dfa2a54d..f32ab304299e458a470825ea5a22639217458cfa 100644 (file)
@@ -21,8 +21,8 @@ P11KitUri *uri_from_module_info(const CK_INFO *info);
 P11KitUri *uri_from_slot_info(const CK_SLOT_INFO *slot_info);
 P11KitUri *uri_from_token_info(const CK_TOKEN_INFO *token_info);
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(P11KitUri*, p11_kit_uri_free);
-DEFINE_TRIVIAL_CLEANUP_FUNC(CK_FUNCTION_LIST**, p11_kit_modules_finalize_and_release);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(P11KitUri*, p11_kit_uri_free, NULL);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(CK_FUNCTION_LIST**, p11_kit_modules_finalize_and_release, NULL);
 
 CK_RV pkcs11_get_slot_list_malloc(CK_FUNCTION_LIST *m, CK_SLOT_ID **ret_slotids, CK_ULONG *ret_n_slotids);
 
index de288bb017c4361e3a1696278a728d96ce8c3bdd..877f439d11723f3fd36af2c6c6099d0a3941030c 100644 (file)
@@ -19,7 +19,7 @@ extern const char* (*sym_pwquality_strerror)(char *buf, size_t len, int errcode,
 
 int dlopen_pwquality(void);
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(pwquality_settings_t*, sym_pwquality_free_settings);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(pwquality_settings_t*, sym_pwquality_free_settings, NULL);
 
 void pwq_maybe_disable_dictionary(pwquality_settings_t *pwq);
 int pwq_allocate_context(pwquality_settings_t **ret);
index ee6f7b878bd49423fea9eefd89ec87f200585750..b3d25c9f3f3e5d2c7ca50b9768fe4efa13324779 100644 (file)
@@ -121,7 +121,7 @@ extern uint32_t seccomp_local_archs[];
 #define ERRNO_IS_SECCOMP_FATAL(r)                                       \
         IN_SET(abs(r), EPERM, EACCES, ENOMEM, EFAULT)
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(scmp_filter_ctx, seccomp_release);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(scmp_filter_ctx, seccomp_release, NULL);
 
 int parse_syscall_archs(char **l, Set **ret_archs);
 
index 61090a6e4af4e1c4ad2b9f8a09de432a9c6fea3a..3d563547190cebce00464a44d6ead24a4b8fa40e 100644 (file)
@@ -167,7 +167,7 @@ static void udev_ctrl_disconnect_and_listen_again(struct udev_ctrl *uctrl) {
         /* We don't return NULL here because uctrl is not freed */
 }
 
-DEFINE_TRIVIAL_CLEANUP_FUNC(struct udev_ctrl *, udev_ctrl_disconnect_and_listen_again);
+DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(struct udev_ctrl*, udev_ctrl_disconnect_and_listen_again, NULL);
 
 static int udev_ctrl_connection_event_handler(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
         _cleanup_(udev_ctrl_disconnect_and_listen_againp) struct udev_ctrl *uctrl = NULL;