]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
efi/libstub: Make efi_printk() input argument const char*
authorArd Biesheuvel <ardb@kernel.org>
Tue, 5 May 2020 08:27:18 +0000 (10:27 +0200)
committerArd Biesheuvel <ardb@kernel.org>
Tue, 5 May 2020 08:27:18 +0000 (10:27 +0200)
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 <joe@perches.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
drivers/firmware/efi/libstub/efi-stub-helper.c
drivers/firmware/efi/libstub/efistub.h

index 7aac89e928ec5adb3bbf25f542554f5846cd3b41..2927f3d30344e78b5b4b4dde22fcc20101f6d065 100644 (file)
@@ -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);
        }
 }
 
index 4f10a09563f36887d38a202b17b04a7b0e21b4bc..15d0b6f3f6c6d92d957bb826ba0f5926bafa1b55 100644 (file)
@@ -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);