* [PATCH] kselftest/cgroup: fix variable dereferenced before check warning
@ 2018-05-22 10:10 Roman Gushchin
2018-05-22 15:35 ` Shuah Khan
0 siblings, 1 reply; 2+ messages in thread
From: Roman Gushchin @ 2018-05-22 10:10 UTC (permalink / raw)
To: Shuah Khan; +Cc: linux-kernel, Roman Gushchin, linux-kselftest
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>
Cc: linux-kselftest@vger.kernel.org
---
tools/testing/selftests/cgroup/cgroup_util.c | 6 ++----
1 file 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)
size_t len = strlen(root) + strlen(name) + 2;
char *ret = malloc(len);
- if (name)
- snprintf(ret, len, "%s/%s", root, name);
+ snprintf(ret, len, "%s/%s", root, name);
return ret;
}
@@ -70,8 +69,7 @@ char *cg_name_indexed(const char *root, const char *name, int index)
size_t len = strlen(root) + strlen(name) + 10;
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;
}
--
2.14.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] kselftest/cgroup: fix variable dereferenced before check warning
2018-05-22 10:10 [PATCH] kselftest/cgroup: fix variable dereferenced before check warning Roman Gushchin
@ 2018-05-22 15:35 ` Shuah Khan
0 siblings, 0 replies; 2+ messages in thread
From: Shuah Khan @ 2018-05-22 15:35 UTC (permalink / raw)
To: Roman Gushchin; +Cc: linux-kernel, linux-kselftest, Shuah Khan
On 05/22/2018 04:10 AM, Roman Gushchin wrote:
> 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>
> Cc: linux-kselftest@vger.kernel.org
Thanks. I will queue this up for 4.18-rc1
-- Shuah
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-22 15:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-22 10:10 [PATCH] kselftest/cgroup: fix variable dereferenced before check warning Roman Gushchin
2018-05-22 15:35 ` Shuah Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox