Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1209976ybe; Wed, 11 Sep 2019 11:05:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzeYju0/eSYd8KadcQmYtpXnHvP1w54SSbn6eF3f/xojVIOKTkg6xxB+kJ9ar8Hz6uBZEVG X-Received: by 2002:a05:6402:17ae:: with SMTP id j14mr37529680edy.219.1568225139193; Wed, 11 Sep 2019 11:05:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568225139; cv=none; d=google.com; s=arc-20160816; b=yrrt/rr0oD2BrIHyB5uR6/MWBMq737SSbzpT2hv60DC/uui6jsl+GPmiDE+5mAHZMa erLo05tloM/KsKtf1QJKk1bFpZCsBddV9htNX+r9t0wjWbiFGFA7RMsHHucAG+1hqgdi 8XQIEigb43PnwJPqMF07rgFwYnoTlyPVYE0auEa8S8UUetUi4fDnyvdN6ksxABNEy/ci 7XkfYD3RK6l4SJccEbcC8aqXhmnw3XzoJ3jZaAmMnr/LbfkUxgewTrHkqJynxheXtQnh fJPvbdZOnTQOfGXnC6usk3tSnL6bBEDo190te70vDSDbD3pnPsC/gVEifm+vGIexScMF Dvdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=VsBvSz35faiD3PHdr7rx05tHtIxQx4DWDbc8PQ1oX04=; b=xI/vxglstM0FsyayqtXmNjM6ONR9mwj+vVlLcE9Zj+aPv4ZmrZTVfgTrtekua4TPME /xHvtfbCPin9jq61q6TIcNqz3qI4yeB+G67edo/ZjUIrWQ1Zt55aI29Uc/OrPSeSVSpZ PrHbSFP77MFEqrbG6Tb/CNL+TauLTGelmWKn3Y25Bru5hqoQdfvbprxiR9QQGu7TjLNE mETKLkmq+smLIJm5a21hbbLzYMAlKgM1VEpulob0VSEdBIBWbKuHGQgoZHggYGmkceAo 4NuQcKUpIjZxsOmDdHiDgvJb2aPHZXoSPuZ8/cZ+Ikqy+BNCqRY9UE8lNt3PM4A8JpAC AX9g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2si13204987edq.361.2019.09.11.11.05.14; Wed, 11 Sep 2019 11:05:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730008AbfIKSCd (ORCPT + 99 others); Wed, 11 Sep 2019 14:02:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60256 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729727AbfIKSCd (ORCPT ); Wed, 11 Sep 2019 14:02:33 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id ADCAD308212D; Wed, 11 Sep 2019 18:02:32 +0000 (UTC) Received: from asgard.redhat.com (ovpn-112-27.ams2.redhat.com [10.36.112.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 13B3F60872; Wed, 11 Sep 2019 18:02:29 +0000 (UTC) Date: Wed, 11 Sep 2019 19:02:03 +0100 From: Eugene Syromiatnikov To: linux-kernel@vger.kernel.org, Christian Brauner , Shuah Khan , linux-kselftest@vger.kernel.org Cc: Adrian Reber Subject: [PATCH v3 1/6] selftests/clone3: convert test modes into an enum Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Wed, 11 Sep 2019 18:02:32 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * tools/testing/selftests/clone3/clone3.c (CLONE3_ARGS_NO_TEST, CLONE3_ARGS_ALL_0, CLONE3_ARGS_ALL_1): Change into an enum. (call_clone3): Change test_mode parameter type to enum test_mode; use switch statement for actions that dependent on test_mode selection. (test_clone3): Change test_mode parameter type to enum test_mode. Signed-off-by: Eugene Syromiatnikov --- tools/testing/selftests/clone3/clone3.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/clone3/clone3.c b/tools/testing/selftests/clone3/clone3.c index a0f1989..7b65ee5 100644 --- a/tools/testing/selftests/clone3/clone3.c +++ b/tools/testing/selftests/clone3/clone3.c @@ -24,16 +24,18 @@ /* V1 includes set_tid */ #define CLONE3_ARGS_SIZE_V1 72 -#define CLONE3_ARGS_NO_TEST 0 -#define CLONE3_ARGS_ALL_0 1 -#define CLONE3_ARGS_ALL_1 2 +enum test_mode { + CLONE3_ARGS_NO_TEST, + CLONE3_ARGS_ALL_0, + CLONE3_ARGS_ALL_1, +}; static pid_t raw_clone(struct clone_args *args, size_t size) { return syscall(__NR_clone3, args, size); } -static int call_clone3(int flags, size_t size, int test_mode) +static int call_clone3(int flags, size_t size, enum test_mode test_mode) { struct clone_args args = {0}; pid_t ppid = -1; @@ -46,7 +48,8 @@ static int call_clone3(int flags, size_t size, int test_mode) if (size == 0) size = sizeof(struct clone_args); - if (test_mode == CLONE3_ARGS_ALL_0) { + switch (test_mode) { + case CLONE3_ARGS_ALL_0: args.flags = 0; args.pidfd = 0; args.child_tid = 0; @@ -56,7 +59,9 @@ static int call_clone3(int flags, size_t size, int test_mode) args. stack_size = 0; args.tls = 0; args.set_tid = 0; - } else if (test_mode == CLONE3_ARGS_ALL_1) { + break; + + case CLONE3_ARGS_ALL_1: args.flags = 1; args.pidfd = 1; args.child_tid = 1; @@ -66,6 +71,7 @@ static int call_clone3(int flags, size_t size, int test_mode) args. stack_size = 1; args.tls = 1; args.set_tid = 1; + break; } pid = raw_clone(&args, size); @@ -91,7 +97,8 @@ static int call_clone3(int flags, size_t size, int test_mode) return 0; } -static int test_clone3(int flags, size_t size, int expected, int test_mode) +static int test_clone3(int flags, size_t size, int expected, + enum test_mode test_mode) { int ret; -- 2.1.4