Re: [PATCH v3] selftests: futex: Fix missing free in main

From: Thomas Gleixner
Date: Fri Sep 06 2024 - 10:17:58 EST


On Fri, Sep 06 2024 at 10:19, zhangjiao2@xxxxxxxxxxxxxxxxxxxx wrote:
> @@ -362,6 +363,7 @@ int main(int argc, char *argv[])
> {
> char *test_name;
> int c, ret;
> + bool is_static = false;

what means is_static? It's not connected to test_name in any way and
please use reverse fir tree variable ordering

https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#variable-declarations

So either use a variable name which makes it clear that it is related to
test_name (something obvious like: name_allocated) or do

char *test_name, *default_name = TEST_NAME;

and do test_name = default_name; in the error path and then check for

(test_name != default_name)

Whatever you pick will be better than the non-obvious is_static.

Thanks,

tglx