[LTP] [PATCH v4 2/2] ptrace06: Refactor the test using new LTP API
Petr Vorel
pvorel@suse.cz
Thu Jan 9 09:55:43 CET 2025
Hi Wei,
> +static inline char *strptrace(int request)
> +{
> + return strings[request];
> +}
Why not just use strings[tc->request] directly?
> +
> +static void child(void)
> +{
> +
Blank line.
> + char path[512];
Unused variable (it's always nice to compile test and pay attention to the
warnings before sending it to ML).
The rest LGTM.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
I suggest to merge with following diff.
Thanks!
Kind regards,
Petr
+++ testcases/kernel/syscalls/ptrace/ptrace06.c
@@ -8,7 +8,7 @@
/*\
* [Description]
*
- * check out-of-bound/unaligned addresses given to
+ * Check out-of-bound/unaligned addresses given to
*
* - {PEEK,POKE}{DATA,TEXT,USER}
* - {GET,SET}{,FG}REGS
@@ -24,11 +24,11 @@
*/
#if defined(__i386__)
-#define SIZEOF_USER 284
+# define SIZEOF_USER 284
#elif defined(__x86_64__)
-#define SIZEOF_USER 928
+# define SIZEOF_USER 928
#else
-#define SIZEOF_USER 0x1000 /* just pick a big number */
+# define SIZEOF_USER 0x1000 /* just pick a big number */
#endif
static struct test_case_t {
@@ -177,16 +177,8 @@ static char *strings[] = {
SPT(SINGLESTEP)
};
-static inline char *strptrace(int request)
-{
- return strings[request];
-}
-
static void child(void)
{
-
- char path[512];
-
SAFE_PTRACE(PTRACE_TRACEME, 0, NULL, NULL);
raise(SIGSTOP);
exit(0);
@@ -217,7 +209,7 @@ static void run(void)
TST_EXP_FAIL_ARR(ptrace(tc->request, pid, (void *)tc->addr,
(void *)tc->data), exp_errnos, ARRAY_SIZE(exp_errnos),
"ptrace(%s, ..., %li, %li) failed as expected",
- strptrace(tc->request), tc->addr, tc->data);
+ strings[tc->request], tc->addr, tc->data);
}
SAFE_PTRACE(PTRACE_CONT, pid, NULL, NULL);
More information about the ltp
mailing list