public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Yao, Jiewen" <jiewen.yao@intel.com>
To: "afish@apple.com" <afish@apple.com>,
	Kurt Kennett <Kurt.Kennett@microsoft.com>
Cc: "Bi, Dandan" <dandan.bi@intel.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>,
	"Ni, Ruiyu" <ruiyu.ni@intel.com>
Subject: Re: [patch 2/8] FatPkg\EnhancedFatDxe: Initialize variable after declaration
Date: Fri, 9 Dec 2016 00:40:18 +0000	[thread overview]
Message-ID: <74D8A39837DF1E4DA445A8C0B3885C50386F44DD@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <D1BD0C11-ED02-479E-894F-91A90BDD564B@apple.com>

Hi
I found it is using "STATIC" not "CONST".

Does a compiler put "STATIC" data to READ-ONLY section?

Thank you
Yao Jiewen

From: afish@apple.com [mailto:afish@apple.com]
Sent: Friday, December 9, 2016 8:37 AM
To: Kurt Kennett <Kurt.Kennett@microsoft.com>
Cc: Yao, Jiewen <jiewen.yao@intel.com>; Bi, Dandan <dandan.bi@intel.com>; edk2-devel@lists.01.org; Ni, Ruiyu <ruiyu.ni@intel.com>
Subject: Re: [edk2] [patch 2/8] FatPkg\EnhancedFatDxe: Initialize variable after declaration


> On Dec 8, 2016, at 4:26 PM, Kurt Kennett <Kurt.Kennett@microsoft.com<mailto:Kurt.Kennett@microsoft.com>> wrote:
>
> Is the data 'variable'?  i.e does it ever change?
>
> A normal compiler should put this data into a section marked read-only if it is marked as const, and a loader could read-protect the region after load.
>

K2,

Did you mean write-protoect?

FYI in my example in this thread from a macOS clang compiler the constant date ends up in a const TEXT section, as the text section in general is const. That is why the compiler emitted a PC relative access. This only ever becomes an issue when hand writing assemble code for X64.

Thanks,

Andrew Fish

> K2
>
> -----Original Message-----
> From: Yao, Jiewen [mailto:jiewen.yao@intel.com]
> Sent: Thursday, December 8, 2016 3:47 PM
> To: Kurt Kennett <Kurt.Kennett@microsoft.com<mailto:Kurt.Kennett@microsoft.com>>; Bi, Dandan <dandan.bi@intel.com<mailto:dandan.bi@intel.com>>; edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> Cc: Ni, Ruiyu <ruiyu.ni@intel.com<mailto:ruiyu.ni@intel.com>>
> Subject: RE: [edk2] [patch 2/8] FatPkg\EnhancedFatDxe: Initialize variable after declaration
>
> Agree. Maybe we can move it to be a global variable ?
>
> Thank you
> Yao Jiewen
>
>> -----Original Message-----
>> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>> Kurt Kennett
>> Sent: Friday, December 9, 2016 1:28 AM
>> To: Bi, Dandan <dandan.bi@intel.com<mailto:dandan.bi@intel.com>>; edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
>> Cc: Ni, Ruiyu <ruiyu.ni@intel.com<mailto:ruiyu.ni@intel.com>>
>> Subject: Re: [edk2] [patch 2/8] FatPkg\EnhancedFatDxe: Initialize
>> variable after declaration
>>
>> 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
>>
>> -----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<mailto:edk2-devel@lists.01.org>
>> Cc: Ruiyu Ni <ruiyu.ni@intel.com<mailto:ruiyu.ni@intel.com>>
>> Subject: [edk2] [patch 2/8] FatPkg\EnhancedFatDxe: Initialize variable
>> after declaration
>>
>> Cc: Ruiyu Ni <ruiyu.ni@intel.com<mailto:ruiyu.ni@intel.com>>
>> Contributed-under: TianoCore Contribution Agreement 1.0
>> Signed-off-by: Dandan Bi <dandan.bi@intel.com<mailto:dandan.bi@intel.com>>
>> ---
>> 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<mailto:edk2-devel@lists.01.org>
>> https://lists.01.org/mailman/listinfo/edk2-devel
>> _______________________________________________
>> edk2-devel mailing list
>> edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
>> https://lists.01.org/mailman/listinfo/edk2-devel
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org<mailto:edk2-devel@lists.01.org>
> https://lists.01.org/mailman/listinfo/edk2-devel


  reply	other threads:[~2016-12-09  0:40 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-08 10:54 [patch 0/8] FatPkg: Fix coding style issues Dandan Bi
2016-12-08 10:54 ` [patch 1/8] FatPkg\EnhancedFatDxe: Avoid Non-Boolean type uses as Boolean Dandan Bi
2016-12-09  1:14   ` Ni, Ruiyu
2016-12-08 10:54 ` [patch 2/8] FatPkg\EnhancedFatDxe: Initialize variable after declaration Dandan Bi
2016-12-08 17:27   ` Kurt Kennett
2016-12-08 23:11     ` Andrew Fish
2016-12-20 23:26       ` Brian J. Johnson
2016-12-08 23:47     ` Yao, Jiewen
2016-12-09  0:26       ` Kurt Kennett
2016-12-09  0:36         ` Andrew Fish
2016-12-09  0:40           ` Yao, Jiewen [this message]
2016-12-09 16:32             ` Kurt Kennett
2016-12-09  0:40           ` Kurt Kennett
2016-12-09  0:57   ` Ni, Ruiyu
2016-12-09  1:18     ` Bi, Dandan
2016-12-08 10:54 ` [patch 3/8] FatPkg\EnhancedFatDxe: Make function prototype align with definition Dandan Bi
2016-12-09  1:13   ` Ni, Ruiyu
2016-12-08 10:54 ` [patch 4/8] FatPkg\EnhancedFatDxe: Make the variable name follow rule Dandan Bi
2016-12-09  1:12   ` Ni, Ruiyu
2016-12-08 10:54 ` [patch 5/8] FatPkg\EnhancedFatDxe: Use typedef for complex type Dandan Bi
2016-12-09  1:11   ` Ni, Ruiyu
2016-12-08 10:54 ` [patch 6/8] FatPkg\EnhancedFatDxe: Make the comments align with EDKII coding style Dandan Bi
2016-12-09  1:10   ` Ni, Ruiyu
2016-12-08 10:54 ` [patch 7/8] FatPkg\EnhancedFatDxe: Add comments for functions Dandan Bi
2016-12-09  1:10   ` Ni, Ruiyu
2016-12-08 10:54 ` [patch 8/8] FatPkg: Fix format issues in dec/inf/dsc files Dandan Bi
2016-12-09  1:09   ` Ni, Ruiyu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=74D8A39837DF1E4DA445A8C0B3885C50386F44DD@SHSMSX104.ccr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox