Re: [edk2-devel] [PATCH] edk II C Coding Standard: Remove section 5.4.2.2 STATIC

2022-11-25 Thread Chang, Abner via groups.io
[AMD Official Use Only - General]

Hi Ray and Mike,
Besides removing 5.4.2.2.1 and 5.4.2.2.2,  the "static" should be also removed 
from 5.6.1.2 section title.  I just went back to check the comment of BZ1766 
and yes we can add the recommendation of using static.  Just having it in 
5.4.2.2. 
Will send the patch update.
Thanks
Abner

> -Original Message-
> From: devel@edk2.groups.io  On Behalf Of Michael
> D Kinney via groups.io
> Sent: Wednesday, November 23, 2022 12:32 AM
> To: Chang, Abner ; Ni, Ray ;
> devel@edk2.groups.io; Gao, Liming 
> Subject: Re: [edk2-devel] [PATCH] edk II C Coding Standard: Remove section
> 5.4.2.2 STATIC
> 
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
> 
> 
> Hi Abner,
> 
> Removing that section 5.4.2.2 is required to close this bug.
> 
> Meaning of 'static' is covered by the ANSI C standards.
> 
> Use of 'static' for non-public variable/functions in EDK II libraries/modules 
> is
> recommended.
> 
> However, it is not required.  It is recommended to reduce chances of symbol
> conflicts at link time.  Current approach is if a link failure occurs for 
> multiply
> defined symbols and those are non-public symbols, the 'static' attribute can
> be applied to the non-public symbols in the components that generated the
> link failure.
> 
> It may be good to mention this recommendation in the CSS.
> 
> I will let you decide when this recommendation needs to be added to CSS.
> 
> Mike
> 
> > -Original Message-
> > From: Chang, Abner 
> > Sent: Monday, November 21, 2022 10:08 PM
> > To: Ni, Ray ; devel@edk2.groups.io; Kinney, Michael
> > D ; Gao, Liming
> 
> > Subject: RE: [edk2-devel] [PATCH] edk II C Coding Standard: Remove
> > section 5.4.2.2 STATIC
> >
> > [AMD Official Use Only - General]
> >
> > Hi Ray,
> > From the last week edk2 Bug triage meeting, my understanding from Mike
> > was to remove the entire 5.4.2.2 section and no need to add anything
> because we already mention at the beginning in CCS to follow C dialect.
> >
> > @Kinney, Michael D and @Liming Gao, is that correct?
> > Abner
> >
> > > -Original Message-
> > > From: Ni, Ray 
> > > Sent: Tuesday, November 22, 2022 1:48 PM
> > > To: devel@edk2.groups.io; Chang, Abner 
> > > Cc: Kinney, Michael D 
> > > Subject: RE: [edk2-devel] [PATCH] edk II C Coding Standard: Remove
> > > section
> > > 5.4.2.2 STATIC
> > >
> > > Caution: This message originated from an External Source. Use proper
> > > caution when opening attachments, clicking links, or responding.
> > >
> > >
> > > Abner,
> > > From what I read, the idea of BZ1766 is to add recommendations to
> > > use static for local symbols.
> > >
> > > "Add recommendations to the EDK II C Coding Standards Specification
> > > to use 'static' for all functions and global variables that are not
> > > referenced outside the current C file."
> > >
> > > Do you want to capture that in the EDKII C Coding Standard?
> > >
> > > Thanks,
> > > Ray
> > >
> > > > -Original Message-
> > > > From: devel@edk2.groups.io  On Behalf Of
> > > > Chang, Abner via groups.io
> > > > Sent: Tuesday, November 22, 2022 12:47 PM
> > > > To: devel@edk2.groups.io
> > > > Cc: Ni, Ray ; Kinney, Michael D
> > > > 
> > > > Subject: [edk2-devel] [PATCH] edk II C Coding Standard: Remove
> > > > section
> > > > 5.4.2.2 STATIC
> > > >
> > > > From: Abner Chang 
> > > >
> > > > BZ #1766
> > > >
> > > > Remove the entire 5.4.2.2 section.
> > > > We are not allowed to use upper-case STATIC in the source file now.
> > > > Just follow C standard and use the lower-case 'static'.
> > > >
> > > > Leave the macro "#deifne STATIC static" there without removing it
> > > > to keep the backward compatable.
> > > >
> > > > Signed-off-by: Abner Chang 
> > > > Cc: Ray Ni 
> > > > Cc: Michael D Kinney 
> > > > ---
> > > >  5_source_files/54_code_file_structure.md | 16 
> > > >  1 file changed, 16 deletions(-)
> > > >
> > > > diff --git a/5_source_files/54_code_file_structure.md
> > > > b/5_source_files/54_code_file_structure.md
> > > > index 0c4d6a2..9acc620 100644
> > > > --- a/5_source_files/54_code_file_structure.md
> > > > +++ b/5_source_files/54_code_file_structure.md
> > > > @@ -267,19 +267,3 @@ specified in Section 5.4.1.3 "Compile-Time
> Names".
> > > >  Thus, while it might be legal C, do **not** declare external
> > > > variables anywhere  other than at the top level of a file as
> > > > specified by this document.
> > > >
> > > > - 5.4.2.2 Static
> > > > -
> > > > -An object declared `STATIC` has either file or block scope.
> > > > -
> > > > -# 5.4.2.2.1 Do not reuse an object or function identifier
> > > > with static storage duration.
> > > > -
> > > > -Throughout the set of source files defined within a single .inf
> > > > file, do not -reuse an identifier with static storage duration.
> > > > The compiler may not be -confused by this, but the user may
> > > > confuse un

[edk2-devel] [edk2-platforms][PATCH V1 1/1] Silicon/ARM/NeoverseN1Soc: Update CCIX PNP ID

2022-11-25 Thread sahil
There is no need for a separate ID for CCIX host bridge,
therefore reusing PCIe PNP ID for CCIX.
Also, updating the file's license to resolve error during
ECC checks.

Signed-off-by: sahil 
---
 Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.c | 17 
+
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git 
a/Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.c 
b/Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.c
index 1f38f654a8ce..4c1acf154ca0 100644
--- a/Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.c
+++ b/Silicon/ARM/NeoverseN1Soc/Library/PciHostBridgeLib/PciHostBridgeLib.c
@@ -1,10 +1,11 @@
 /** @file
-*  PCI Host Bridge Library instance for ARM Neoverse N1 platform
-*
-*  Copyright (c) 2019 - 2022, ARM Limited. All rights reserved.
-*
-*  SPDX-License-Identifier: BSD-2-Clause-Patent
-*
+
+  PCI Host Bridge Library instance for ARM Neoverse N1 platform
+
+  Copyright (c) 2019 - 2022, ARM Limited. All rights reserved.
+
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
 **/
 
 #include 
@@ -65,8 +66,8 @@ STATIC EFI_PCI_ROOT_BRIDGE_DEVICE_PATH 
mEfiPciRootBridgeDevicePath[ROOT_COMPLEX_
   (UINT8)(sizeof (ACPI_HID_DEVICE_PATH) >> 8)
 }
   },
-  EISA_PNP_ID(0x0A09), // CCIX
-  0
+  EISA_PNP_ID(0x0A08), // CCIX
+  1
 },
 {
   END_DEVICE_PATH_TYPE,
-- 
2.25.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96628): https://edk2.groups.io/g/devel/message/96628
Mute This Topic: https://groups.io/mt/95259747/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




Re: [edk2-devel] [PATCH] Multiple Coverity issues were found from EDK2 ShellPkg

2022-11-25 Thread kalaivanip via groups.io
Please ignore this path. Sorry for the inconvenience, will send version 2 patch.


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96629): https://edk2.groups.io/g/devel/message/96629
Mute This Topic: https://groups.io/mt/95197753/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH EDK2 v1 1/1] CryptoPkg/BaseCryptLib:time overflow

2022-11-25 Thread wenyi,xie via groups.io
From: Zihong Yi 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4167

In CrtLibSupport.h, time_t is defined as INT32, and its maximum value
is 2147483647. That is, the corresponding maximum timestamp is
2038-01-19 11:14:07. Therefore, overflow occurs when the test time
exceeds 2038-01-19 11:14:07. So change the type of time_t to INT64 and
also change the type of variables in function gmtime which calculated
with time_t.

Cc: Jiewen Yao 
Cc: Jian J Wang 
Cc: Xiaoyu Lu 
Cc: Guomin Jiang 
Signed-off-by: Zihong Yi 
---
 CryptoPkg/Library/Include/CrtLibSupport.h |  2 +-
 CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c | 51 ++--
 2 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/CryptoPkg/Library/Include/CrtLibSupport.h 
b/CryptoPkg/Library/Include/CrtLibSupport.h
index 5072c343da57..94b0e6b6014f 100644
--- a/CryptoPkg/Library/Include/CrtLibSupport.h
+++ b/CryptoPkg/Library/Include/CrtLibSupport.h
@@ -109,7 +109,7 @@ typedef UINTN   off_t;
 typedef UINTN   u_int;
 typedef INTNptrdiff_t;
 typedef INTNssize_t;
-typedef INT32   time_t;
+typedef INT64   time_t;
 typedef UINT8   __uint8_t;
 typedef UINT8   sa_family_t;
 typedef UINT8   u_char;
diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c 
b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
index bf8a5325817f..3ed64375d0ff 100644
--- a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
+++ b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
@@ -15,7 +15,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 // -- Time Management Routines --
 //
 
-#define IsLeap(y)  (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
 #define SECSPERMIN   (60)
 #define SECSPERHOUR  (60 * 60)
 #define SECSPERDAY   (24 * SECSPERHOUR)
@@ -60,6 +59,26 @@ UINTN  CumulativeDays[2][14] = {
   }
 };
 
+/* Check the year is leap or not. */
+// BOOLEAN IsLeap(
+//  INTN timer
+//  )
+BOOLEAN
+IsLeap (
+  time_t  timer
+  )
+{
+  INT64  Remainder1;
+  INT64  Remainder2;
+  INT64  Remainder3;
+
+  DivS64x64Remainder (timer, 4, &Remainder1);
+  DivS64x64Remainder (timer, 100, &Remainder2);
+  DivS64x64Remainder (timer, 400, &Remainder3);
+
+  return (Remainder1 == 0 && (Remainder2 != 0 || Remainder3 == 0));
+}
+
 /* Get the system time as seconds elapsed since midnight, January 1, 1970. */
 // INTN time(
 //  INTN *timer
@@ -117,12 +136,13 @@ gmtime (
   )
 {
   struct tm  *GmTime;
-  UINT16 DayNo;
-  UINT32 DayRemainder;
+  UINT64 DayNo;
+  UINT64 DayRemainder;
   time_t Year;
   time_t YearNo;
-  UINT16 TotalDays;
-  UINT16 MonthNo;
+  UINT32 TotalDays;
+  UINT32 MonthNo;
+  INT64  Remainder;
 
   if (timer == NULL) {
 return NULL;
@@ -135,18 +155,21 @@ gmtime (
 
   ZeroMem ((VOID *)GmTime, (UINTN)sizeof (struct tm));
 
-  DayNo= (UINT16)(*timer / SECSPERDAY);
-  DayRemainder = (UINT32)(*timer % SECSPERDAY);
+  DayNo= (UINT64)DivS64x64Remainder (*timer, SECSPERDAY, &Remainder);
+  DayRemainder = (UINT64)Remainder;
 
-  GmTime->tm_sec  = (int)(DayRemainder % SECSPERMIN);
-  GmTime->tm_min  = (int)((DayRemainder % SECSPERHOUR) / SECSPERMIN);
-  GmTime->tm_hour = (int)(DayRemainder / SECSPERHOUR);
-  GmTime->tm_wday = (int)((DayNo + 4) % 7);
+  DivS64x64Remainder (DayRemainder, SECSPERMIN, &Remainder);
+  GmTime->tm_sec  = (int)Remainder;
+  DivS64x64Remainder (DayRemainder, SECSPERHOUR, &Remainder);
+  GmTime->tm_min  = (int)DivS64x64Remainder (Remainder, SECSPERMIN, NULL);
+  GmTime->tm_hour = (int)DivS64x64Remainder (DayRemainder, SECSPERHOUR, NULL);
+  DivS64x64Remainder ((DayNo + 4), 7, &Remainder);
+  GmTime->tm_wday = (int)Remainder;
 
   for (Year = 1970, YearNo = 0; DayNo > 0; Year++) {
-TotalDays = (UINT16)(IsLeap (Year) ? 366 : 365);
+TotalDays = (UINT32)(IsLeap (Year) ? 366 : 365);
 if (DayNo >= TotalDays) {
-  DayNo = (UINT16)(DayNo - TotalDays);
+  DayNo = (UINT64)(DayNo - TotalDays);
   YearNo++;
 } else {
   break;
@@ -158,7 +181,7 @@ gmtime (
 
   for (MonthNo = 12; MonthNo > 1; MonthNo--) {
 if (DayNo >= CumulativeDays[IsLeap (Year)][MonthNo]) {
-  DayNo = (UINT16)(DayNo - (UINT16)(CumulativeDays[IsLeap 
(Year)][MonthNo]));
+  DayNo = (UINT64)(DayNo - (UINT32)(CumulativeDays[IsLeap 
(Year)][MonthNo]));
   break;
 }
   }
-- 
2.20.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96625): https://edk2.groups.io/g/devel/message/96625
Mute This Topic: https://groups.io/mt/95251049/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-




[edk2-devel] [PATCH EDK2 v1 0/1] CryptoPkg/BaseCryptLib:time overflow

2022-11-25 Thread wenyi,xie via groups.io
Main Changes :
1.Change type of time_t to INT64.
2.Using function DivS64x64Remainder to deal with INT64 divide.

Zihong Yi (1):
  CryptoPkg/BaseCryptLib:time overflow

 CryptoPkg/Library/Include/CrtLibSupport.h |  2 +-
 CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c | 51 ++--
 2 files changed, 38 insertions(+), 15 deletions(-)

-- 
2.20.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#96626): https://edk2.groups.io/g/devel/message/96626
Mute This Topic: https://groups.io/mt/95251050/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-