From patchwork Fri Dec 10 17:33:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 12670449 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB522C433EF for ; Fri, 10 Dec 2021 17:34:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A7776B0073; Fri, 10 Dec 2021 12:33:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 456106B0074; Fri, 10 Dec 2021 12:33:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 31E7E6B0075; Fri, 10 Dec 2021 12:33:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 24ADB6B0073 for ; Fri, 10 Dec 2021 12:33:38 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DCE488249980 for ; Fri, 10 Dec 2021 17:33:27 +0000 (UTC) X-FDA: 78902581254.16.F8ABE80 Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) by imf25.hostedemail.com (Postfix) with ESMTP id 70DD8A0010 for ; Fri, 10 Dec 2021 17:33:26 +0000 (UTC) Received: by mail-ot1-f42.google.com with SMTP id x43-20020a056830246b00b00570d09d34ebso10344926otr.2 for ; Fri, 10 Dec 2021 09:33:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MYhfIoJvlZ3UvjgjTfCOCi8477KYN3hMlQaW6RBS+ig=; b=af9yfAM2vzCaX+swy2klbMoSrH2tkjLgvNjPp0zQZByY6sB9n0hkrMVuGwo8y7p4sl iEWkYM32+PBDmuzOdK0fJYMVX7YbtQRe7QOqh9iRvdW29YJVTnwap6Ilz1qoldCsQCyH 0rote55FZD2B/vSw6df149TN+E2Br2fgnwzyc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MYhfIoJvlZ3UvjgjTfCOCi8477KYN3hMlQaW6RBS+ig=; b=TnPTOtegXM+SZoVetKV0CeVIXiVR3GdIstUMVbxtHpgw9HMobA7Ut6/Z0BgK7qHpXx Ss5yKElNmelItvx2QkkCR0F/WOJvESHJNNiLYNeWbJjTTL85Z5iHDVhtKAMRYPK20k8d IC/GFmoh9h10MB7XRXjvo9H9fl6uM4iwBDfDlT18SRrFx2G18SidsPdXmP/N2PkiWiRJ QAx7TFcIXpB6iQ7GJvj7tg6nxX7InrqtIVk0rSWj+lR8qGx7FTu92wDCovatq6aF4vQT XZ8Te5PImyFYdc3PLMC8I6h6mc/hdpzkbU4hryD/S+yBA4zA2bxUf7gppaZ9CxlBa5ks Werw== X-Gm-Message-State: AOAM530orsSva4IJhV+PdINGOX5d/GhmkPDI/8DxeoSBUjWjNVDRIGv4 aZTTBOJMT3/1EhW7lS070gBzoA== X-Google-Smtp-Source: ABdhPJz+fdxZhcaBb0aXL1/U4YYsysQrmZmbnuOBIm+WLfQTPZbTuKYEVakW8zy1Ps1nYPL431Nd1w== X-Received: by 2002:a9d:69ce:: with SMTP id v14mr12130459oto.312.1639157606779; Fri, 10 Dec 2021 09:33:26 -0800 (PST) Received: from shuah-t480s.internal (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id x4sm892224oiv.35.2021.12.10.09.33.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Dec 2021 09:33:26 -0800 (PST) From: Shuah Khan To: catalin.marinas@arm.com, will@kernel.org, shuah@kernel.org, keescook@chromium.org, mic@digikod.net, davem@davemloft.net, kuba@kernel.org, peterz@infradead.org, paulmck@kernel.org, boqun.feng@gmail.com, akpm@linux-foundation.org Cc: Shuah Khan , linux-kselftest@vger.kernel.org, linux-security-module@vger.kernel.org, netdev@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 01/12] tools: fix ARRAY_SIZE defines in tools and selftests hdrs Date: Fri, 10 Dec 2021 10:33:11 -0700 Message-Id: <30585e0f0acfb523c6f7a93e0b916ae756e0c7e7.1639156389.git.skhan@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 70DD8A0010 X-Stat-Signature: aq94zk5cghnj41fzp84gjcx8ngffjpro Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=linuxfoundation.org header.s=google header.b=af9yfAM2; spf=pass (imf25.hostedemail.com: domain of skhan@linuxfoundation.org designates 209.85.210.42 as permitted sender) smtp.mailfrom=skhan@linuxfoundation.org; dmarc=pass (policy=none) header.from=linuxfoundation.org X-HE-Tag: 1639157606-953423 X-Bogosity: Ham, tests=bogofilter, spamicity=0.001656, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: tools/include/linux/kernel.h and kselftest_harness.h are missing ifndef guard around ARRAY_SIZE define. Fix them to avoid duplicate define errors during compile when another file defines it. This problem was found when compiling selftests that include a header with ARRAY_SIZE define. ARRAY_SIZE is defined in several selftests. There are about 25+ duplicate defines in various selftests source and header files. Add ARRAY_SIZE to kselftest.h in preparation for removing duplicate ARRAY_SIZE defines from individual test files. Signed-off-by: Shuah Khan Reviewed-by: Kees Cook --- tools/include/linux/kernel.h | 2 ++ tools/testing/selftests/kselftest.h | 4 ++++ tools/testing/selftests/kselftest_harness.h | 2 ++ 3 files changed, 8 insertions(+) diff --git a/tools/include/linux/kernel.h b/tools/include/linux/kernel.h index 3e8df500cfbd..9701e8307db0 100644 --- a/tools/include/linux/kernel.h +++ b/tools/include/linux/kernel.h @@ -92,7 +92,9 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); int scnprintf(char * buf, size_t size, const char * fmt, ...); int scnprintf_pad(char * buf, size_t size, const char * fmt, ...); +#ifndef ARRAY_SIZE #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) +#endif #define current_gfp_context(k) 0 #define synchronize_rcu() diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h index 8d50483fe204..f1180987492c 100644 --- a/tools/testing/selftests/kselftest.h +++ b/tools/testing/selftests/kselftest.h @@ -48,6 +48,10 @@ #include #include +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) +#endif + /* define kselftest exit codes */ #define KSFT_PASS 0 #define KSFT_FAIL 1 diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h index ae0f0f33b2a6..75164e23f036 100644 --- a/tools/testing/selftests/kselftest_harness.h +++ b/tools/testing/selftests/kselftest_harness.h @@ -671,7 +671,9 @@ #define EXPECT_STRNE(expected, seen) \ __EXPECT_STR(expected, seen, !=, 0) +#ifndef ARRAY_SIZE #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) +#endif /* Support an optional handler after and ASSERT_* or EXPECT_*. The approach is * not thread-safe, but it should be fine in most sane test scenarios.