56 lines
1.5 KiB
Diff
56 lines
1.5 KiB
Diff
From 5d7175b7d6ac7340c779c0102955f2099fc7b7e9 Mon Sep 17 00:00:00 2001
|
|
From: LiFeng <lifeng68@huawei.com>
|
|
Date: Mon, 23 Dec 2019 03:20:14 -0500
|
|
Subject: [PATCH 135/140] lxc: fix code warnings for cgfsng.c
|
|
|
|
Signed-off-by: LiFeng <lifeng68@huawei.com>
|
|
---
|
|
src/lxc/cgroups/cgfsng.c | 8 +++++---
|
|
1 file changed, 5 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
|
|
index 79fc5d3..9f0bb69 100644
|
|
--- a/src/lxc/cgroups/cgfsng.c
|
|
+++ b/src/lxc/cgroups/cgfsng.c
|
|
@@ -252,10 +252,12 @@ static char *read_file(const char *fnam)
|
|
static bool copy_parent_file(char *path, char *file)
|
|
{
|
|
int ret;
|
|
- char *fpath, *lastslash, oldv;
|
|
int len = 0;
|
|
char *value = NULL;
|
|
char *current = NULL;
|
|
+ char *fpath = NULL;
|
|
+ char *lastslash = NULL;
|
|
+ char oldv;
|
|
|
|
fpath = must_make_path(path, file, NULL);
|
|
current = read_file(fpath);
|
|
@@ -276,13 +278,14 @@ static bool copy_parent_file(char *path, char *file)
|
|
free(current);
|
|
|
|
lastslash = strrchr(path, '/');
|
|
- if (!lastslash) {
|
|
+ if (lastslash == NULL) {
|
|
ERROR("Failed to detect \"/\" in \"%s\"", path);
|
|
return false;
|
|
}
|
|
oldv = *lastslash;
|
|
*lastslash = '\0';
|
|
fpath = must_make_path(path, file, NULL);
|
|
+ *lastslash = oldv;
|
|
len = lxc_read_from_file(fpath, NULL, 0);
|
|
if (len <= 0)
|
|
goto on_error;
|
|
@@ -293,7 +296,6 @@ static bool copy_parent_file(char *path, char *file)
|
|
goto on_error;
|
|
free(fpath);
|
|
|
|
- *lastslash = oldv;
|
|
fpath = must_make_path(path, file, NULL);
|
|
ret = lxc_write_to_file(fpath, value, len, false, 0666);
|
|
if (ret < 0)
|
|
--
|
|
1.8.3.1
|
|
|