From patchwork Mon Sep 4 12:43:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Wieczor-Retman X-Patchwork-Id: 13373838 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 435E5C71153 for ; Mon, 4 Sep 2023 12:44:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07FCF8D0002; Mon, 4 Sep 2023 08:44:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 02FB08D0001; Mon, 4 Sep 2023 08:44:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E3B0E8D0002; Mon, 4 Sep 2023 08:44:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D4A648D0001 for ; Mon, 4 Sep 2023 08:44:32 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 9D4F21A0668 for ; Mon, 4 Sep 2023 12:44:32 +0000 (UTC) X-FDA: 81198883584.01.9CC3B1F Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by imf06.hostedemail.com (Postfix) with ESMTP id 95ADE180024 for ; Mon, 4 Sep 2023 12:44:29 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=cBZcK8Of; spf=pass (imf06.hostedemail.com: domain of maciej.wieczor-retman@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=maciej.wieczor-retman@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1693831470; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=tFYcAuCx+1S35XSt2aicZZYua+vSEZPA1egsfLYZDc0=; b=mCWfz9tcMrfAR4bE8X2Npc0xM5j2YcsYIZWjmvmloLHytuMmi4++A3cnU27tS8jnH1dv1h vci711EZDySl5B2pNkWJElM0fJ+1QZWmbUGUEVr8hBsfEpDk/XWE7RSBe1LCMWphHVuTyB kAYijaknoznYPVR/cIXujaVx0QHlep8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1693831470; a=rsa-sha256; cv=none; b=cWAge216RztKFo7sVgQnXxS91BIVetcCJDYrRYWF7hqZprN8IwIQLPz5sUHn4BPM7Ryh4M AipQAWlA87PXO0V0xNidqQ4xemNNFJ2u0By8E2plBuJOG5pMTehIJNwiDu8O4fmCq0bB98 fj06TcVWvD8z+jabS7cf4nBSL4Bzp6M= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=cBZcK8Of; spf=pass (imf06.hostedemail.com: domain of maciej.wieczor-retman@intel.com designates 192.55.52.43 as permitted sender) smtp.mailfrom=maciej.wieczor-retman@intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1693831469; x=1725367469; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=7OC8ieWLUaMKSqNXbWK6Ilf12UrX6NTH6dUWJKnSfd8=; b=cBZcK8Of3Lx6PvRZf2r8f1Fw8yHGoSNQAfre2sN8oeTLA3t702TruWPG yWKdruLKTVQ9kFn77jw0sdknI3nkhUCaS02YBVfiDnx5QN0b+cKxIXiOT PIW8a3iYJ5rrtK5vTqE9LH+IeShzifwPODAIFJRb4loN8wVDZx++UURtz 5lUgR916/PPWVVJDuh+bphiBDYZMMej+T28QNOr1MKvNbHddZunh/It10 TRGdYtWAPkdXYuD7QGK0gbxFhXIcdsckg96t+p602MpQrR8EGDDGiisHU yR1zGIEp5/Yi99igNug1ILEevXXUrzTtYcJisKCi7UNysEeGFLsGD19Vg A==; X-IronPort-AV: E=McAfee;i="6600,9927,10823"; a="462958527" X-IronPort-AV: E=Sophos;i="6.02,226,1688454000"; d="scan'208";a="462958527" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2023 05:44:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10823"; a="810888530" X-IronPort-AV: E=Sophos;i="6.02,226,1688454000"; d="scan'208";a="810888530" Received: from mfederki-mobl1.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.15.69]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Sep 2023 05:44:22 -0700 From: Wieczor-Retman Maciej To: akpm@linux-foundation.org, christian@kellner.me, fenghua.yu@intel.com, keescook@chromium.org, ndesaulniers@google.com, coltonlewis@google.com, dmatlack@google.com, vipinsh@google.com, seanjc@google.com, brauner@kernel.org, pbonzini@redhat.com, shuah@kernel.org, hannes@cmpxchg.org, nphamcs@gmail.com, reinette.chatre@intel.com Cc: ilpo.jarvinen@linux.intel.com, linux-kselftest@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v2 0/8] Add printf attribute to kselftest functions Date: Mon, 4 Sep 2023 14:43:14 +0200 Message-ID: X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: 95ADE180024 X-Rspam-User: X-Stat-Signature: yqxihnari6mik67yjskam97rjzm9suhi X-Rspamd-Server: rspam03 X-HE-Tag: 1693831469-74870 X-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Ud32hfIqs9UliqPgKtOsiKWTi6G3iDI4TkHLGkXFzhgafOyTa4= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Kselftest.h declares many variadic functions that can print some formatted message while also executing selftest logic. These declarations don't have any compiler mechanism to verify if passed arguments are valid in comparison with format specifiers used in printf() calls. Attribute addition can make debugging easier, the code more consistent and prevent mismatched or missing variables. Add a __printf() macro that validates types of variables passed to the format string. The macro is similarly used in other tools in the kernel. Add __printf() attributes to function definitions inside kselftest.h that use printing. Adding the __printf() macro exposes some mismatches in format strings across different selftests. Fix the mismatched format specifiers in multiple tests. Changelog v2: - Add review and fixes tags to patches. - Add two patches with mismatch fixes. - Fix missed attribute in selftests/kvm. (Andrew) - Fix previously missed issues in selftests/mm (Ilpo) Wieczor-Retman Maciej (8): selftests: Add printf attribute to ksefltest prints selftests/cachestat: Fix print_cachestat format selftests/openat2: Fix wrong format specifier selftests/pidfd: Fix ksft print formats selftests/sigaltstack: Fix wrong format specifier selftests/kvm: Replace attribute with macro selftests/mm: Substitute attribute with a macro selftests/resctrl: Fix wrong format specifier .../selftests/cachestat/test_cachestat.c | 2 +- tools/testing/selftests/kselftest.h | 18 ++++++++++-------- .../testing/selftests/kvm/include/test_util.h | 8 ++++---- tools/testing/selftests/mm/mremap_test.c | 2 +- tools/testing/selftests/mm/pkey-helpers.h | 2 +- tools/testing/selftests/openat2/openat2_test.c | 2 +- .../selftests/pidfd/pidfd_fdinfo_test.c | 2 +- tools/testing/selftests/pidfd/pidfd_test.c | 12 ++++++------ tools/testing/selftests/resctrl/cache.c | 2 +- tools/testing/selftests/sigaltstack/sas.c | 2 +- 10 files changed, 27 insertions(+), 25 deletions(-) base-commit: 9b1db732866bee060b9bca9493e5ebf5e8874c48