]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: yet another batch of coccinelle recommendations
authorFrantisek Sumsal <frantisek@sumsal.cz>
Wed, 1 Jan 2020 18:17:15 +0000 (19:17 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 2 Jan 2020 12:32:55 +0000 (13:32 +0100)
Prettify certain parts of the codebase using coccinelle transformations
(no functional changes).

src/basic/memory-util.h
src/basic/unit-name.c
src/cryptsetup/cryptsetup.c
src/libsystemd/sd-event/sd-event.c

index 4f92a6434a52ecf2436162052345363ac32a0815..b7e2e67e84c287f63a87d66ebe1dc4d39ff5c6d7 100644 (file)
@@ -7,6 +7,7 @@
 #include <string.h>
 #include <sys/types.h>
 
+#include "alloc-util.h"
 #include "macro.h"
 
 size_t page_size(void) _pure_;
@@ -88,9 +89,7 @@ static inline void* erase_and_free(void *p) {
 
         l = malloc_usable_size(p);
         explicit_bzero_safe(p, l);
-        free(p);
-
-        return NULL;
+        return mfree(p);
 }
 
 static inline void erase_and_freep(void *p) {
index 680e8eb4ab1fc99844ed188716cba3af2a2037cf..521364124fa3a5cdaecff2b9c5a9ec39589397bd 100644 (file)
@@ -621,7 +621,7 @@ int unit_name_mangle_with_suffix(const char *name, const char *operation, UnitNa
                         goto good;
                 log_full(flags & UNIT_NAME_MANGLE_WARN ? LOG_NOTICE : LOG_DEBUG,
                          "Glob pattern passed%s%s, but globs are not supported for this.",
-                         operation ? " " : "", operation ?: "");
+                         operation ? " " : "", strempty(operation));
                 suggest_escape = false;
         }
 
index 328873e0e100e76a45121686f9fec3fd134b5093..860b29b3b6c049aac28f1293b5d094a236c4b922 100644 (file)
@@ -455,10 +455,10 @@ static int attach_tcrypt(
         assert(name);
         assert(key_file || (passwords && passwords[0]));
 
-        if (arg_pkcs11_uri) {
-                log_error("Sorry, but tcrypt devices are currently not supported in conjunction with pkcs11 support.");
-                return -EAGAIN; /* Ask for a regular password */
-        }
+        if (arg_pkcs11_uri)
+                /* Ask for a regular password */
+                return log_error_errno(SYNTHETIC_ERRNO(EAGAIN),
+                                       "Sorry, but tcrypt devices are currently not supported in conjunction with pkcs11 support.");
 
         if (arg_tcrypt_hidden)
                 params.flags |= CRYPT_TCRYPT_HIDDEN_HEADER;
index 9771bf2e42cec3c8d6d64e26bef3955f3467ae29..17d232f9db30b21e571153b8f2a92d21ab9488ab 100644 (file)
@@ -828,9 +828,7 @@ static void source_disconnect(sd_event_source *s) {
         if (s->prepare)
                 prioq_remove(s->event->prepare, s, &s->prepare_index);
 
-        event = s->event;
-
-        s->event = NULL;
+        event = TAKE_PTR(s->event);
         LIST_REMOVE(sources, event->sources, s);
         event->n_sources--;