From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0709.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe42::709]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 6D43C81FBC for ; Thu, 8 Dec 2016 16:40:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=524vaVWHHlJ5e5pJ014TxJ03EbcXRjTT7kEmot8VigA=; b=jgrIOzSzT0xQ33T5ICJe3n+DZsHG+DUbHqnNq0MHw9m4dgIhwaDtyLTDTXIi0LgtCGo4gepWSfqjbXN0rTQVm2FfwA7BL7lAz6CiQj1WurC3YZiMap58sd1pt9wSTr3a0f3EPBIndWYzg6Mf0yAQvHeh/kMvkRR2TW6U9lKZUEA= Received: from SN2PR03MB2351.namprd03.prod.outlook.com (10.166.210.142) by SN2PR03MB2349.namprd03.prod.outlook.com (10.166.210.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.761.9; Fri, 9 Dec 2016 00:40:24 +0000 Received: from SN2PR03MB2351.namprd03.prod.outlook.com ([10.166.210.142]) by SN2PR03MB2351.namprd03.prod.outlook.com ([10.166.210.142]) with mapi id 15.01.0761.018; Fri, 9 Dec 2016 00:40:24 +0000 From: Kurt Kennett To: "afish@apple.com" CC: "Yao, Jiewen" , "Bi, Dandan" , "edk2-devel@lists.01.org" , "Ni, Ruiyu" Thread-Topic: [edk2] [patch 2/8] FatPkg\EnhancedFatDxe: Initialize variable after declaration Thread-Index: AQHSUUGEv7dYXu5p+0mZLsjiSWUaf6D+TfQwgABqC0CAAArK4IAAA2eAgAAArGA= Date: Fri, 9 Dec 2016 00:40:24 +0000 Message-ID: References: <1481194467-75920-1-git-send-email-dandan.bi@intel.com> <1481194467-75920-3-git-send-email-dandan.bi@intel.com> <74D8A39837DF1E4DA445A8C0B3885C50386F23F1@SHSMSX104.ccr.corp.intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Kurt.Kennett@microsoft.com; x-originating-ip: [2001:4898:80e8:6::2e6] x-ms-office365-filtering-correlation-id: 8ae71b34-f6c9-4ad9-2f9c-08d41fcbf6de x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:SN2PR03MB2349; x-microsoft-exchange-diagnostics: 1; SN2PR03MB2349; 7:3gw6POu5m1n0/sQ/zWUKCT1YhnSgLl0TFS+DH8mxYJmYRGF3HdpueLiPpHNBXX2g875E5mlLpOCt4gACW9H6IC8xBAACtsgrx6tXlmngvJlHHjx6zwJKF6VQs/RH/LV+OShQXJRwtr2CD1JWNi/pktA2SKVib+9w7pkGyWfbQHLvaUk5hR8Y3HR6cSIhWWXQnsANHdjmh67a6v1AK3QFcUxmaLypqXv4PPhY+xnjqhfZbEqlqvvh0m44OoKpY+NcV8wcCi32/ERtR3e22v76ayD6qMoLkTkxYqm4wn6UelqmXNQGZ7BZGrxynOCFgmWUNLaqOnbZj92NtBFjgaDqZd9bbt+VjSvOcmNJGez2BfEzoGK2F+8RPjdB9v9HrE4f2QLINSHKW3p75eqZOGz6G0DnvKRDquNyz5u+4lKbSTc35xWlvmEaocbSYHUqKlkYQS0LOUyBOK/Kch28DY7CD9BuBIibr+mfDrMqzRAD2xQ= x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(162533806227266)(31960201722614)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(61425038)(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026)(61426038)(61427038)(6041248)(20161123564025)(20161123562025)(20161123555025)(20161123560025)(6072148)(6047074); SRVR:SN2PR03MB2349; BCL:0; PCL:0; RULEID:; SRVR:SN2PR03MB2349; x-forefront-prvs: 015114592F x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(7916002)(39850400002)(39860400002)(39450400003)(39410400002)(39840400002)(189002)(377454003)(13464003)(24454002)(199003)(69234005)(101416001)(7736002)(5005710100001)(76176999)(50986999)(54356999)(7696004)(38730400001)(93886004)(3660700001)(2906002)(68736007)(8676002)(74316002)(97736004)(5640700002)(229853002)(9686002)(8936002)(81156014)(110136003)(10290500002)(5660300001)(10090500001)(1730700003)(6916009)(8990500004)(6506006)(8666005)(77096006)(81166006)(2950100002)(305945005)(2501003)(106116001)(2900100001)(99286002)(189998001)(105586002)(122556002)(106356001)(4326007)(2351001)(102836003)(6116002)(92566002)(76576001)(3280700002)(86362001)(33656002)(86612001)(6436002)(7059030); DIR:OUT; SFP:1102; SCL:1; SRVR:SN2PR03MB2349; H:SN2PR03MB2351.namprd03.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Dec 2016 00:40:24.4178 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR03MB2349 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: Fri, 09 Dec 2016 00:40:26 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Yes. When I said "read-protect" I mean "protect by making it read-only". = I should have said "read-only protect" or "write-protect". K2 -----Original Message----- From: afish@apple.com [mailto:afish@apple.com]=20 Sent: Thursday, December 8, 2016 4:37 PM To: Kurt Kennett Cc: Yao, Jiewen ; Bi, Dandan ; e= dk2-devel@lists.01.org; Ni, Ruiyu Subject: Re: [edk2] [patch 2/8] FatPkg\EnhancedFatDxe: Initialize variable = after declaration > On Dec 8, 2016, at 4:26 PM, Kurt Kennett wro= te: >=20 > Is the data 'variable'? i.e does it ever change? >=20 > 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 lo= ad. >=20 K2, Did you mean write-protoect?=20 FYI in my example in this thread from a macOS clang compiler the constant d= ate ends up in a const TEXT section, as the text section in general is cons= t. That is why the compiler emitted a PC relative access. This only ever be= comes an issue when hand writing assemble code for X64.=20 Thanks, Andrew Fish=20 > K2 >=20 > -----Original Message----- > From: Yao, Jiewen [mailto:jiewen.yao@intel.com] > Sent: Thursday, December 8, 2016 3:47 PM > To: Kurt Kennett ; Bi, Dandan=20 > ; edk2-devel@lists.01.org > Cc: Ni, Ruiyu > Subject: RE: [edk2] [patch 2/8] FatPkg\EnhancedFatDxe: Initialize=20 > variable after declaration >=20 > Agree. Maybe we can move it to be a global variable ? >=20 > Thank you > Yao Jiewen >=20 >> -----Original Message----- >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf=20 >> Of Kurt Kennett >> Sent: Friday, December 9, 2016 1:28 AM >> To: Bi, Dandan ; edk2-devel@lists.01.org >> Cc: Ni, Ruiyu >> Subject: Re: [edk2] [patch 2/8] FatPkg\EnhancedFatDxe: Initialize=20 >> variable after declaration >>=20 >> This seems kind of silly. >> Why isn't this just const data? This adds code and memory accesses=20 >> that are worthless and happen on every call to the function. >>=20 >> K2 >>=20 >> -----Original Message----- >> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf=20 >> 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=20 >> variable after declaration >>=20 >> 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(-) >>=20 >> diff --git a/FatPkg/EnhancedFatDxe/Misc.c=20 >> 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. >>=20 >> --*/ >> { >> - static UINT8 MonthDays[] =3D { 31, 28, 31, 30, 31, 30, 31, 31, 30,=20 >> 31, 30, 31 }; >> + STATIC UINT8 MonthDays[12]; >> UINTN Day; >> BOOLEAN ValidTime; >>=20 >> ValidTime =3D TRUE; >> + MonthDays[0] =3D 31; >> + MonthDays[1] =3D 28; >> + MonthDays[2] =3D 31; >> + MonthDays[3] =3D 30; >> + MonthDays[4] =3D 31; >> + MonthDays[5] =3D 30; >> + MonthDays[6] =3D 31; >> + MonthDays[7] =3D 31; >> + MonthDays[8] =3D 30; >> + MonthDays[9] =3D 31; >> + MonthDays[10] =3D 30; >> + MonthDays[11] =3D 31; >>=20 >> // >> // Check the fields for range problems >> // Fat can only support from 1980 >> // >> -- >> 1.9.5.msysgit.1 >>=20 >> _______________________________________________ >> 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 > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel