Commit adb31be4 authored by Roman Gushchin's avatar Roman Gushchin Committed by Shuah Khan (Samsung OSG)

kselftest/cgroup: fix variable dereferenced before check warning

cg_name(const char *root, const char *name) is always called with
non-empty root and name arguments, so there is no sense in checking
it in the function body (after using in strlen()).
Signed-off-by: default avatarRoman Gushchin <guro@fb.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarShuah Khan (Samsung OSG) <shuah@kernel.org>
parent 7b04d1e9
...@@ -59,7 +59,6 @@ char *cg_name(const char *root, const char *name) ...@@ -59,7 +59,6 @@ char *cg_name(const char *root, const char *name)
size_t len = strlen(root) + strlen(name) + 2; size_t len = strlen(root) + strlen(name) + 2;
char *ret = malloc(len); char *ret = malloc(len);
if (name)
snprintf(ret, len, "%s/%s", root, name); snprintf(ret, len, "%s/%s", root, name);
return ret; return ret;
...@@ -70,7 +69,6 @@ char *cg_name_indexed(const char *root, const char *name, int index) ...@@ -70,7 +69,6 @@ char *cg_name_indexed(const char *root, const char *name, int index)
size_t len = strlen(root) + strlen(name) + 10; size_t len = strlen(root) + strlen(name) + 10;
char *ret = malloc(len); char *ret = malloc(len);
if (name)
snprintf(ret, len, "%s/%s_%d", root, name, index); snprintf(ret, len, "%s/%s_%d", root, name, index);
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment