|
Zbigniew Jędrzejewski-Szmek |
5d6eed |
From d7270c1642fa81b34b266d33412a842edc42c64c Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
Date: Mon, 7 Nov 2016 08:54:47 -0500
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
Subject: [PATCH] nspawn: avoid one strdup by using free_and_replace
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
(cherry picked from commit 49fedb4094b69d279095ef8ce8d9203161aed5d9)
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
---
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
src/core/namespace.c | 5 +++--
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
1 file changed, 3 insertions(+), 2 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
diff --git a/src/core/namespace.c b/src/core/namespace.c
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
index c45c120193..524416ecbd 100644
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
--- a/src/core/namespace.c
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
+++ b/src/core/namespace.c
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
@@ -678,8 +678,9 @@ static int chase_all_symlinks(const char *root_directory, BindMount *m, unsigned
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
* chase the symlinks on our own first. This call wil do so for all entries and remove all entries where we
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
* can't resolve the path, and which have been marked for such removal. */
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
- for (f = m, t = m; f < m+*n; f++) {
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
+ for (f = m, t = m; f < m + *n; f++) {
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
_cleanup_free_ char *chased = NULL;
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
+
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
r = chase_symlinks(f->path, root_directory, &chased);
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
if (r == -ENOENT && f->ignore) {
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
/* Doesn't exist? Then remove it! */
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
@@ -691,7 +692,7 @@ static int chase_all_symlinks(const char *root_directory, BindMount *m, unsigned
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
if (!path_equal(f->path, chased)) {
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
log_debug("Chased %s → %s", f->path, chased);
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
- r = free_and_strdup(&f->path, chased);
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
+ r = free_and_replace(f->path, chased);
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
03e93e |
}
|