Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp6981910yba; Thu, 2 May 2019 01:54:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqz2DnjGFqFitMjN3Gcua9KT1ubv0+784Ygy9sYDzPgYHbhOs0++R/maLHdKf8Tl5NU+M7eB X-Received: by 2002:a17:902:bd0c:: with SMTP id p12mr2539496pls.50.1556787293826; Thu, 02 May 2019 01:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556787293; cv=none; d=google.com; s=arc-20160816; b=MA5PDvn6CFCoY8hWZA3G/A0I9NKOW2U/09U1Hr17kr36YzDnSKz0w/cHKE8fpRjUdp Vh2SZ2rLvHrbb4TK6tJtmBv5WRNSuvkg9ir3JN5NbvPNqWmP+fCooG0WE7AQbrCFxJsY x9etPpRx7Hc3lZ7JFQsG7wrkVLUJDH+iI9ZLmHd8MEcdnu01ij+C7NFA01RLI/kkO2vT z7eOl8l03mmm3fhiHd1HkiVis19eG7/bbK43hvfIEeoB9ZCIf0X29yJlfHOLt1PvxLSH YDT4uEgytq27nqD5khYj/e3Ybq9+suQlYcyfSBO7JK43H51UNgSMHbDtMs9jYSNIn+zz BTsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=1X9ipyrjBCgysbixO7mllniKFp0zrqAX+YLVm+Qy1S0=; b=lJ269yL3wkWolt4Ul2vdSBlQWy7G25LQr64i+tvYG9r0C/dbH7FJir2WZ+k72sIwFb JKrkSVwZdG+mK0bRMRARMHEQMQn29EhxtY32Oh5OPAgjU1G72gOmLj/PsO4yJSyUhQ2A WvT3udt+/kS33fS0KI1pmGz+1j/61Mp4BOx2k1EFb5PPDW28OpgYyZh0h3c2L7lZSram lJCOGdeGvwisaN2GAQ+jkZs7FmerzvCJy6jMzwSyhy1oNTkbKRtDFhqedX4/a1VcTKjd sPgO3HjFKqWSEJiWi5NWrN+ZVH2UeFHsT8GccG4mXqFLqM2gR54bRU+9pqYZkdLv3vRS rXSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yWsXoM80; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d6si17965362pgk.129.2019.05.02.01.54.38; Thu, 02 May 2019 01:54:53 -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; dkim=pass header.i=@linaro.org header.s=google header.b=yWsXoM80; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726341AbfEBIxp (ORCPT + 99 others); Thu, 2 May 2019 04:53:45 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:38515 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbfEBIxo (ORCPT ); Thu, 2 May 2019 04:53:44 -0400 Received: by mail-it1-f194.google.com with SMTP id q19so2064770itk.3 for ; Thu, 02 May 2019 01:53:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1X9ipyrjBCgysbixO7mllniKFp0zrqAX+YLVm+Qy1S0=; b=yWsXoM80YUTgdMB6oO2DDbeU8DPDbcmA+PC+5sSaToOqaTpIKARGyOV/boF39l6Q1e 0aVuAgi17sn11G4czZdsXIIJkkaqL5RwBNxp2WmHWGQ0do7X2cYx5WD9ZEZgo4pNA4eM jQeldBHxndo5h2SYoCG+q9P+M52Zgdto9W0VS1nmNRxaq9lQxMuYeHsQMqJOD1PiJBJL ZbHxxKVWhhaxPoCfu7IaDYqyN9xb9KuFVUCbvvm5JUBTMgU9qJ+Cy7s2nVCb+dPkiDWV FNdrFBiSFR1EnoD5PIjaMUH7Ka1MQhnuK2F3cSwxw0wBXszsZbDKh7ybJR69Ihjcb57D zysw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1X9ipyrjBCgysbixO7mllniKFp0zrqAX+YLVm+Qy1S0=; b=THlZ50L+mHFV1bN/Xntfw6nhuzE4xheuQxmUEv/7lHU4yR1zbJLqc8hkdgAr0eqBhc J1rIEYGbvs1Cnos5qry6G3mxF0+yv3+ERnyY1DtyWGWtFO5PhefLmA2sNSxJDEu1beRN YHLHFLm7Cm0OJgYh0eamo0dvKBfh1XzkNZ+5/V2EeQBNWIQBpPQqtHaQY54dL8egFQs7 5SPgIdNEKzom+PEd81SRbRpCE3zC56smYR5Mc7zic3cmKJfomX+9Qj99geKg3fO6IQzo kqrOqOSeSdewWtfnSlwfvn2/cHvkigzuIX9yMf/sA/b/GQKscNUlqmbFk3uEsySrJMfs quDQ== X-Gm-Message-State: APjAAAXMrZI6ENXSL5fjMJHXYQiVBbuv10bZGnzcxq94m9+6HQcyCJo8 YoJCQ93crkCLuin+3X64tP4w33imSGUUt8ZQaw25XQ== X-Received: by 2002:a24:b342:: with SMTP id z2mr1327414iti.121.1556787223814; Thu, 02 May 2019 01:53:43 -0700 (PDT) MIME-Version: 1.0 References: <20190502040441.30372-1-jlee@suse.com> In-Reply-To: <20190502040441.30372-1-jlee@suse.com> From: Ard Biesheuvel Date: Thu, 2 May 2019 10:53:31 +0200 Message-ID: Subject: Re: [PATCH 1/2 v2] efi: add a function to convert the status value to string To: "Lee, Chun-Yi" Cc: James Morris , "Serge E . Hallyn" , David Howells , Josh Boyer , Nayna Jain , Mimi Zohar , linux-efi , linux-security-module , Linux Kernel Mailing List , "Lee, Chun-Yi" , Kees Cook , Anton Vorontsov , Colin Cross , Tony Luck Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2 May 2019 at 06:04, Lee, Chun-Yi wrote: > > This function can be used to convert EFI status value to string > for printing out debug message. Using this function can improve > the readability of log. > > v2. Please move the changelog out of the commit log (move it below the --- further down) > - Changed the wording in subject and description. > - Moved the marco immediately after the status value definitions. > - Turned into a proper function instead of inline. > You missed my point here. A proper function means the function in a .c file, and only the declaration in a .h file. This way, you are still duplicating the literal strings into every object file that references this function. > 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..6f3f89a32eef 100644 > --- a/include/linux/efi.h > +++ b/include/linux/efi.h > @@ -42,6 +42,34 @@ > #define EFI_ABORTED (21 | (1UL << (BITS_PER_LONG-1))) > #define EFI_SECURITY_VIOLATION (26 | (1UL << (BITS_PER_LONG-1))) > > +#define EFI_STATUS_STR(_status) \ > +case EFI_##_status: \ > + return "EFI_" __stringify(_status); > + > +static __attribute__((unused)) char * > +efi_status_to_str(unsigned long 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"; > +} > + > typedef unsigned long efi_status_t; > typedef u8 efi_bool_t; > typedef u16 efi_char16_t; /* UNICODE character */ > -- > 2.16.4 >