On 07/10/13 09:19, Gary Ching-Pang Lin wrote:
> Per gmtime manpage, tm_mon is the number of months since January
> while MonthNo is the month of the year, so tm_mon should be MonthNo-1.
>
> Similarly, tm_mday is the day of the month, and DayNo is the number
> of days since the first day of the month. Assigning DayNo+1 to tm_mday
> to fit the definition.
>
> This commit also corrected miscalculated MonthNo and DayNo for the last
> day of the month. (Thanks to Laszlo Ersek!)
("first day", but the message can be fixed up at commit time)
>
> Contributed-under: TianoCore Contribution Agreement 1.0
> Signed-off-by: Gary Ching-Pang Lin <[email protected]>
> ---
> CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
> b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
> index 805e6b4..6422d61 100644
> --- a/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
> +++ b/CryptoPkg/Library/BaseCryptLib/SysCall/TimerWrapper.c
> @@ -148,14 +148,14 @@ struct tm * gmtime (const time_t *timer)
> GmTime->tm_yday = (int) DayNo;
>
> for (MonthNo = 12; MonthNo > 1; MonthNo--) {
> - if (DayNo > CumulativeDays[IsLeap(Year)][MonthNo]) {
> + if (DayNo >= CumulativeDays[IsLeap(Year)][MonthNo]) {
> DayNo = (UINT16) (DayNo - (UINT16)
> (CumulativeDays[IsLeap(Year)][MonthNo]));
> break;
> }
> }
>
> - GmTime->tm_mon = (int) MonthNo;
> - GmTime->tm_mday = (int) DayNo;
> + GmTime->tm_mon = (int) MonthNo - 1;
> + GmTime->tm_mday = (int) DayNo + 1;
>
> GmTime->tm_isdst = 0;
> GmTime->tm_gmtoff = 0;
>
Reviewed-by: Laszlo Ersek <[email protected]>
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel