Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1800765rdb; Mon, 9 Oct 2023 03:31:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEc4XLoNQ3tn2t0MeBt8geWs5o3wj6zMfrIsFO6cNo76CrntdPfZQJJloYlSg61H6aeskMC X-Received: by 2002:a05:6a20:8f1f:b0:13d:5b8e:db83 with SMTP id b31-20020a056a208f1f00b0013d5b8edb83mr16503886pzk.9.1696847496127; Mon, 09 Oct 2023 03:31:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696847496; cv=none; d=google.com; s=arc-20160816; b=TIrftuF05YFjSsRo3POuI99iUYYJCMxFsSk7h1sAmwBYlgVotKoK5VMkigLQh2T4fO 368ZZjfHRcLbXesYYXuOD/1G5fS2EEEHDCSnYEY8NqSpQ9efsbGHW8t+49xDkmgoA2BJ wXoK7vqO3khkeLD5nHIX6ZfchsH6+WucTgumreJPI5knJbqw/BC5E/iLIzzN42Lxqt3N sN6HHetgkBP1qPmmRCPZ+Ss1y51mZ9gsrxw6i3Yadqc9kZv4IsETeBioXyCSUQSYJYwZ ZHbZfd6JNWs9DV3TCHUz+U0G7APqJaVsNg6NmJem13uyX94Ygbggm3BQrOutwqJ49Du0 FBJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=f/VUGoJn1gawgVJetYuTbv9Psy7s8v6Qiq9yrG7HZVc=; fh=3uvKWjK8lH0xuedqZ95iWSyYUFK+rVV9kRDprZNpWdA=; b=XiizhuL3rlwj9cNnSXTJ/hMhzSuPPmWosT03jRT3hGQVoj9rCn5O9uvGBYuICXucno CUqPm3F3ex3yen0agjO5Eu6BRFfDsjLWBhQRDWF4hudnl6M1Yxw2Tmsl9bNPY3bKIPoT NkfnEMZWpjQ9l4fTSsND6zzkTZY/jxv7nMdsKJ4KHwNHUkV9rujhq3O+Uldrh6NK9TRp NSgzJtPYWu4gY9qoxZGmQzEi4oqD4VGzg27iEtzvCR4Bi3N2itSmrsM6Y2GDljTJkbwy fYI6P1TKc6Wj/zYsqLa5DBS9U5nZ5F/L1P2avCNKTIY9zC9xa6+tp3+VWiZGw2g0jJ0O PRjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=giFWtOeW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id y18-20020a63b512000000b005897813624fsi8321217pge.476.2023.10.09.03.31.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 03:31:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=giFWtOeW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 563268041FED; Mon, 9 Oct 2023 03:31:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345724AbjJIKbP (ORCPT + 99 others); Mon, 9 Oct 2023 06:31:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345655AbjJIKbN (ORCPT ); Mon, 9 Oct 2023 06:31:13 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4542AA3; Mon, 9 Oct 2023 03:31:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696847471; x=1728383471; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DODJjFottlxEJu0e1tIrYsECssXJAlmKZEBekFL0/ME=; b=giFWtOeWicLZfxu9iLZCeNpPH0Ercp8rUmOFdOvNAgQ1RbakUpM/bYh+ NGxoc486OVlhXW7ZZOBu7OZyFrbSqgWlHQ5yDog+RGwH8JMKq9ptYXIo2 ex56+W91NnwUr6RuRIFxIl2VNTpKOicFPpNoiu8N4UEcRj78/HnBK8Ro6 dJVSNuBONt51K5uoQG8/pEI6F6ZlJ1r5b/2eZWWUANDxUEmXaQduJp04R 7+TMvhcqYpLF1Ro/dDhNqoYv+EcDm5Zb5w6ip0dQuHQ2MXMqh+NQo5io1 ihbb7s4iI5WjdEwmnjpXFRrInTklzp33YUy1WbIXBBH6EJ0zatHrg1hbk A==; X-IronPort-AV: E=McAfee;i="6600,9927,10857"; a="363468366" X-IronPort-AV: E=Sophos;i="6.03,210,1694761200"; d="scan'208";a="363468366" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2023 03:31:10 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10857"; a="926718647" X-IronPort-AV: E=Sophos;i="6.03,210,1694761200"; d="scan'208";a="926718647" Received: from kkensic-mobl1.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.30.239]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2023 03:31:08 -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 v4 1/8] selftests: Add printf attribute to kselftest prints Date: Mon, 9 Oct 2023 12:30:35 +0200 Message-ID: <9c14b1fcc057e31fdb2e2c9438cc4e04bf218d34.1696846568.git.maciej.wieczor-retman@intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 09 Oct 2023 03:31:32 -0700 (PDT) X-Spam-Level: ** 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; -- 2.42.0