Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp258257ybj; Fri, 8 May 2020 11:05:58 -0700 (PDT) X-Google-Smtp-Source: APiQypJo6O9f9KCDwX18OKJdrjsRQiQHBh5DPj/8voETs9NVFNUUb1rZZt1qafEbvQXTbslcCxot X-Received: by 2002:a17:906:8282:: with SMTP id h2mr3101292ejx.250.1588961158253; Fri, 08 May 2020 11:05:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588961158; cv=none; d=google.com; s=arc-20160816; b=TTF0WSuZhlgMPHHI9RtUsWF2VS4NtLASfrBG/skJ3iH0y6ir/M5TWCPtwgIDH4TMq0 apheDJsypC3zmSHjmjmjBQvs7J54J+qppJ8FLgOzg135r6U6ToYVx0zlIJKntNl6Liyi YAZ9IhN0YjUvj+KXTvraJvJoJXBKJuJ0LVhP4UWkIrUOMt3Lm1y3GVWw5xNqG79xqsW2 006Sp0+ZcEYFrgeULa94JX78zmDe1JJ5gLKxLTIw4xU2722B/l5paYRxKa1QARgVOoV+ MSv/510C3EHuj2KjnfK8ZPjix1SW40JnVe72rKHuhvQOLSAjC/fnMo81y5X5/f/wDhKa u1qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=BF2EVhKg0EiPyZ5ICJuZYrEfRjJbmsOHAcSSZXiwNl0=; b=ZQaQbCRP3FXKm30RSCBnBhbEKqjnmXevh3CK8SLGMSL2/Pc9gjHavEv6++RMq9wmck PMlp/ff/0GoEStSKXE/NoGqnXEBNX/0VGUoNxDgZs6IiGsy3ragkgqS4v72U0bBAAMlq /QSSgZ1Y5UnlVyFDGq8jeVFEH2fQHGQboy61rZzVUP59twh7cdNVuxH0YQgyW03lhRvn p6s54HoJRQP5OdgzFuMWQmGRABDshogFEBVIsPdH3J4m0crD3LS+0RZuGTRxurNX3fHt GrRIx3t6r5GAPgZp7ChGpxO9GhOIk6rukH5kA6smr65TB8mBLvus2lgNmerLMRSZLtbf GJTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iE2XHwii; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si1252454edo.476.2020.05.08.11.05.28; Fri, 08 May 2020 11:05:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iE2XHwii; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728053AbgEHSDB (ORCPT + 99 others); Fri, 8 May 2020 14:03:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:48484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728060AbgEHSC6 (ORCPT ); Fri, 8 May 2020 14:02:58 -0400 Received: from e123331-lin.nice.arm.com (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr [109.210.65.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6B1EA2496C; Fri, 8 May 2020 18:02:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588960977; bh=tEtYwbHIEBSjoO7xCVKA06ixFT9BcUomNx/PjkEJSkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iE2XHwiiN0S1NlgE5Zh3bJZ/uiB8cyAAagP6nsVRwisCFyUJ2DT+gkNCCv8IKH5UN oIevzFmE1Vm2CBKXgiF9YIVQkDvDDqqJ1X/4KMjI1jts5xRPBkqSUUfV/wtE1N6iQc beQiHL1AuwHvoSRjxFOMQNyZd5th29cn97YOHnK0= From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-kernel@vger.kernel.org, Arnd Bergmann , Arvind Sankar , Guenter Roeck , Joe Perches Subject: [PATCH 14/15] efi/libstub: Make efi_printk() input argument const char* Date: Fri, 8 May 2020 20:01:56 +0200 Message-Id: <20200508180157.1816-15-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508180157.1816-1-ardb@kernel.org> References: <20200508180157.1816-1-ardb@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To help the compiler figure out that efi_printk() will not modify the string it is given, make the input argument type const char*. While at it, simplify the implementation as well. Suggested-by: Joe Perches Signed-off-by: Ard Biesheuvel --- .../firmware/efi/libstub/efi-stub-helper.c | 19 +++++++------------ drivers/firmware/efi/libstub/efistub.h | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index 7aac89e928ec..2927f3d30344 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -26,20 +26,15 @@ bool __pure __efi_soft_reserve_enabled(void) return !efi_nosoftreserve; } -void efi_printk(char *str) +void efi_printk(const char *str) { - char *s8; - - for (s8 = str; *s8; s8++) { - efi_char16_t ch[2] = { 0 }; - - ch[0] = *s8; - if (*s8 == '\n') { - efi_char16_t nl[2] = { '\r', 0 }; - efi_char16_printk(nl); - } + while (*str) { + efi_char16_t ch[] = { *str++, L'\0' }; - efi_char16_printk(ch); + if (ch[0] == L'\n') + efi_char16_printk(L"\r\n"); + else + efi_char16_printk(ch); } } diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h index 4f10a09563f3..15d0b6f3f6c6 100644 --- a/drivers/firmware/efi/libstub/efistub.h +++ b/drivers/firmware/efi/libstub/efistub.h @@ -625,7 +625,7 @@ efi_status_t check_platform_features(void); void *get_efi_config_table(efi_guid_t guid); -void efi_printk(char *str); +void efi_printk(const char *str); void efi_free(unsigned long size, unsigned long addr); -- 2.17.1