From patchwork Sat Aug 5 17:50:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13342644 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 D88E2C001DB for ; Sat, 5 Aug 2023 17:49:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8C0A18D0005; Sat, 5 Aug 2023 13:49:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 86FF38D0002; Sat, 5 Aug 2023 13:49:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 64E9F8D0005; Sat, 5 Aug 2023 13:49:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4F0238D0002 for ; Sat, 5 Aug 2023 13:49:38 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 19E6616034E for ; Sat, 5 Aug 2023 17:49:38 +0000 (UTC) X-FDA: 81090788436.10.3A18757 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by imf01.hostedemail.com (Postfix) with ESMTP id ED02F4000B for ; Sat, 5 Aug 2023 17:49:35 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=SFD1zt27; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf01.hostedemail.com: domain of andriy.shevchenko@linux.intel.com has no SPF policy when checking 192.55.52.88) smtp.mailfrom=andriy.shevchenko@linux.intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691257776; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Nl4rJPbf9lJRqy1FTNc3L1ii3wsmDMe6b6YFfzVSNO8=; b=Y6nGs5/j4jbDFRMxIx7tTS0hlwmAgy9uVyaTbM6Ci46Hk2+25RJ4djdaKsbDK43hP9/pf9 /u91GUtFMjh3H2MnYj/PJiPtxa9Hx/m1VAoTBmbVghov4Tul7R0o5S+BY0jSnUbondbQoV PWnKAcuv6r0vyWl/cY5EYm+FjYrm3eU= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=SFD1zt27; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf01.hostedemail.com: domain of andriy.shevchenko@linux.intel.com has no SPF policy when checking 192.55.52.88) smtp.mailfrom=andriy.shevchenko@linux.intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691257776; a=rsa-sha256; cv=none; b=b0wSkMtqv1p9ACuHtIrRsFIlsq0LNm55DoXLrvhvSK92FbK2SuWI9QCAPA7qwCPfVSB9En OgJ9X6DZohsz6DiccxoXypmgMyhxFXxAf7iNQQT2j2aUToT/oXT/D7hexvFe02nJWAa83P VIWzHBH4brCEfkeCP0WgmOqAUXAaF00= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691257776; x=1722793776; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TaWK1Xu3PSHBh+Y6Cr3TB9YkGt2K3wWn+qk8w07ZH0o=; b=SFD1zt275ImsC3npDSWExNWMrFiKljnCNbDx8pGQgUUI6WGmIyaM6sOe ODgS7BculzdgcdQX3fVLfuJUEJ/yRROoKG+vfN6JBvaYY6de77+NxZxh9 sudzEjnK6n01wn5zyKj4ASIhxneZ6nVaWud1xY/2XlCZx37QSF21ggfmn RTXlqF85/vA45g8JXjULst0yA3PAaRbwysHIjecJiFtIkcAATjQCilo7S tkIibgESnB6ZDxt3IQiLP+23rQxn/8TphC4MqVJt0sm4pd8xYU03JyajA gi+2QCFvK+C16WliiS3htlVAqWlSsMvYaRpSz1FcPSh7CunwRvPDBHGzO g==; X-IronPort-AV: E=McAfee;i="6600,9927,10793"; a="401292534" X-IronPort-AV: E=Sophos;i="6.01,258,1684825200"; d="scan'208";a="401292534" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2023 10:49:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10793"; a="820494257" X-IronPort-AV: E=Sophos;i="6.01,258,1684825200"; d="scan'208";a="820494257" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 05 Aug 2023 10:49:29 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 905ABF7; Sat, 5 Aug 2023 20:50:29 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Petr Mladek , Marco Elver , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org Cc: Steven Rostedt , Rasmus Villemoes , Sergey Senozhatsky , Alexander Potapenko , Dmitry Vyukov , Andrew Morton Subject: [PATCH v2 1/3] lib/vsprintf: Sort headers alphabetically Date: Sat, 5 Aug 2023 20:50:25 +0300 Message-Id: <20230805175027.50029-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230805175027.50029-1-andriy.shevchenko@linux.intel.com> References: <20230805175027.50029-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: ED02F4000B X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: ehtjge7xwsaem1bw7aq6hd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uTCH52sUUbAU6kjFP2t4afRtGfhNoB4eA3A1a0UAgUyb2EDazoAReYbXux9ydhkISGmHjes652s= 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: Sorting headers alphabetically helps locating duplicates, and make it easier to figure out where to insert new headers. Signed-off-by: Andy Shevchenko --- lib/test_printf.c | 17 +++++++---------- lib/vsprintf.c | 38 ++++++++++++++++++++------------------ 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/lib/test_printf.c b/lib/test_printf.c index 7677ebccf3c3..2ab09a0dc841 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -5,24 +5,21 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include +#include +#include +#include #include #include +#include #include #include +#include #include #include #include -#include - -#include -#include #include -#include - -#include -#include - -#include +#include #include "../tools/testing/selftests/kselftest_module.h" diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 40f560959b16..b17e0744a7bc 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -17,42 +17,44 @@ * - scnprintf and vscnprintf */ -#include #include #include #include -#include -#include /* for KSYM_SYMBOL_LEN */ -#include -#include +#include +#include #include -#include +#include +#include +#include #include +#include #include -#include -#include -#include -#include +#include /* for KSYM_SYMBOL_LEN */ +#include +#include +#include #include +#include +#include +#include +#include #include +#include +#include #include -#include -#include -#include -#include -#include -#include + #ifdef CONFIG_BLOCK #include #endif +#include + #include "../mm/internal.h" /* For the trace_print_flags arrays */ -#include /* for PAGE_SIZE */ #include /* cpu_to_le16 */ +#include /* for PAGE_SIZE */ #include -#include #include "kstrtox.h" /* Disable pointer hashing if requested */ From patchwork Sat Aug 5 17:50:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13342643 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 0D3AFC41513 for ; Sat, 5 Aug 2023 17:49:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 64F388D0001; Sat, 5 Aug 2023 13:49:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 58EAF8D0005; Sat, 5 Aug 2023 13:49:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3DC388D0002; Sat, 5 Aug 2023 13:49:36 -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 1F8FF8D0002 for ; Sat, 5 Aug 2023 13:49:36 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id ECB17401CD for ; Sat, 5 Aug 2023 17:49:35 +0000 (UTC) X-FDA: 81090788310.26.D37E435 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by imf06.hostedemail.com (Postfix) with ESMTP id 7E2C018000D for ; Sat, 5 Aug 2023 17:49:33 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=jSSlHpr0; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf06.hostedemail.com: domain of andriy.shevchenko@linux.intel.com has no SPF policy when checking 192.55.52.151) smtp.mailfrom=andriy.shevchenko@linux.intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691257774; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=APFaLpzRvkmsd23+nAQve4IWVf1KVk54bqCwJXd8ZvA=; b=7bUN/DirO0zKkAWA5f7z3mEw3uNadg2L3qeyfm5i91DIhjgDCK/ah9SDpuMRddJfzhxCAG D3qXqIPqQ5usNr94LfEoz25QpzM4lBV5/bXDf38NcLqQqLLvK4FZajjbMeGRo8965pROIO ZR8E1av2af3ptZ1RRY7W+mabBcDvx+8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=jSSlHpr0; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf06.hostedemail.com: domain of andriy.shevchenko@linux.intel.com has no SPF policy when checking 192.55.52.151) smtp.mailfrom=andriy.shevchenko@linux.intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691257774; a=rsa-sha256; cv=none; b=lTgoN3+gJBLhhL2VFDT60BaL2tjCfl+FCeZ1MdNoP2LNwfE8n5bF/M30PxXCuh4G4T3vma md7GtcknJMjl4FvfsPF8m45yr7FEtQPLBra6ehub6ovVJyevujfuA15OaJWWiay8N33SBq 2uAlPnnBCHwapwC+CgGejNELirltbvY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691257773; x=1722793773; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WwFlBTMWGP/2Noo8uToUlcYjMLDc5ySAvwUDql7sE7Y=; b=jSSlHpr0/OCujrrizHhDJhBToIyd21sKfSVutUtNPSE0/l/3B+bR+exE 4whM9u5wiAH3VnMOgmemvGQ1TvtiDmrnM+7I/sN3v3dgv+1Quqwvs1rZ9 YABD0f29u64nOQJ3O3IJAgM32kHttyRjJ4igsXeQKU1RrsH34nXr0+BjD 08hB6d9oksUMY/mHWV6Lj7bP+yPip40TPje/wtmHS3Fp8d0pQXvFfd8ny 5mn1iLWQjwyH7dRQmRznk6eRXrNrUN39nBBysIQcN2k5fqTkBeSURa0Fd 3WoDfCEKYYZRhyNbZgBAZMAEKilaDe2Rnx5HVZFpHqbr4xLYpAYhGNELS A==; X-IronPort-AV: E=McAfee;i="6600,9927,10793"; a="350638995" X-IronPort-AV: E=Sophos;i="6.01,258,1684825200"; d="scan'208";a="350638995" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2023 10:49:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10793"; a="733622471" X-IronPort-AV: E=Sophos;i="6.01,258,1684825200"; d="scan'208";a="733622471" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 05 Aug 2023 10:49:28 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9F9D5BAB; Sat, 5 Aug 2023 20:50:29 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Petr Mladek , Marco Elver , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org Cc: Steven Rostedt , Rasmus Villemoes , Sergey Senozhatsky , Alexander Potapenko , Dmitry Vyukov , Andrew Morton Subject: [PATCH v2 2/3] lib/vsprintf: Split out sprintf() and friends Date: Sat, 5 Aug 2023 20:50:26 +0300 Message-Id: <20230805175027.50029-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230805175027.50029-1-andriy.shevchenko@linux.intel.com> References: <20230805175027.50029-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7E2C018000D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 4o83rq8yj6s8ncg1ysu3nxckbjcxqmds X-HE-Tag: 1691257773-649370 X-HE-Meta: U2FsdGVkX1/p5mCg6b3hLzG0ZgY2PzlME0z0Tpng5o7O5zsbDLi/Mz5lBu/E3Ff6lCyp8hIWgIlxUYjNipNNQZuY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000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: kernel.h is being used as a dump for all kinds of stuff for a long time. sprintf() and friends are used in many drivers without need of the full kernel.h dependency train with it. Here is the attempt on cleaning it up by splitting out sprintf() and friends. Signed-off-by: Andy Shevchenko --- include/linux/kernel.h | 30 +----------------------------- include/linux/sprintf.h | 25 +++++++++++++++++++++++++ lib/test_printf.c | 1 + lib/vsprintf.c | 1 + 4 files changed, 28 insertions(+), 29 deletions(-) create mode 100644 include/linux/sprintf.h diff --git a/include/linux/kernel.h b/include/linux/kernel.h index b9e76f717a7e..cee8fe87e9f4 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -203,35 +204,6 @@ static inline void might_fault(void) { } void do_exit(long error_code) __noreturn; -extern int num_to_str(char *buf, int size, - unsigned long long num, unsigned int width); - -/* lib/printf utilities */ - -extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...); -extern __printf(2, 0) int vsprintf(char *buf, const char *, va_list); -extern __printf(3, 4) -int snprintf(char *buf, size_t size, const char *fmt, ...); -extern __printf(3, 0) -int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); -extern __printf(3, 4) -int scnprintf(char *buf, size_t size, const char *fmt, ...); -extern __printf(3, 0) -int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); -extern __printf(2, 3) __malloc -char *kasprintf(gfp_t gfp, const char *fmt, ...); -extern __printf(2, 0) __malloc -char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); -extern __printf(2, 0) -const char *kvasprintf_const(gfp_t gfp, const char *fmt, va_list args); - -extern __scanf(2, 3) -int sscanf(const char *, const char *, ...); -extern __scanf(2, 0) -int vsscanf(const char *, const char *, va_list); - -extern int no_hash_pointers_enable(char *str); - extern int get_option(char **str, int *pint); extern char *get_options(const char *str, int nints, int *ints); extern unsigned long long memparse(const char *ptr, char **retptr); diff --git a/include/linux/sprintf.h b/include/linux/sprintf.h new file mode 100644 index 000000000000..9ca23bcf9f42 --- /dev/null +++ b/include/linux/sprintf.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_KERNEL_SPRINTF_H_ +#define _LINUX_KERNEL_SPRINTF_H_ + +#include +#include + +int num_to_str(char *buf, int size, unsigned long long num, unsigned int width); + +__printf(2, 3) int sprintf(char *buf, const char * fmt, ...); +__printf(2, 0) int vsprintf(char *buf, const char *, va_list); +__printf(3, 4) int snprintf(char *buf, size_t size, const char *fmt, ...); +__printf(3, 0) int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); +__printf(3, 4) int scnprintf(char *buf, size_t size, const char *fmt, ...); +__printf(3, 0) int vscnprintf(char *buf, size_t size, const char *fmt, va_list args); +__printf(2, 3) __malloc char *kasprintf(gfp_t gfp, const char *fmt, ...); +__printf(2, 0) __malloc char *kvasprintf(gfp_t gfp, const char *fmt, va_list args); +__printf(2, 0) const char *kvasprintf_const(gfp_t gfp, const char *fmt, va_list args); + +__scanf(2, 3) int sscanf(const char *, const char *, ...); +__scanf(2, 0) int vsscanf(const char *, const char *, va_list); + +int no_hash_pointers_enable(char *str); + +#endif /* _LINUX_KERNEL_SPRINTF_H */ diff --git a/lib/test_printf.c b/lib/test_printf.c index 2ab09a0dc841..5adca19d34e2 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include "../tools/testing/selftests/kselftest_module.h" diff --git a/lib/vsprintf.c b/lib/vsprintf.c index b17e0744a7bc..c89719586d0c 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include From patchwork Sat Aug 5 17:50:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13342645 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 28DE5C001DE for ; Sat, 5 Aug 2023 17:49:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84BC18D0006; Sat, 5 Aug 2023 13:49:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7AE148D0002; Sat, 5 Aug 2023 13:49:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 600038D0006; Sat, 5 Aug 2023 13:49:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 38DCC8D0002 for ; Sat, 5 Aug 2023 13:49:39 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 011291C915F for ; Sat, 5 Aug 2023 17:49:38 +0000 (UTC) X-FDA: 81090788478.30.C6CCC9C Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by imf11.hostedemail.com (Postfix) with ESMTP id C681640020 for ; Sat, 5 Aug 2023 17:49:36 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=SfLidcpZ; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf11.hostedemail.com: domain of andriy.shevchenko@linux.intel.com has no SPF policy when checking 192.55.52.88) smtp.mailfrom=andriy.shevchenko@linux.intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691257777; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YiDRN4KLkDxtCAumuHw+kaAhuG4xOP0mLOcBIaK9ECQ=; b=yy+j+OapxCOF63lfsZOIYdvCM8oEqt5ng52zacSlEJwqocMkRcJDYt7s7rCUNs/ft/5bJJ 9GznxrQ6Bew/g/StFk/5vvhtGlj1PK7XCSLzrRWLzB2sCMZ6gABmApw+Nx0kPrna34/WG1 vmKcKLPBCVIKu41ktKHMjTN/4oQnqBQ= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=SfLidcpZ; dmarc=pass (policy=none) header.from=intel.com; spf=none (imf11.hostedemail.com: domain of andriy.shevchenko@linux.intel.com has no SPF policy when checking 192.55.52.88) smtp.mailfrom=andriy.shevchenko@linux.intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691257777; a=rsa-sha256; cv=none; b=5duIPm4Vk6h3EPjIuYs9TZqRP+QtDJhCpucrx4XvqZ+GbIbjxVq7l43XoDQiFIjqeiGDSk ABfPUyHJO6xEtoC4JiRyTV/5SeWCJgnzoI7dLkEVWnl0zDwTKLTERr/wzgXlzdMCqronSR uCx/wlaL9vh6lWHMbwbs/5GKma1JgHM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691257776; x=1722793776; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9t4+UHB5bV6ky/Acf0xEikn59MqZgagOLuXamRB5Rw0=; b=SfLidcpZvIBxZ/YztO1Ckf5lU/rzBKZcOeI++agB6SeXSd39XN/+WZzP o/ldur0i4RoNhsC4/8xr4guPBigmWpsYk28qicKLCl0cNt3+RkR0IuDHs 6vcTAADykiDJTw8/MbkXJf2foZ33QIV1Iu0TOMzBbX0iy+7JcRKx4ThPI tX9QGp352uOgWV5zDh43jXzNeYwgmou7+UCEVkjHwhyEUrxfFNraEkG4B vzqjB6tOK3UOu9K0uCivvqCrxYu7ukuhBct5EAVVBewQseZf9aHpuNOO6 sBQ5vhUIiDAqx9acJdi7BW54Fab4Ru85Jv5k3Ic8dby7RHiZSrH/O0kzE Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10793"; a="401292543" X-IronPort-AV: E=Sophos;i="6.01,258,1684825200"; d="scan'208";a="401292543" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Aug 2023 10:49:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10793"; a="820494258" X-IronPort-AV: E=Sophos;i="6.01,258,1684825200"; d="scan'208";a="820494258" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 05 Aug 2023 10:49:29 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id AA2F4F12; Sat, 5 Aug 2023 20:50:29 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Petr Mladek , Marco Elver , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org Cc: Steven Rostedt , Rasmus Villemoes , Sergey Senozhatsky , Alexander Potapenko , Dmitry Vyukov , Andrew Morton Subject: [PATCH v2 3/3] lib/vsprintf: Declare no_hash_pointers in sprintf.h Date: Sat, 5 Aug 2023 20:50:27 +0300 Message-Id: <20230805175027.50029-4-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230805175027.50029-1-andriy.shevchenko@linux.intel.com> References: <20230805175027.50029-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: C681640020 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: fjgpy6skjg5oezs639wxxkzumqt5z7zr X-HE-Tag: 1691257776-159233 X-HE-Meta: U2FsdGVkX18JCHFzooDz6Swuzl2OIPSgVKWaJ6oZRdtnOtS3/GZQcCWq1Y+RQUpOH5JH0tlM7t/pZJf+3SBuR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nnAdFSPvZbQDl3FNu4vSVfW+uVVpkTnq0bhhXYzKouy 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: Sparse is not happy to see non-static variable without declaration: lib/vsprintf.c:61:6: warning: symbol 'no_hash_pointers' was not declared. Should it be static? Declare respective variable in the sprintf.h. With this, add a comment to discourage its use if no real need. Signed-off-by: Andy Shevchenko Acked-by: Marco Elver --- include/linux/sprintf.h | 2 ++ lib/test_printf.c | 2 -- mm/kfence/report.c | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/linux/sprintf.h b/include/linux/sprintf.h index 9ca23bcf9f42..33dcbec71925 100644 --- a/include/linux/sprintf.h +++ b/include/linux/sprintf.h @@ -20,6 +20,8 @@ __printf(2, 0) const char *kvasprintf_const(gfp_t gfp, const char *fmt, va_list __scanf(2, 3) int sscanf(const char *, const char *, ...); __scanf(2, 0) int vsscanf(const char *, const char *, va_list); +/* These are for specific cases, do not use without real need */ +extern bool no_hash_pointers; int no_hash_pointers_enable(char *str); #endif /* _LINUX_KERNEL_SPRINTF_H */ diff --git a/lib/test_printf.c b/lib/test_printf.c index 5adca19d34e2..cf861dc22169 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -39,8 +39,6 @@ KSTM_MODULE_GLOBALS(); static char *test_buffer __initdata; static char *alloced_buffer __initdata; -extern bool no_hash_pointers; - static int __printf(4, 0) __init do_test(int bufsize, const char *expect, int elen, const char *fmt, va_list ap) diff --git a/mm/kfence/report.c b/mm/kfence/report.c index 197430a5be4a..c509aed326ce 100644 --- a/mm/kfence/report.c +++ b/mm/kfence/report.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -26,8 +27,6 @@ #define ARCH_FUNC_PREFIX "" #endif -extern bool no_hash_pointers; - /* Helper function to either print to a seq_file or to console. */ __printf(2, 3) static void seq_con_printf(struct seq_file *seq, const char *fmt, ...)