From a1e58e8ee1c84b633d6d6d651d5328d4dd4eba5b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 8 Sep 2015 18:43:11 +0200 Subject: tree-wide: use coccinelle to patch a lot of code to use mfree() This replaces this: free(p); p = NULL; by this: p = mfree(p); Change generated using coccinelle. Semantic patch is added to the sources. --- src/import/export-tar.c | 6 ++---- src/import/import-raw.c | 3 +-- src/import/import-tar.c | 3 +-- src/import/pull-dkr.c | 6 ++---- 4 files changed, 6 insertions(+), 12 deletions(-) (limited to 'src/import') diff --git a/src/import/export-tar.c b/src/import/export-tar.c index 5adc748c50..43fa9d1b03 100644 --- a/src/import/export-tar.c +++ b/src/import/export-tar.c @@ -287,8 +287,7 @@ int tar_export_start(TarExport *e, const char *path, int fd, ImportCompressType if (r >= 0) e->quota_referenced = q.referenced; - free(e->temp_path); - e->temp_path = NULL; + e->temp_path = mfree(e->temp_path); r = tempfn_random(path, NULL, &e->temp_path); if (r < 0) @@ -298,8 +297,7 @@ int tar_export_start(TarExport *e, const char *path, int fd, ImportCompressType r = btrfs_subvol_snapshot_fd(sfd, e->temp_path, BTRFS_SNAPSHOT_READ_ONLY|BTRFS_SNAPSHOT_RECURSIVE); if (r < 0) { log_debug_errno(r, "Couldn't create snapshot %s of %s, not exporting atomically: %m", e->temp_path, path); - free(e->temp_path); - e->temp_path = NULL; + e->temp_path = mfree(e->temp_path); } } diff --git a/src/import/import-raw.c b/src/import/import-raw.c index a27e81bbd4..5f7d25d063 100644 --- a/src/import/import-raw.c +++ b/src/import/import-raw.c @@ -249,8 +249,7 @@ static int raw_import_finish(RawImport *i) { if (r < 0) return log_error_errno(r, "Failed to move image into place: %m"); - free(i->temp_path); - i->temp_path = NULL; + i->temp_path = mfree(i->temp_path); return 0; } diff --git a/src/import/import-tar.c b/src/import/import-tar.c index 7ffe83cc33..d2bfb30238 100644 --- a/src/import/import-tar.c +++ b/src/import/import-tar.c @@ -205,8 +205,7 @@ static int tar_import_finish(TarImport *i) { if (r < 0) return log_error_errno(r, "Failed to move image into place: %m"); - free(i->temp_path); - i->temp_path = NULL; + i->temp_path = mfree(i->temp_path); return 0; } diff --git a/src/import/pull-dkr.c b/src/import/pull-dkr.c index 5ff49baa22..0dab184af1 100644 --- a/src/import/pull-dkr.c +++ b/src/import/pull-dkr.c @@ -1211,10 +1211,8 @@ static void dkr_pull_job_on_finished(PullJob *j) { log_info("Completed writing to layer %s.", i->final_path); i->layer_job = pull_job_unref(i->layer_job); - free(i->temp_path); - i->temp_path = NULL; - free(i->final_path); - i->final_path = NULL; + i->temp_path = mfree(i->temp_path); + i->final_path = mfree(i->final_path); i->current_ancestry ++; r = dkr_pull_pull_layer(i); -- cgit v1.2.3-54-g00ecf