From e24fadd86ee6b991ec80c625ef307e22b9c7f38c Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Thu, 20 Jun 2019 09:49:27 +0000 Subject: [PATCH] clone: fix printing of zero clone flags * clone.c (SYS_FUNC(clone)): Fix printing of zero clone flags. * tests/clone-flags.c (main): Check it. --- clone.c | 17 +++++++++++------ tests/clone-flags.c | 5 +++++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/clone.c b/clone.c index 383b8a74..f43431ae 100644 --- a/clone.c +++ b/clone.c @@ -91,12 +91,17 @@ SYS_FUNC(clone) tcp->u_arg[ARG_STACKSIZE]); #endif tprints("flags="); - const char *sep = "|"; - if (!printflags64(clone_flags, flags, NULL)) - sep = ""; - if (sig != 0) { - tprints(sep); - printsignal(sig); + if (flags) { + printflags64(clone_flags, flags, "CLONE_???"); + if (sig) { + tprints("|"); + printsignal(sig); + } + } else { + if (sig) + printsignal(sig); + else + tprints("0"); } /* * TODO on syscall entry: diff --git a/tests/clone-flags.c b/tests/clone-flags.c index dbcf71df..49cdbb49 100644 --- a/tests/clone-flags.c +++ b/tests/clone-flags.c @@ -95,6 +95,11 @@ main(void) (unsigned long) child_stack + (child_stack_reported - child_stack_expected); + pid = do_clone(child, child_stack, child_stack_size, 0, 0); + printf("%s(child_stack=%#lx" STACK_SIZE_FMT ", flags=%s) = %d\n", + SYSCALL_NAME, child_stack_printed, STACK_SIZE_ARG + "0", pid); + pid = do_clone(child, child_stack, child_stack_size, CLONE_FS, 0); printf("%s(child_stack=%#lx" STACK_SIZE_FMT ", flags=%s) = %d\n", SYSCALL_NAME, child_stack_printed, STACK_SIZE_ARG -- 2.40.0