From patchwork Fri Sep 22 09:06:37 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: 143417 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5550155vqi; Fri, 22 Sep 2023 06:00:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE35TKTOpbkm1Z6VCkzG2gnJm2RzyOxU4b31JcoAsixtMscEElEq+M0VrIsLEoXrpR2ziml X-Received: by 2002:a05:6a20:c1aa:b0:15c:b7ba:e9ba with SMTP id bg42-20020a056a20c1aa00b0015cb7bae9bamr8076486pzb.0.1695387603470; Fri, 22 Sep 2023 06:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695387603; cv=none; d=google.com; s=arc-20160816; b=baF1kRefg+OSTgTMNV5ui70eUQVGdwBSJwgft+jOnW+CM98gQ8yjq42TWvCojr4nuD sgZBn2rdKHm3hVWz/LAY3JKlJXq56R5Fwh63Efontvu7JH1Y8oaRHi6Y7Y7OV4PgAHsf 3DfczkvKc2ExfYp91nEbYtWisC0QbeoNx+o2vxNnsnP0cqdHokurPlSUpjZeVWAUI+VF 8TI2tLYfRrJhjm0K6rEU8PPzBg8nQgppY2+6krRGLEgtp9ruVop2+jkvwJU6tIp49kBp kKcHgbku5Ka447FxlmFi39XbLqOm6z1NKWneK09AtyF+5GrfuMCaI9IpbzKx+m6SWVrK /2OA== 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=ByieT2llU14KWfTToJs7mv76C6gkg5q7CFU/5J6HOts=; fh=fn0AWIQbuxjUao4CckPCArAms5Ae1ulO+SPfXoxHNbk=; b=pSzuDuyvrbrOWbhVA7LCDbfrlEVDLtOFeoBKU0S0LXS9lpZDfl355O5ycwCDCC2lmA cOlLhkr1vySwTFpLRNLAqTzLaAKGmh7pCDcltqxYFsxb5PLEkgaXD12ToWpZTT5itsu5 fDOG52vY/ezs82leBpodXMN2Rfq1fF7NpiD62P2CvmwU7nn8DeuyOeh3qjbfK6If0lD2 K2kl8J8CLF4YuOQ6gx8L1NLbHNsAJwhJ70xZO5+3d9Ojj+4tyRvxmLW94KY1uJHBZE2O kA8gTjDU5WaurEjYM/ITpQW9Bc0I9SEiOXf4uoMkz2o91N1a8eKfqo5CRl+zpKNegWex fpdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Di8dTY3f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id l11-20020a170902d04b00b001c432da203asi3618568pll.270.2023.09.22.05.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 06:00:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Di8dTY3f; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 1550E83421B6; Fri, 22 Sep 2023 02:07:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232543AbjIVJHJ (ORCPT + 30 others); Fri, 22 Sep 2023 05:07:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229576AbjIVJHG (ORCPT ); Fri, 22 Sep 2023 05:07:06 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10001C2; Fri, 22 Sep 2023 02:06:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1695373620; x=1726909620; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+bd+QBscp0NY6rRNQqvwBPLTBFFQn+H/2YyOTsEGJGY=; b=Di8dTY3fzyFEfjMpsUqNliSZUktVeYqKsStwcd0X6B2k28SoMo1NmdWb nZeuVpC6LVpKfgBOxHmFDLNl6kQ6kqGcC1K550ei/xOPnn1UWDl/X4i2E bSuC/pS/NR7tajbpHIg8HhATXn+NEvQnbPiq8CX+/HD6GcZmQwPP2npGU UrjbQW2is8WQ7HdEXbFg0OkpBFBAp9efPCwlmtGAgGLRb66a0p5Ba0536 rIxYMPBxiSfJ92mM7LjZgl9pScTup4O28p8N28K02UexVcDbvWahWqgbW KUxYht28yaTlJqwhvLhR4UwWDfrQN9rExkfqtSIy5e9QfaUxgpXCrk0Vp w==; X-IronPort-AV: E=McAfee;i="6600,9927,10840"; a="378070737" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="378070737" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 02:06:59 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10840"; a="837663632" X-IronPort-AV: E=Sophos;i="6.03,167,1694761200"; d="scan'208";a="837663632" Received: from bmatwiej-mobl.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.8.2]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Sep 2023 02:06:57 -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 v3 1/8] selftests: Add printf attribute to ksefltest prints Date: Fri, 22 Sep 2023 11:06:37 +0200 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Fri, 22 Sep 2023 02:07:12 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777742751400291556 X-GMAIL-MSGID: 1777742751400291556 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. Reviewed-by: Ilpo Järvinen Signed-off-by: Maciej Wieczor-Retman Reviewed-by: Reinette Chatre --- 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 529d29a35900..f4c677b5d68f 100644 --- a/tools/testing/selftests/kselftest.h +++ b/tools/testing/selftests/kselftest.h @@ -77,6 +77,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; @@ -143,7 +145,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; @@ -155,7 +157,7 @@ static inline void ksft_print_msg(const char *msg, ...) va_end(args); } -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; @@ -169,7 +171,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; @@ -195,7 +197,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; @@ -209,7 +211,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; @@ -224,7 +226,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; @@ -271,7 +273,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; @@ -298,7 +300,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;