From patchwork Sun May 23 17:43:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 12274981 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=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED 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 E5E86C47080 for ; Sun, 23 May 2021 17:43:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA729611ED for ; Sun, 23 May 2021 17:43:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231878AbhEWRpX (ORCPT ); Sun, 23 May 2021 13:45:23 -0400 Received: from smtprelay0252.hostedemail.com ([216.40.44.252]:41256 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231853AbhEWRpX (ORCPT ); Sun, 23 May 2021 13:45:23 -0400 Received: from omf02.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id C8166837F24A; Sun, 23 May 2021 17:43:55 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf02.hostedemail.com (Postfix) with ESMTPA id 2204A1D42F4; Sun, 23 May 2021 17:43:55 +0000 (UTC) Message-ID: Subject: [trivial PATCH] vfs: fs_context: Deduplicate logging calls to reduce object size From: Joe Perches To: Alexander Viro Cc: linux-fsdevel , LKML Date: Sun, 23 May 2021 10:43:53 -0700 User-Agent: Evolution 3.38.1-1 MIME-Version: 1.0 X-Rspamd-Queue-Id: 2204A1D42F4 X-Stat-Signature: 8d8fgt3xrhk1y9u86ikemufubw4ryaqi X-Rspamd-Server: rspamout03 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX18BMTREeoJ3ECxEKQqNusDkcqT1ltHmelc= X-HE-Tag: 1621791835-754072 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Deduplicate the logging calls by using a temporary for KERN_ with miscellaneous source code neatening of the output calls. $ size fs/fs_context.o* #defconfig x86_64 text data bss dec hex filename 6727 192 0 6919 1b07 fs/fs_context.o.new 6802 192 0 6994 1b52 fs/fs_context.o.old Signed-off-by: Joe Perches --- fs/fs_context.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/fs/fs_context.c b/fs/fs_context.c index 2834d1afa6e80..2a6ff20da40f5 100644 --- a/fs/fs_context.c +++ b/fs/fs_context.c @@ -359,33 +359,40 @@ EXPORT_SYMBOL(vfs_dup_fs_context); * @fc: The filesystem context to log to. * @fmt: The format of the buffer. */ -void logfc(struct fc_log *log, const char *prefix, char level, const char *fmt, ...) +void logfc(struct fc_log *log, const char *prefix, char level, + const char *fmt, ...) { va_list va; struct va_format vaf = {.fmt = fmt, .va = &va}; va_start(va, fmt); if (!log) { + const char *kern_level; + switch (level) { case 'w': - printk(KERN_WARNING "%s%s%pV\n", prefix ? prefix : "", - prefix ? ": " : "", &vaf); + kern_level = KERN_WARNING; break; case 'e': - printk(KERN_ERR "%s%s%pV\n", prefix ? prefix : "", - prefix ? ": " : "", &vaf); + kern_level = KERN_ERR; break; default: - printk(KERN_NOTICE "%s%s%pV\n", prefix ? prefix : "", - prefix ? ": " : "", &vaf); + kern_level = KERN_NOTICE; break; } + printk("%s%s%s%pV\n", + kern_level, + prefix ? prefix : "", + prefix ? ": " : "", + &vaf); } else { unsigned int logsize = ARRAY_SIZE(log->buffer); u8 index; - char *q = kasprintf(GFP_KERNEL, "%c %s%s%pV\n", level, - prefix ? prefix : "", - prefix ? ": " : "", &vaf); + char *q = kasprintf(GFP_KERNEL, "%c %s%s%pV\n", + level, + prefix ? prefix : "", + prefix ? ": " : "", + &vaf); index = log->head & (logsize - 1); BUILD_BUG_ON(sizeof(log->head) != sizeof(u8) ||