]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/coredump/coredumpctl.c
tree-wide: drop license boilerplate
[thirdparty/systemd.git] / src / coredump / coredumpctl.c
index 2f8b9b7cbfc0a0b81355f6ba30833b495fb6990c..95c81f582638f37f8d5ef43f4c46d2ec1f9a1172 100644 (file)
@@ -3,19 +3,6 @@
   This file is part of systemd.
 
   Copyright 2012 Zbigniew JÄ™drzejewski-Szmek
-
-  systemd is free software; you can redistribute it and/or modify it
-  under the terms of the GNU Lesser General Public License as published by
-  the Free Software Foundation; either version 2.1 of the License, or
-  (at your option) any later version.
-
-  systemd is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  Lesser General Public License for more details.
-
-  You should have received a copy of the GNU Lesser General Public License
-  along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
 #include <fcntl.h>
@@ -67,8 +54,7 @@ static bool arg_quiet = false;
 
 static int add_match(sd_journal *j, const char *match) {
         _cleanup_free_ char *p = NULL;
-        char *pattern = NULL;
-        const char* prefix;
+        const char* prefix, *pattern;
         pid_t pid;
         int r;
 
@@ -91,6 +77,7 @@ static int add_match(sd_journal *j, const char *match) {
         r = sd_journal_add_match(j, pattern, 0);
         if (r < 0)
                 return log_error_errno(r, "Failed to add match \"%s\": %m", match);
+
         return 0;
 }
 
@@ -146,8 +133,7 @@ static int acquire_journal(sd_journal **ret, char **matches) {
                 log_debug("Journal filter: %s", filter);
         }
 
-        *ret = j;
-        j = NULL;
+        *ret = TAKE_PTR(j);
 
         return 0;
 }
@@ -764,8 +750,7 @@ static int save_core(sd_journal *j, FILE *file, char **path, bool *unlink_temp)
                         return log_error_errno(errno, "File \"%s\" is not readable: %m", filename);
 
                 if (path && !endswith(filename, ".xz") && !endswith(filename, ".lz4")) {
-                        *path = filename;
-                        filename = NULL;
+                        *path = TAKE_PTR(filename);
 
                         return 0;
                 }
@@ -1073,8 +1058,7 @@ int main(int argc, char *argv[]) {
 end:
         pager_close();
 
-        if (arg_output)
-                fclose(arg_output);
+        safe_fclose(arg_output);
 
         return r >= 0 ? r : EXIT_FAILURE;
 }