From patchwork Wed Oct 11 08:23:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maciej Wieczor-Retman X-Patchwork-Id: 732325 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E152CD98FD for ; Wed, 11 Oct 2023 08:24:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230253AbjJKIYk (ORCPT ); Wed, 11 Oct 2023 04:24:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229846AbjJKIYk (ORCPT ); Wed, 11 Oct 2023 04:24:40 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD7BD93; Wed, 11 Oct 2023 01:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697012678; x=1728548678; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DODJjFottlxEJu0e1tIrYsECssXJAlmKZEBekFL0/ME=; b=VUSvqqpetOYSh100vMYFNrQW+PR5VadePHTwFfqAOYJOyDgV5YVgKYd4 MjBc9ik3VMhGRa05RCnbvEESFl6Nr/aYKuI4ZjJb5gMo6So/5hYpd0MnW BmCxbmeqKRFoCDUjXSfnOTqzBh1GWXGY7Tfk0b/85BgsLF12hBMijcK+U UTng9DGuFMdaUsoF4FMGGL+jvAcaOXiWpbQ1QzIXtIbdwRmZt/hIGXtCN fn6YWeOkJt5SAvj+qkmXqbmOZY5TH7Sq8f2BSjI1SzeITgE7uylrgbduR Q6NaB72egmrHXoPRzvhPLH2lOXV4Y1cMXUogS4WTTDa3a6OjTDPw4T9aS A==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="3200696" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="3200696" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 01:24:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="730411561" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="730411561" Received: from bmatwiej-mobl.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.17.119]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 01:24:26 -0700 From: Maciej Wieczor-Retman To: Shuah Khan Cc: ilpo.jarvinen@linux.intel.com, Reinette Chatre , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 1/8] selftests: Add printf attribute to kselftest prints Date: Wed, 11 Oct 2023 10:23:57 +0200 Message-ID: <13a47130763d109aa40de153ecbee9ede22d8356.1697012398.git.maciej.wieczor-retman@intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Kselftest header defines multiple variadic functions that use printf along with other logic. There is no format checking for the variadic functions that use printing inside kselftest.h. Because of this the compiler won't be able to catch instances of mismatched printf formats and debugging tests might be more difficult. Add the common __printf attribute macro to kselftest.h. Add __printf attribute to every function using formatted printing with variadic arguments. Signed-off-by: Maciej Wieczor-Retman Reviewed-by: Ilpo Järvinen Reviewed-by: Reinette Chatre --- Changelog v4: - Fix typo in patch subject. (Reinette) - Add Reinette's reviewed-by tag. tools/testing/selftests/kselftest.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/kselftest.h b/tools/testing/selftests/kselftest.h index af9f1202d423..5696199c16f9 100644 --- a/tools/testing/selftests/kselftest.h +++ b/tools/testing/selftests/kselftest.h @@ -78,6 +78,8 @@ #define KSFT_XPASS 3 #define KSFT_SKIP 4 +#define __printf(a, b) __attribute__((format(printf, a, b))) + /* counters */ struct ksft_count { unsigned int ksft_pass; @@ -144,7 +146,7 @@ static inline void ksft_print_cnts(void) ksft_cnt.ksft_xskip, ksft_cnt.ksft_error); } -static inline void ksft_print_msg(const char *msg, ...) +static inline __printf(1, 2) void ksft_print_msg(const char *msg, ...) { int saved_errno = errno; va_list args; @@ -169,7 +171,7 @@ static inline void ksft_perror(const char *msg) #endif } -static inline void ksft_test_result_pass(const char *msg, ...) +static inline __printf(1, 2) void ksft_test_result_pass(const char *msg, ...) { int saved_errno = errno; va_list args; @@ -183,7 +185,7 @@ static inline void ksft_test_result_pass(const char *msg, ...) va_end(args); } -static inline void ksft_test_result_fail(const char *msg, ...) +static inline __printf(1, 2) void ksft_test_result_fail(const char *msg, ...) { int saved_errno = errno; va_list args; @@ -209,7 +211,7 @@ static inline void ksft_test_result_fail(const char *msg, ...) ksft_test_result_fail(fmt, ##__VA_ARGS__);\ } while (0) -static inline void ksft_test_result_xfail(const char *msg, ...) +static inline __printf(1, 2) void ksft_test_result_xfail(const char *msg, ...) { int saved_errno = errno; va_list args; @@ -223,7 +225,7 @@ static inline void ksft_test_result_xfail(const char *msg, ...) va_end(args); } -static inline void ksft_test_result_skip(const char *msg, ...) +static inline __printf(1, 2) void ksft_test_result_skip(const char *msg, ...) { int saved_errno = errno; va_list args; @@ -238,7 +240,7 @@ static inline void ksft_test_result_skip(const char *msg, ...) } /* TODO: how does "error" differ from "fail" or "skip"? */ -static inline void ksft_test_result_error(const char *msg, ...) +static inline __printf(1, 2) void ksft_test_result_error(const char *msg, ...) { int saved_errno = errno; va_list args; @@ -285,7 +287,7 @@ static inline int ksft_exit_fail(void) ksft_cnt.ksft_xfail + \ ksft_cnt.ksft_xskip) -static inline int ksft_exit_fail_msg(const char *msg, ...) +static inline __printf(1, 2) int ksft_exit_fail_msg(const char *msg, ...) { int saved_errno = errno; va_list args; @@ -312,7 +314,7 @@ static inline int ksft_exit_xpass(void) exit(KSFT_XPASS); } -static inline int ksft_exit_skip(const char *msg, ...) +static inline __printf(1, 2) int ksft_exit_skip(const char *msg, ...) { int saved_errno = errno; va_list args; From patchwork Wed Oct 11 08:23:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maciej Wieczor-Retman X-Patchwork-Id: 732324 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3865FCD68E3 for ; Wed, 11 Oct 2023 08:24:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344927AbjJKIYo (ORCPT ); Wed, 11 Oct 2023 04:24:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230321AbjJKIYn (ORCPT ); Wed, 11 Oct 2023 04:24:43 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B97E692; Wed, 11 Oct 2023 01:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697012681; x=1728548681; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=b4TyoAhMCzLpIfy+bwpbogijkWzx9xqBmM+wkUI3lCg=; b=ntIWm+5GP6gRhHThVD75V9/eGp58ZBHO/+BHjPxwJtPH99TmkewWaVDp MJPc+MVrWoN9NNzluNRvQIFsri+7NmpENkgAy1nODcUouYX449x6viPTL m1r2d4xmnB5FqZB0IXD7vrYA4bj4sUeFXf3AWsjfOdWRdBY6YB7u1oPKV U2VzpPzfzHzVrmtOcWAxvCX3fpivOa0OagzVyC63rVhJEO7iruiF5BHTV MDlvyal/oP1O4i6OBSUVJiuOKU4s+O0gSq2PPJhGZ9TstE9K6nDAT8Eu1 5GKAcuuUeVyHZ9l+EZLYixRgp/eZUhS1d5S/ePP1Bv7BwwhLO99nz9Mrx g==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="3200768" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="3200768" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 01:24:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="730411635" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="730411635" Received: from bmatwiej-mobl.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.17.119]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 01:24:37 -0700 From: Maciej Wieczor-Retman To: Shuah Khan Cc: ilpo.jarvinen@linux.intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 3/8] selftests/openat2: Fix wrong format specifier Date: Wed, 11 Oct 2023 10:23:59 +0200 Message-ID: <177c35acb0e8921e3fce0928d19427b76708ea89.1697012398.git.maciej.wieczor-retman@intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Ksft_print_msg() inside test_openat2_flags() uses the wrong format specifier for printing test.how->flags variable. Change the format specifier to %llX so it matches the printed variable. Signed-off-by: Maciej Wieczor-Retman Reviewed-by: Ilpo Järvinen --- Changelog v2: - Added Reviewed-by tag (Ilpo) tools/testing/selftests/openat2/openat2_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/openat2/openat2_test.c b/tools/testing/selftests/openat2/openat2_test.c index 7fb902099de4..9024754530b2 100644 --- a/tools/testing/selftests/openat2/openat2_test.c +++ b/tools/testing/selftests/openat2/openat2_test.c @@ -300,7 +300,7 @@ void test_openat2_flags(void) ksft_print_msg("openat2 unexpectedly returned "); if (fdpath) - ksft_print_msg("%d['%s'] with %X (!= %X)\n", + ksft_print_msg("%d['%s'] with %X (!= %llX)\n", fd, fdpath, fdflags, test->how.flags); else From patchwork Wed Oct 11 08:24:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maciej Wieczor-Retman X-Patchwork-Id: 732323 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97A97CD6119 for ; Wed, 11 Oct 2023 08:24:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345311AbjJKIYy (ORCPT ); Wed, 11 Oct 2023 04:24:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230338AbjJKIYw (ORCPT ); Wed, 11 Oct 2023 04:24:52 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E78FE5; Wed, 11 Oct 2023 01:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697012691; x=1728548691; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IHXhr/Amo8gh/HA2VTVFzzTi37cYr/rpIJkcT+9qONg=; b=GmS8t6GDSmKu0CtDygyTFadd32639nQBJ8Dq7FWC8lEiYJuXKVY+sMb5 cLg4IiX+/zKwvMc5a5ENOZ2KGcLgMH/qAW/lnWvlPGwUEAVdddD7WW/O3 DXNyGxn0lVndA+LR7JxZuOxex/uJkNcvEytU77onwHxN8Q27gR4Cj0AgO KbHUripOXeRfmyEFwRzxI2Xw5OYtfrVRbSz/kF2bEhNJ0CQCYCQoCiSZA cmCQhFqxl/L0z/QKeQvHnA7xiQXRiRUvx2JoiCPt0cj1b9Yt9pP17Hkpr tHgpE9O2b1Rnpco3wA6YRb6PsIQWqrlvumlECIwTNMMTNm/9AqdOyOS/2 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="3200842" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="3200842" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 01:24:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="730411699" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="730411699" Received: from bmatwiej-mobl.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.17.119]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 01:24:48 -0700 From: Maciej Wieczor-Retman To: Shuah Khan Cc: ilpo.jarvinen@linux.intel.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 5/8] selftests/sigaltstack: Fix wrong format specifier Date: Wed, 11 Oct 2023 10:24:01 +0200 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The format specifier inside ksft printing function expects a long unsigned int but the passed variable is of unsigned int type. Fix the format specifier so it matches the passed variable. Signed-off-by: Maciej Wieczor-Retman Reviewed-by: Ilpo Järvinen --- Changelog v2: - Added Reviewed-by tag (Ilpo) tools/testing/selftests/sigaltstack/sas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/sigaltstack/sas.c b/tools/testing/selftests/sigaltstack/sas.c index 98d37cb744fb..07227fab1cc9 100644 --- a/tools/testing/selftests/sigaltstack/sas.c +++ b/tools/testing/selftests/sigaltstack/sas.c @@ -111,7 +111,7 @@ int main(void) /* Make sure more than the required minimum. */ stack_size = getauxval(AT_MINSIGSTKSZ) + SIGSTKSZ; - ksft_print_msg("[NOTE]\tthe stack size is %lu\n", stack_size); + ksft_print_msg("[NOTE]\tthe stack size is %u\n", stack_size); ksft_print_header(); ksft_set_plan(3); From patchwork Wed Oct 11 08:24:03 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: 732322 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99E5FCD98FD for ; Wed, 11 Oct 2023 08:25:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232818AbjJKIZd (ORCPT ); Wed, 11 Oct 2023 04:25:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345619AbjJKIZX (ORCPT ); Wed, 11 Oct 2023 04:25:23 -0400 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C67F11D; Wed, 11 Oct 2023 01:25:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697012720; x=1728548720; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=VXxoZYWc1k9TebbKU7+nIiD46KUiapqhrZ8TkPNyZG4=; b=gU30vLPbDmGiTPRB0Okz4GuTExMfwLMmmul6u8YypUsckG1M3klFdfnO mjpDjggmtRJbLIX3RvwMF3Vm29brsW6JUlR0qabnPbFQpkwjkFIalvT8j DEgKU65ywsDF3DMQlIY7Pij0tvJo839rmWmFwT2Thmumnu2XfZLU7v4T9 d1BuGd+ztHY/ZSHBU9aVeUL9X8qmKhCCFjSk13LzkBz5AGBVXvMEPMOeg pKjui7jNqw4El94OJsD7ZCs/WdofR0O4lzxfy7nhiEXkbVajnxv+HwUL5 tZS6kvv6omnMJLtobpwqH0rnTgukNRdd5T9w5FQXd7BGHEK/XB7BNET/n Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="3200903" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="3200903" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 01:25:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="730411781" X-IronPort-AV: E=Sophos;i="6.03,214,1694761200"; d="scan'208";a="730411781" Received: from bmatwiej-mobl.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.17.119]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Oct 2023 01:25:03 -0700 From: Maciej Wieczor-Retman To: Andrew Morton , Shuah Khan Cc: ilpo.jarvinen@linux.intel.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 7/8] selftests/mm: Substitute attribute with a macro Date: Wed, 11 Oct 2023 10:24:03 +0200 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org The mm selftest uses the printf attribute in its full form. Since the header file that uses it also includes kselftests.h it can use the macro defined there. Use __printf() included with kselftests.h instead of the full attribute. Fix a wrong format specifier in ksft_print_msg(). Signed-off-by: Maciej Wieczor-Retman --- Changelog v2: - Added this patch to the series. tools/testing/selftests/mm/mremap_test.c | 2 +- tools/testing/selftests/mm/pkey-helpers.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/mm/mremap_test.c b/tools/testing/selftests/mm/mremap_test.c index 5c3773de9f0f..1dbfcf6df255 100644 --- a/tools/testing/selftests/mm/mremap_test.c +++ b/tools/testing/selftests/mm/mremap_test.c @@ -338,7 +338,7 @@ static long long remap_region(struct config c, unsigned int threshold_mb, char c = (char) rand(); if (((char *) dest_addr)[i] != c) { - ksft_print_msg("Data after remap doesn't match at offset %d\n", + ksft_print_msg("Data after remap doesn't match at offset %llu\n", i); ksft_print_msg("Expected: %#x\t Got: %#x\n", c & 0xff, ((char *) dest_addr)[i] & 0xff); diff --git a/tools/testing/selftests/mm/pkey-helpers.h b/tools/testing/selftests/mm/pkey-helpers.h index 92f3be3dd8e5..1af3156a9db8 100644 --- a/tools/testing/selftests/mm/pkey-helpers.h +++ b/tools/testing/selftests/mm/pkey-helpers.h @@ -34,7 +34,7 @@ extern int test_nr; extern int iteration_nr; #ifdef __GNUC__ -__attribute__((format(printf, 1, 2))) +__printf(1, 2) #endif static inline void sigsafe_printf(const char *format, ...) {