Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2567860rdb; Fri, 22 Sep 2023 02:24:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IESTvMGmOrLU3JvkP7IJyc87CLohAXJ7ne0GbhNoROX3QhMvmC2bilZIysOE9Rf430FPBRZ X-Received: by 2002:a17:903:278b:b0:1bd:edac:af44 with SMTP id jw11-20020a170903278b00b001bdedacaf44mr6935032plb.51.1695374657754; Fri, 22 Sep 2023 02:24:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695374657; cv=none; d=google.com; s=arc-20160816; b=pKYVuHG0ov5tb2Js2Cx/uIFPT09TAQhtySWCxqBvQCDkpnon+HNY3WAXWE0QI6juQi c5DUwSA0zmI+yh/Mv8ePEZI3tfXiSWEwQ/eCM0NFp3I+aDSnI5dOtDE4GELULODgujaR eZv/raPk/3I/8lF0+lp2XLhLPNMl0vv7Obb1umeRTyQKaeRHgQL+/COj23yOhBx4Hqql l1RY+xt+UWwC+UDVrP8l7/iGpfPmMgnsmllOP5vl9saFPp/Kh2h2wL6Z+o4obyjt+K0M TqYPp8x8D1rtuyhuEMy9IGXcHP004ZaSGtrZruUEpxJOaUpL+eEH7Q5CJ25tt1qv/iny 5Cyg== 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:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id jc6-20020a17090325c600b001c386f8dd0asi3218164plb.179.2023.09.22.02.24.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 02:24:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; 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:3 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 lipwig.vger.email (Postfix) with ESMTP id 6C774835D96C; Fri, 22 Sep 2023 02:07:12 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232830AbjIVJHJ (ORCPT + 99 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 22 Sep 2023 02:07:12 -0700 (PDT) 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 --- 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; -- 2.42.0