Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2207319ybb; Fri, 29 Mar 2019 22:42:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxysrYGzjYo3OTdOLEoJ/A9R5rHjUz1q4qI+ba1V9Co041XPyjo/+o8ihVe7+g36ra0oTYM X-Received: by 2002:a17:902:7c8a:: with SMTP id y10mr11748070pll.232.1553924573018; Fri, 29 Mar 2019 22:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553924573; cv=none; d=google.com; s=arc-20160816; b=Tw8t97W4vHt9lSwXMQUDfvW/x4zf2YbdkD23ThyONn+UFlYZO9+xUF4KunVf8YHDXq MmOa0hHeYpLSRY1yrdtlegjsWd1aWjFvu+/2lJJxUzKCxN1JVhcHxTOGuG5HEvhkaNdA kZysErimz3f8bwPXXyEIXmQ3z8RVqDqxgUIn10f2AM9y6pX1FcyxDpfkR2yQtDdtNWcJ O8hUPM+HybacfSn58V1n8zzwE9r/DKBhgTv7f4i8bx1AIOmhF7MTYMZpsIbbT1s4mXQU Z0nH9pFsMoXccnvwFT9wYXTcW0mo3o5jwvbSe6hhlwzyAPCXSMQW7cHnP3vxD3el/jtr M4ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=kj4wydnnA+dVjjrPYfND7M3T9eur2dIdn1Ir7Ff11Cs=; b=cKimgWWFwsZl0hZ0veSk0jbdJI3okRz7loqXT3XyXtz/5FWdSMM3iK1Jx9+9+iSUHL 9LqWlPYCq7cKBNyCQ+KyCvxdRon7H7lwtgXTfB681lUbt4JzxCaLQcNPvebUNvW5JLKR AxF6hAueTSYAafllE5IqRlqxQDUQTFtX+l/Bp9Js8fNypDA4nqEkStdd5ZWykW8HjNC0 P2vNk+9oBbTCHY0AvmkEmjFHnLZ+c9vr3nFRL9eGY5i/NwZwxDXAZ7ari4LBvl82g+xV 8w/Lqr+4znocOHf5yWWh2ASlV4lGWhKtz0z60L2tKpJ+HhgI67InhTP44zcVzk2oMfFy Wc0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i26si3667991pfd.140.2019.03.29.22.42.36; Fri, 29 Mar 2019 22:42:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730082AbfC3FmB (ORCPT + 99 others); Sat, 30 Mar 2019 01:42:01 -0400 Received: from smtp.nue.novell.com ([195.135.221.5]:49652 "EHLO smtp.nue.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726434AbfC3FmB (ORCPT ); Sat, 30 Mar 2019 01:42:01 -0400 Received: from emea4-mta.ukb.novell.com ([10.120.13.87]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Sat, 30 Mar 2019 06:41:59 +0100 Received: from linux-l9pv.suse (nwb-a10-snat.microfocus.com [10.120.13.201]) by emea4-mta.ukb.novell.com with ESMTP (TLS encrypted); Sat, 30 Mar 2019 05:41:28 +0000 Date: Sat, 30 Mar 2019 13:41:23 +0800 From: joeyli To: Mimi Zohar Cc: Ard Biesheuvel , "Lee, Chun-Yi" , James Morris , "Serge E . Hallyn" , David Howells , Josh Boyer , Nayna Jain , linux-efi , linux-security-module , Linux Kernel Mailing List , Kees Cook , Anton Vorontsov , Colin Cross , Tony Luck Subject: Re: [PATCH 1/2] efi: add a function for transferring status to string Message-ID: <20190330054123.GX26049@linux-l9pv.suse> References: <20190324002621.3551-1-jlee@suse.com> <1553713442.4608.20.camel@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1553713442.4608.20.camel@linux.ibm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mimi, On Wed, Mar 27, 2019 at 03:04:02PM -0400, Mimi Zohar wrote: > On Wed, 2019-03-27 at 19:58 +0100, Ard Biesheuvel wrote: > > On Sun, 24 Mar 2019 at 01:26, Lee, Chun-Yi wrote: > > > > > > This function can be used to transfer EFI status code to string > > > for printing out debug message. Using this function can improve > > > the readability of log. > > Maybe instead of "for transferring status" use "to convert the status > value to a" in the Subject line and here in the patch description. > Thanks for your suggestion. I will change subject and description. > > > > > > Cc: Ard Biesheuvel > > > Cc: Kees Cook > > > Cc: Anton Vorontsov > > > Cc: Colin Cross > > > Cc: Tony Luck > > > Signed-off-by: "Lee, Chun-Yi" > > > --- > > > include/linux/efi.h | 28 ++++++++++++++++++++++++++++ > > > 1 file changed, 28 insertions(+) > > > > > > diff --git a/include/linux/efi.h b/include/linux/efi.h > > > index 54357a258b35..a43cb0dc37af 100644 > > > --- a/include/linux/efi.h > > > +++ b/include/linux/efi.h > > > @@ -1768,4 +1768,32 @@ struct linux_efi_memreserve { > > > #define EFI_MEMRESERVE_COUNT(size) (((size) - sizeof(struct linux_efi_memreserve)) \ > > > / sizeof(((struct linux_efi_memreserve *)0)->entry[0])) > > > > > > +#define EFI_STATUS_STR(_status) \ > > > +case EFI_##_status: \ > > > + return "EFI_" __stringify(_status); > > > + > > > +static inline char * > > > +efi_status_to_str(efi_status_t status) > > > +{ > > > + switch (status) { > > > + EFI_STATUS_STR(SUCCESS) > > > + EFI_STATUS_STR(LOAD_ERROR) > > > + EFI_STATUS_STR(INVALID_PARAMETER) > > > + EFI_STATUS_STR(UNSUPPORTED) > > > + EFI_STATUS_STR(BAD_BUFFER_SIZE) > > > + EFI_STATUS_STR(BUFFER_TOO_SMALL) > > > + EFI_STATUS_STR(NOT_READY) > > > + EFI_STATUS_STR(DEVICE_ERROR) > > > + EFI_STATUS_STR(WRITE_PROTECTED) > > > + EFI_STATUS_STR(OUT_OF_RESOURCES) > > > + EFI_STATUS_STR(NOT_FOUND) > > > + EFI_STATUS_STR(ABORTED) > > > + EFI_STATUS_STR(SECURITY_VIOLATION) > > > + default: > > > + pr_warn("Unknown efi status: 0x%lx", status); > > > + } > > > + > > > + return "Unknown efi status"; > > > +} > > > + > > > #endif /* _LINUX_EFI_H */ > > > -- > > > 2.16.4 > > > > > > > Please turn this into a proper function so that not every calling > > object has to duplicate all these strings. > > Hi Ard, > > Keeping the status values and strings in sync is difficult. I was > going to suggest moving the macro immediately after the status value > definitions. > I will move the code to after the status value definitions. Thanks Joey Lee