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=-8.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_SANE_1 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 5CC9EC433E7 for ; Tue, 13 Oct 2020 20:43:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D65720EDD for ; Tue, 13 Oct 2020 20:43:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727591AbgJMUnN (ORCPT ); Tue, 13 Oct 2020 16:43:13 -0400 Received: from mxout04.lancloud.ru ([89.108.124.63]:47504 "EHLO mxout04.lancloud.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727215AbgJMUnM (ORCPT ); Tue, 13 Oct 2020 16:43:12 -0400 Received: from LanCloud DKIM-Filter: OpenDKIM Filter v2.11.0 mxout04.lancloud.ru ADCE320275ED Received: from LanCloud Received: from LanCloud Received: from LanCloud Subject: [PATCH 1/2] module: merge repetitive strings in module_sig_check() From: Sergey Shtylyov To: Jessica Yu , References: <789a4e5c-8efd-bb1c-86e2-eed8b2b7b0af@omprussia.ru> Organization: Open Mobile Platform, LLC Message-ID: <4c4a3fa0-3eee-6cca-947c-9d01e3eb2a8a@omprussia.ru> Date: Tue, 13 Oct 2020 23:34:09 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: <789a4e5c-8efd-bb1c-86e2-eed8b2b7b0af@omprussia.ru> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [213.87.131.195] X-ClientProxiedBy: LFEXT01.lancloud.ru (fd00:f066::141) To LFEX1908.lancloud.ru (fd00:f066::208) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The 'reason' variable in module_sig_check() points to 3 strings across the *switch* statement, all needlessly starting with the same text. Let's put as much of the starting text as we can into the pr_notice() call (this includes some rewording of the 1st message) -- it saves 37 bytes of object code (x86 gcc 10.2.1). Signed-off-by: Sergey Shtylyov --- kernel/module.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) Index: linux/kernel/module.c =================================================================== --- linux.orig/kernel/module.c +++ linux/kernel/module.c @@ -2906,16 +2906,17 @@ static int module_sig_check(struct load_ * enforcing, certain errors are non-fatal. */ case -ENODATA: - reason = "Loading of unsigned module"; + reason = "no signature"; goto decide; case -ENOPKG: - reason = "Loading of module with unsupported crypto"; + reason = "unsupported crypto"; goto decide; case -ENOKEY: - reason = "Loading of module with unavailable key"; + reason = "unavailable key"; decide: if (is_module_sig_enforced()) { - pr_notice("%s: %s is rejected\n", info->name, reason); + pr_notice("%s: loading of module with %s is rejected\n", + info->name, reason); return -EKEYREJECTED; }