* [LTP] [PATCH] futex_waitv01: Correct assign and add cleanup
@ 2022-04-13 11:24 Zhao Gongyi via ltp
2022-04-14 13:42 ` Cyril Hrubis
0 siblings, 1 reply; 3+ messages in thread
From: Zhao Gongyi via ltp @ 2022-04-13 11:24 UTC (permalink / raw)
To: ltp
1.Correct assign of waitv->uaddr
2.Rename function name of test_invalid_nr_futex
3.Add cleanup
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
testcases/kernel/syscalls/futex/futex_waitv01.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/testcases/kernel/syscalls/futex/futex_waitv01.c b/testcases/kernel/syscalls/futex/futex_waitv01.c
index 8b7bd50d3..ddc4be01c 100644
--- a/testcases/kernel/syscalls/futex/futex_waitv01.c
+++ b/testcases/kernel/syscalls/futex/futex_waitv01.c
@@ -10,6 +10,7 @@
*/
#include <time.h>
+#include <stdlib.h>
#include "tst_test.h"
#include "lapi/futex.h"
#include "futex2test.h"
@@ -32,7 +33,7 @@ static void init_timeout(struct timespec *to)
static void init_waitv(void)
{
- waitv->uaddr = (uintptr_t)&futex;
+ waitv->uaddr = (uintptr_t)futex;
waitv->flags = FUTEX_32 | FUTEX_PRIVATE_FLAG;
waitv->val = 0;
}
@@ -98,7 +99,7 @@ static void test_invalid_clockid(void)
"futex_waitv invalid clockid");
}
-static void test_invalid_nr_futex(void)
+static void test_invalid_nr_futexes(void)
{
struct timespec to;
@@ -112,6 +113,12 @@ static void test_invalid_nr_futex(void)
"futex_waitv invalid nr_futexes");
}
+static void cleanup(void)
+{
+ if (futex != NULL)
+ free(futex);
+}
+
static void run(void)
{
test_invalid_flags();
@@ -119,12 +126,13 @@ static void run(void)
test_null_address();
test_null_waiters();
test_invalid_clockid();
- test_invalid_nr_futex();
+ test_invalid_nr_futexes();
}
static struct tst_test test = {
.test_all = run,
.setup = setup,
+ .cleanup = cleanup,
.min_kver = "5.16",
.bufs =
(struct tst_buffers[]){
--
2.17.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] futex_waitv01: Correct assign and add cleanup
2022-04-13 11:24 [LTP] [PATCH] futex_waitv01: Correct assign and add cleanup Zhao Gongyi via ltp
@ 2022-04-14 13:42 ` Cyril Hrubis
2022-04-14 15:25 ` Petr Vorel
0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2022-04-14 13:42 UTC (permalink / raw)
To: Zhao Gongyi; +Cc: ltp
Hi!
> +static void cleanup(void)
> +{
> + if (futex != NULL)
> + free(futex);
free(NULL) is no-op, there is no reason to check for NULL before passing
a pointer to free().
The rest of the changes looks good to me.
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] futex_waitv01: Correct assign and add cleanup
2022-04-14 13:42 ` Cyril Hrubis
@ 2022-04-14 15:25 ` Petr Vorel
0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2022-04-14 15:25 UTC (permalink / raw)
To: Cyril Hrubis; +Cc: ltp
Hi Zhao, Cyril,
> Hi!
> > +static void cleanup(void)
> > +{
> > + if (futex != NULL)
> > + free(futex);
> free(NULL) is no-op, there is no reason to check for NULL before passing
> a pointer to free().
> The rest of the changes looks good to me.
Removed if check before free(futex) and merged with Cyril's Reviewed-by: tag.
Thanks!
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-04-14 15:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-13 11:24 [LTP] [PATCH] futex_waitv01: Correct assign and add cleanup Zhao Gongyi via ltp
2022-04-14 13:42 ` Cyril Hrubis
2022-04-14 15:25 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox