lxc/0135-lxc-fix-code-warnings-for-cgfsng.c.patch
LiFeng 7b470b3cde lxc: internal change at 1.6
Change-Id: I5821dc8a44f724e59cee65e356dfae4fbae04f76
Signed-off-by: LiFeng <lifeng68@huawei.com>
2020-01-05 22:20:49 -05:00

56 lines
1.5 KiB
Diff

From 6c1e2e9db0e6f6cf685b60d62a74ba3994b0a333 Mon Sep 17 00:00:00 2001
From: LiFeng <lifeng68@huawei.com>
Date: Mon, 23 Dec 2019 03:20:14 -0500
Subject: [PATCH 135/138] 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