From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14FB1C5517A for ; Sun, 1 Nov 2020 20:13:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9A0BD208B6 for ; Sun, 1 Nov 2020 20:13:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9A0BD208B6 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1CD586B0074; Sun, 1 Nov 2020 15:13:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B8A46B0075; Sun, 1 Nov 2020 15:13:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E4BFD6B0078; Sun, 1 Nov 2020 15:13:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0195.hostedemail.com [216.40.44.195]) by kanga.kvack.org (Postfix) with ESMTP id AF9E06B0074 for ; Sun, 1 Nov 2020 15:13:05 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 4A2D9181AEF10 for ; Sun, 1 Nov 2020 20:13:05 +0000 (UTC) X-FDA: 77436948330.03.hands62_350821a272aa Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 24A3028A4EA for ; Sun, 1 Nov 2020 20:13:05 +0000 (UTC) X-HE-Tag: hands62_350821a272aa X-Filterd-Recvd-Size: 3344 Received: from smtprelay.hostedemail.com (smtprelay0031.hostedemail.com [216.40.44.31]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Sun, 1 Nov 2020 20:13:04 +0000 (UTC) Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay06.hostedemail.com (Postfix) with ESMTP id 83CE918224D76; Sun, 1 Nov 2020 20:13:04 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: dog73_2e0c98d272aa X-Filterd-Recvd-Size: 2268 Received: from joe-laptop.perches.com (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf04.hostedemail.com (Postfix) with ESMTPA; Sun, 1 Nov 2020 20:13:03 +0000 (UTC) From: Joe Perches To: Hugh Dickins , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] mm: shmem: Convert shmem_enabled_show to use sysfs_emit_at Date: Sun, 1 Nov 2020 12:12:51 -0800 Message-Id: X-Mailer: git-send-email 2.26.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: Update the function to use sysfs_emit_at while neatening the uses of sprintf and overwriting the last space char with a newline. Signed-off-by: Joe Perches --- mm/shmem.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 5009d783d954..294ba0017a0f 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -4024,7 +4024,7 @@ int __init shmem_init(void) =20 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && defined(CONFIG_SYSFS) static ssize_t shmem_enabled_show(struct kobject *kobj, - struct kobj_attribute *attr, char *buf) + struct kobj_attribute *attr, char *buf) { static const int values[] =3D { SHMEM_HUGE_ALWAYS, @@ -4034,16 +4034,19 @@ static ssize_t shmem_enabled_show(struct kobject = *kobj, SHMEM_HUGE_DENY, SHMEM_HUGE_FORCE, }; - int i, count; - - for (i =3D 0, count =3D 0; i < ARRAY_SIZE(values); i++) { - const char *fmt =3D shmem_huge =3D=3D values[i] ? "[%s] " : "%s "; + int len =3D 0; + int i; =20 - count +=3D sprintf(buf + count, fmt, - shmem_format_huge(values[i])); + for (i =3D 0; i < ARRAY_SIZE(values); i++) { + len +=3D sysfs_emit_at(buf, len, + shmem_huge =3D=3D values[i] ? "%s[%s]" : "%s%s", + i ? " " : "", + shmem_format_huge(values[i])); } - buf[count - 1] =3D '\n'; - return count; + + len +=3D sysfs_emit_at(buf, len, "\n"); + + return len; } =20 static ssize_t shmem_enabled_store(struct kobject *kobj, --=20 2.26.0