From patchwork Fri Aug 4 08:26:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13341450 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 813A8C001DB for ; Fri, 4 Aug 2023 08:26:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D4FC92802D3; Fri, 4 Aug 2023 04:26:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D001F8D0002; Fri, 4 Aug 2023 04:26:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC7A72802D3; Fri, 4 Aug 2023 04:26:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id ACC1A8D0002 for ; Fri, 4 Aug 2023 04:26:29 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 63FF012137B for ; Fri, 4 Aug 2023 08:26:29 +0000 (UTC) X-FDA: 81085740498.13.ED8897A Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by imf11.hostedemail.com (Postfix) with ESMTP id 958F840010 for ; Fri, 4 Aug 2023 08:26:26 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=OWjUces5; spf=none (imf11.hostedemail.com: domain of andriy.shevchenko@linux.intel.com has no SPF policy when checking 192.55.52.115) smtp.mailfrom=andriy.shevchenko@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691137587; 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=xN1TF/cqSYy8egconCIVN+MATNViZmMKhKgDRHlEMBE=; b=uX6K+iFXA/Udp5Uaqh8i7msLL19rchL6FYMQkFYzlLu6LJwr7kMxJUhBlC31YfYsdigQia DApehvijW4Iv5pGPuBJgbcnDjDsE89x0MuBUgO3XdBDthPpVZ7MvTNKadwbQJNRtFkYr1x h4oFJbVIm7Ufw7ldapQ+fdClx+4RrBA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691137587; a=rsa-sha256; cv=none; b=peJG7in7L16C04LV3KoLLcj1zK4D0OPKJDnQyUlDzbGB14hCGoirsBvjj/Tii1yc/PVjQ+ UzHdnH9CxuvPXWlSXaeTU5MY9uSKItes5Cfc6wAxYN4/DVvpPXLYEX/b8rXabkYbBumBKG xHqq7pc4Pg5skYO/lzazUoRdqNVXI+8= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=OWjUces5; spf=none (imf11.hostedemail.com: domain of andriy.shevchenko@linux.intel.com has no SPF policy when checking 192.55.52.115) smtp.mailfrom=andriy.shevchenko@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691137586; x=1722673586; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=oOKhR2UGvbPRHxNgYwLaRfSIwQ0Gyd6LYZcMKMFhKWQ=; b=OWjUces5p2+trDsCFfKDjSPPA7epI30+daOS7LGSXYxbPeBqFlXkf2YB dlGk3M22d184D8kTKQtXSv6zfUavWVfsbrD212eFmXY7GS1c5dBxaTqvx 4WbrcaODCPqNzYnyAbkmco7SC25F9tdfdmmAVOTznkqr7beICx1rA/oIm 4IOdzNikTZdzm9DDS5HP8gJ3rz0X4zYETJofI1jFOHac2CJnKy9zLPubR WLj7Fatb96SKyDdwzDqf1RSNGbxdUgaHEvuQ6d4xtKPZzwzfc4JV/zwLV 28MPNHadPAE/Bvg5bn7Nati+N7EkM0cKEoF3CKxFPmPfDQvaOf5SxDo6u w==; X-IronPort-AV: E=McAfee;i="6600,9927,10791"; a="370090214" X-IronPort-AV: E=Sophos;i="6.01,254,1684825200"; d="scan'208";a="370090214" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2023 01:26:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10791"; a="733132237" X-IronPort-AV: E=Sophos;i="6.01,254,1684825200"; d="scan'208";a="733132237" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 04 Aug 2023 01:26:21 -0700 Received: by black.fi.intel.com (Postfix, from userid 1003) id 99899F12; Fri, 4 Aug 2023 11:26:32 +0300 (EEST) From: Andy Shevchenko To: Andy Shevchenko , Marco Elver , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org Cc: Petr Mladek , Steven Rostedt , Rasmus Villemoes , Sergey Senozhatsky , Alexander Potapenko , Dmitry Vyukov , Andrew Morton Subject: [PATCH v1 4/4] lib/vsprintf: Split out sprintf() and friends Date: Fri, 4 Aug 2023 11:26:19 +0300 Message-Id: <20230804082619.61833-5-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.40.0.1.gaa8946217a0b In-Reply-To: <20230804082619.61833-1-andriy.shevchenko@linux.intel.com> References: <20230804082619.61833-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 958F840010 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ikcr3dbgok9qgqfyhxxpytcw71im3k1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yqj08ug2VfviCT4jN5UuW/3iAw5sGGuNUey9FMU5m8wU3MxzdO+JhMYT3ZPdr0yMNViDD65hSRgqrZoZiQVtmdt+lE4= 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: 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 | 24 ++++++++++++++++++++++++ lib/vsprintf.c | 1 + 3 files changed, 26 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..00d1fdc70a3e --- /dev/null +++ b/include/linux/sprintf.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_KERNEL_SPRINTF_H_ +#define _LINUX_KERNEL_SPRINTF_H_ + +#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/vsprintf.c b/lib/vsprintf.c index eb0934d02722..e553bc9e18f3 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include