From: Michal Schmidt Date: Wed, 6 Mar 2013 13:17:59 +0000 (+0100) Subject: shared: remove pointless checks in auto-cleanup functions X-Git-Tag: v199~258 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=5f1be48b264e4d556f688062cc6f4a1e03f9f455 shared: remove pointless checks in auto-cleanup functions The argument given to the __attribute__((cleanup)) functions is the address of the variable that's going out of scope. It cannot be NULL. The "if (!s)" check in set_freep() is pointless. Perhaps "if (!*s)" was intented. But that's pointless too, because set_free()/set_free_free() are OK to call with a NULL argument (just like free()). Setting "*s = NULL" is pointless, because the variable that s points to is about to go out of scope. The same holds for strv_freep(). --- diff --git a/src/shared/set.c b/src/shared/set.c index cd910d70a..111d53bb3 100644 --- a/src/shared/set.c +++ b/src/shared/set.c @@ -38,11 +38,7 @@ void set_free(Set* s) { } void set_freep(Set **s) { - if (!s) - return; - set_free(*s); - *s = NULL; } void set_free_free(Set *s) { @@ -50,11 +46,7 @@ void set_free_free(Set *s) { } void set_free_freep(Set **s) { - if (!*s) - return; - set_free_free(*s); - *s = NULL; } int set_ensure_allocated(Set **s, hash_func_t hash_func, compare_func_t compare_func) { diff --git a/src/shared/strv.c b/src/shared/strv.c index 60c476257..117382ed8 100644 --- a/src/shared/strv.c +++ b/src/shared/strv.c @@ -65,11 +65,7 @@ void strv_free(char **l) { } void strv_freep(char ***l) { - if (!l) - return; - strv_free(*l); - *l = NULL; } char **strv_copy(char **l) {