tree-wide: drop redundant _cleanup_ macros (#8810)
This drops a good number of type-specific _cleanup_ macros, and patches all users to just use the generic ones. In most recent code we abstained from defining type-specific macros, and this basically removes all those added already, with the exception of the really low-level ones. Having explicit macros for this is not too useful, as the expression without the extra macro is generally just 2ch wider. We should generally emphesize generic code, unless there are really good reasons for specific code, hence let's follow this in this case too. Note that _cleanup_free_ and similar really low-level, libc'ish, Linux API'ish macros continue to be defined, only the really high-level OO ones are dropped. From now on this should really be the rule: for really low-level stuff, such as memory allocation, fd handling and so one, go ahead and define explicit per-type macros, but for high-level, specific program code, just use the generic _cleanup_() macro directly, in order to keep things simple and as readable as possible for the uninitiated. Note that before this patch some of the APIs (notable libudev ones) were already used with the high-level macros at some places and with the generic _cleanup_ macro at others. With this patch we hence unify on the latter.
This commit is contained in:
committed by
Zbigniew Jędrzejewski-Szmek
parent
0d6f0ea6c1
commit
8e766630f0
+3
-3
@@ -2878,7 +2878,7 @@ static int uid_shift_pick(uid_t *shift, LockFile *ret_lock_file) {
|
||||
|
||||
for (;;) {
|
||||
char lock_path[STRLEN("/run/systemd/nspawn-uid/") + DECIMAL_STR_MAX(uid_t) + 1];
|
||||
_cleanup_release_lock_file_ LockFile lf = LOCK_FILE_INIT;
|
||||
_cleanup_(release_lock_file) LockFile lf = LOCK_FILE_INIT;
|
||||
|
||||
if (--n_tries <= 0)
|
||||
return -EBUSY;
|
||||
@@ -3286,7 +3286,7 @@ static int run(int master,
|
||||
.sa_flags = SA_NOCLDSTOP|SA_RESTART,
|
||||
};
|
||||
|
||||
_cleanup_release_lock_file_ LockFile uid_shift_lock = LOCK_FILE_INIT;
|
||||
_cleanup_(release_lock_file) LockFile uid_shift_lock = LOCK_FILE_INIT;
|
||||
_cleanup_close_ int etc_passwd_lock = -1;
|
||||
_cleanup_close_pair_ int
|
||||
kmsg_socket_pair[2] = { -1, -1 },
|
||||
@@ -3791,7 +3791,7 @@ int main(int argc, char *argv[]) {
|
||||
bool secondary = false, remove_directory = false, remove_image = false;
|
||||
pid_t pid = 0;
|
||||
union in_addr_union exposed = {};
|
||||
_cleanup_release_lock_file_ LockFile tree_global_lock = LOCK_FILE_INIT, tree_local_lock = LOCK_FILE_INIT;
|
||||
_cleanup_(release_lock_file) LockFile tree_global_lock = LOCK_FILE_INIT, tree_local_lock = LOCK_FILE_INIT;
|
||||
bool interactive, veth_created = false, remove_tmprootdir = false;
|
||||
char tmprootdir[] = "/tmp/nspawn-root-XXXXXX";
|
||||
_cleanup_(loop_device_unrefp) LoopDevice *loop = NULL;
|
||||
|
||||
Reference in New Issue
Block a user