From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in6.apple.com (mail-out6.apple.com [17.151.62.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6BF5B81F79 for ; Thu, 8 Dec 2016 15:11:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1481238674; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=uNsRxRufGS1ljFQrLIteAz4WlOwu2YurKQR9vYC9ldE=; b=Z0eSUatSHIkNheoufCvCXuLtqzpXNWcXVhgXrqosETxYNKC8IsQtxCi0tPikanDD /bboaHuRW/lJWhIPO9aXffn6N/RDxtOfLIU+T8M+D+lNL+uPQ5AH2sglH3HkIW2E EgXgfz3Ytq0kuxr1DOkb+JqVjKYWI7om7iuCPd8r4F03Tyt5owwO/ZgfsDgAqsjR oWIGWNHm/U6HGbyA4kTmWAXuDn87IGeKI9caFIZLIE9EEZHsGB6gOUffBKhPDR7V gfkHswfu5+nIBY20nDAFpUWKpSStlbM3N5AXZFbFTPyMC0MvDMcXXzfCbgBvOKiq P9kC15Gmor9tudNPXJNHeA==; Received: from relay6.apple.com (relay6.apple.com [17.128.113.90]) by mail-in6.apple.com (Apple Secure Mail Relay) with SMTP id 78.25.18170.198E9485; Thu, 8 Dec 2016 15:11:14 -0800 (PST) X-AuditID: 11973e15-459e39a0000046fa-12-5849e8912453 Received: from nwk-mmpp-sz07.apple.com (nwk-mmpp-sz07.apple.com [17.128.115.240]) by relay6.apple.com (Apple SCV relay) with SMTP id 09.F8.23613.198E9485; Thu, 8 Dec 2016 15:11:13 -0800 (PST) MIME-version: 1.0 Received: from [17.153.30.31] by nwk-mmpp-sz07.apple.com (Oracle Communications Messaging Server 8.0.1.1.0 64bit (built Jun 15 2016)) with ESMTPSA id <0OHW009RY32O2J10@nwk-mmpp-sz07.apple.com>; Thu, 08 Dec 2016 15:11:13 -0800 (PST) Sender: afish@apple.com From: Andrew Fish Message-id: Date: Thu, 08 Dec 2016 15:11:12 -0800 In-reply-to: Cc: Dandan Bi , "edk2-devel@lists.01.org" , Ruiyu Ni To: Kurt Kennett References: <1481194467-75920-1-git-send-email-dandan.bi@intel.com> <1481194467-75920-3-git-send-email-dandan.bi@intel.com> X-Mailer: Apple Mail (2.3226) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPLMWRmVeSWpSXmKPExsUi2FAYpTvphWeEwYJnTBZbt6lb7Dl0lNli 0nILi5c9q9kdWDwW73nJ5NE9+x+LR+uOv+wBzFFcNimpOZllqUX6dglcGU+vvGAr2DyBsWLh mkb2BsaPtV2MHBwSAiYSV17xdTFycQgJ7GWUmDevi62LkRMsvu3lRyaIxCFGicMLLjODJHgF BCV+TL7HAmIzC4RJnOyfxQhR9JZRYlLTcyaQhLCAuMS7M5vAGtgElCVWzP/ADtFsI7GjbSEL yGZhgTiJvmcqIGEWAVWJD7v+gc3kFIiXmN41kRlifrXE3jmX2EDKRQR0JTZ2GUOsusAo8eD3 JRaIB2QlZv/yAolLCDxmkzi+8xfbBEahWUhOnYXkVAhbS+L7o1agOAeQLS9x8LwsRFhT4tm9 T+wQtrbEk3cXWBcwsq1iFMpNzMzRzcwz00ssKMhJ1UvOz93ECIqR6XaiOxjPrLI6xCjAwajE w3ugwDNCiDWxrLgy9xCjNAeLkjhv2S6PCCGB9MSS1OzU1ILUovii0pzU4kOMTBycUg2Met/+ RKUnLVBKWfj18j0x0TcVz6/XByrsOSAbGyQ6fyFP5YSJOVN2cgj4hi19f53/S65Js29++I41 l2wOuUxnFvC7MbHT2ffAbLWA6aqM4glB3/d9aT6lfHTrshtrPb6cvWXjpe/4QWxLXmIyj96G 8CVlieetK2dFnH6ddsphekZtolkiT/gqJZbijERDLeai4kQAIscs0XICAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrGIsWRmVeSWpSXmKPExsUi2FD8QXfiC88Ig9u3TC22blO32HPoKLPF pOUWFi97VrM7sHgs3vOSyaN79j8Wj9Ydf9kDmKO4bFJSczLLUov07RK4Mp5eecFWsHkCY8XC NY3sDYwfa7sYOTkkBEwktr38yARhi0lcuLeerYuRi0NI4BCjxOEFl5lBErwCghI/Jt9jAbGZ BcIkTvbPYoQoessoManpOVi3sIC4xLszm8Aa2ASUJVbM/8AO0WwjsaNtIVAzB1BNnETfMxWQ MIuAqsSHXf/AZnIKxEtM75rIDDG/WmLvnEtsIOUiAroSG7uMIVZdYJR48PsS2BgJAVmJ2b+8 JjAKzEJy3Swk10HYWhLfH7UCxTmAbHmJg+dlIcKaEs/ufWKHsLUlnry7wLqAkW0Vo0BRak5i pZleYkFBTqpecn7uJkZwsBdG7WBsWG51iFGAg1GJh/dAgWeEEGtiWXFlLjCIOJiVRHgbngGF eFMSK6tSi/Lji0pzUosPMU5kBPpxIrOUaHI+MBbzSuINTUwMTIyNzYyNzU3MaSmsJM6btNAj QkggPbEkNTs1tSC1COYoJg5OqQZGtQMLZhct6FH0zio+arey+sYbU+7EHMa/CwXi//dNyrPo eK0W8qP/dLmsCU9Fw44HphVaKyRsnmp+3P6hZCZXJN9e+wNbOb9Vb9JXLbwpUdTRajMjgePM E94Kn4pXJ3vW2bYV51xZk7r3jMgjBh8L1wN+ZekpuxR9pm/w2dvuXpu3fb5OoIsSS3FGoqEW c1FxIgAriiPx6QIAAA== X-Content-Filtered-By: Mailman/MimeDel 2.1.21 Subject: Re: [patch 2/8] FatPkg\EnhancedFatDxe: Initialize variable after declaration X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Dec 2016 23:11:14 -0000 Content-Type: text/plain; CHARSET=US-ASCII Content-Transfer-Encoding: 7BIT > On Dec 8, 2016, at 9:27 AM, Kurt Kennett wrote: > > This seems kind of silly. > Why isn't this just const data? This adds code and memory accesses that are worthless and happen on every call to the function. > K2, I think this is an attempt to conform to the coding standard? I do agree it is pointless to make it static if you are going to initialize it every time. Seems like it would have been better to make this a global variable. Given that a static local variable is very much like a global that is limited in scope it may make sense to relax the coding standard in this regard (I did not re-read the coding standard so hopefully this is not a bad assumption), or just require pre-initialized local static variables to be globals? In this simple example you can see that a local static variable that is initialized ends up with code generation that is very close to a global variable. The name is not global and it is mangled with the function name. The other interesting tidbit is the compiler realized the static was const and marked it as such. ~/work/Compiler>cat static.c const unsigned char gMonthDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 131 }; int test (int i) { static unsigned char MonthDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; return MonthDays[i]; } ~/work/Compiler>clang -S -Os static.c ~/work/Compiler>cat static.S .section __TEXT,__text,regular,pure_instructions .globl _test _test: ## @test pushq %rbp movq %rsp, %rbp movslq %edi, %rax leaq _test.MonthDays(%rip), %rcx movzbl (%rax,%rcx), %eax popq %rbp retq .section __TEXT,__const .globl _gMonthDays ## @gMonthDays _gMonthDays: .ascii "\037\034\037\036\037\036\037\037\036\037\036\203" _test.MonthDays: ## @test.MonthDays .ascii "\037\034\037\036\037\036\037\037\036\037\036\037" Note: I had to make gMonthDays different than _test.MonthDays or _test.MonthDays gets optimized out. Thanks, Andrew Fish > K2 > > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Dandan Bi > Sent: Thursday, December 8, 2016 2:54 AM > To: edk2-devel@lists.01.org > Cc: Ruiyu Ni > Subject: [edk2] [patch 2/8] FatPkg\EnhancedFatDxe: Initialize variable after declaration > > Cc: Ruiyu Ni > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Dandan Bi > --- > FatPkg/EnhancedFatDxe/Misc.c | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/FatPkg/EnhancedFatDxe/Misc.c b/FatPkg/EnhancedFatDxe/Misc.c index f91759c..6ad688c 100644 > --- a/FatPkg/EnhancedFatDxe/Misc.c > +++ b/FatPkg/EnhancedFatDxe/Misc.c > @@ -696,15 +696,27 @@ Returns: > TRUE - The time is valid. > FALSE - The time is not valid. > > --*/ > { > - static UINT8 MonthDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; > + STATIC UINT8 MonthDays[12]; > UINTN Day; > BOOLEAN ValidTime; > > ValidTime = TRUE; > + MonthDays[0] = 31; > + MonthDays[1] = 28; > + MonthDays[2] = 31; > + MonthDays[3] = 30; > + MonthDays[4] = 31; > + MonthDays[5] = 30; > + MonthDays[6] = 31; > + MonthDays[7] = 31; > + MonthDays[8] = 30; > + MonthDays[9] = 31; > + MonthDays[10] = 30; > + MonthDays[11] = 31; > > // > // Check the fields for range problems > // Fat can only support from 1980 > // > -- > 1.9.5.msysgit.1 > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel