chiark / gitweb /
shared: remove pointless checks in auto-cleanup functions
authorMichal Schmidt <mschmidt@redhat.com>
Wed, 6 Mar 2013 13:17:59 +0000 (14:17 +0100)
committerMichal Schmidt <mschmidt@redhat.com>
Fri, 8 Mar 2013 09:09:31 +0000 (10:09 +0100)
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().

src/shared/set.c
src/shared/strv.c

index cd910d70abbc403eb54ae8eb50871c36f93929d6..111d53bb36e6bd95d50348ddd03ed02e24d44a01 100644 (file)
@@ -38,11 +38,7 @@ void set_free(Set* s) {
 }
 
 void set_freep(Set **s) {
 }
 
 void set_freep(Set **s) {
-        if (!s)
-                return;
-
         set_free(*s);
         set_free(*s);
-        *s = NULL;
 }
 
 void set_free_free(Set *s) {
 }
 
 void set_free_free(Set *s) {
@@ -50,11 +46,7 @@ void set_free_free(Set *s) {
 }
 
 void set_free_freep(Set **s) {
 }
 
 void set_free_freep(Set **s) {
-        if (!*s)
-                return;
-
         set_free_free(*s);
         set_free_free(*s);
-        *s = NULL;
 }
 
 int set_ensure_allocated(Set **s, hash_func_t hash_func, compare_func_t compare_func) {
 }
 
 int set_ensure_allocated(Set **s, hash_func_t hash_func, compare_func_t compare_func) {
index 60c47625723296b624a0c6394a2d54424e6c3f56..117382ed80052d14620a744f269b827a3cfd9a27 100644 (file)
@@ -65,11 +65,7 @@ void strv_free(char **l) {
 }
 
 void strv_freep(char ***l) {
 }
 
 void strv_freep(char ***l) {
-        if (!l)
-                return;
-
         strv_free(*l);
         strv_free(*l);
-        *l = NULL;
 }
 
 char **strv_copy(char **l) {
 }
 
 char **strv_copy(char **l) {