diff options
author | Roman Gushchin <guro@fb.com> | 2018-05-22 06:10:31 -0400 |
---|---|---|
committer | Shuah Khan (Samsung OSG) <shuah@kernel.org> | 2018-05-30 17:29:07 -0400 |
commit | adb31be4424cc22f328e6664280f5c4e4902aaf3 (patch) | |
tree | 7bc46a9f8724cbb97e5357c50377e6162e9816f6 | |
parent | 7b04d1e9c6d08b9f033f16ccc0394f86f00f33ef (diff) |
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: Roman Gushchin <guro@fb.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Shuah Khan (Samsung OSG) <shuah@kernel.org>
-rw-r--r-- | tools/testing/selftests/cgroup/cgroup_util.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/tools/testing/selftests/cgroup/cgroup_util.c b/tools/testing/selftests/cgroup/cgroup_util.c index 41cc3b5e5be1..b69bdeb4b9fe 100644 --- a/tools/testing/selftests/cgroup/cgroup_util.c +++ b/tools/testing/selftests/cgroup/cgroup_util.c | |||
@@ -59,8 +59,7 @@ char *cg_name(const char *root, const char *name) | |||
59 | size_t len = strlen(root) + strlen(name) + 2; | 59 | size_t len = strlen(root) + strlen(name) + 2; |
60 | char *ret = malloc(len); | 60 | char *ret = malloc(len); |
61 | 61 | ||
62 | if (name) | 62 | snprintf(ret, len, "%s/%s", root, name); |
63 | snprintf(ret, len, "%s/%s", root, name); | ||
64 | 63 | ||
65 | return ret; | 64 | return ret; |
66 | } | 65 | } |
@@ -70,8 +69,7 @@ char *cg_name_indexed(const char *root, const char *name, int index) | |||
70 | size_t len = strlen(root) + strlen(name) + 10; | 69 | size_t len = strlen(root) + strlen(name) + 10; |
71 | char *ret = malloc(len); | 70 | char *ret = malloc(len); |
72 | 71 | ||
73 | if (name) | 72 | snprintf(ret, len, "%s/%s_%d", root, name, index); |
74 | snprintf(ret, len, "%s/%s_%d", root, name, index); | ||
75 | 73 | ||
76 | return ret; | 74 | return ret; |
77 | } | 75 | } |