Reviewed-by: Ray Ni <[email protected]> -----Original Message----- From: Rehan, MohammedX <[email protected]> Sent: Thursday, February 10, 2022 2:51 PM To: [email protected]; Esakkithevar, Kathappan <[email protected]>; Gao, Zhichao <[email protected]>; Ni, Ray <[email protected]>; Pethaiyan, Madhan <[email protected]> Cc: Thirupugal, MadhaviX <[email protected]>; Rehan, MohammedX <[email protected]> Subject: [PATCH V2 1/1] ShellPkg: Fix Ping GetTimerPeriod API failure
[edk2-devel] [Patch V2 1/1] REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3819 Ping GetTimerPeriod API returns sometime zero value when StallCounter has smaller value than RttTimerTick (divide by zero) which results some failure at ping UEFI shell command Signed-off-by: MohammedX Rehan <[email protected]> Change-Id: I4458577c921b3748102da385d2f48a21680f5687 Signed-off-by: MohammedX Rehan <[email protected]> --- ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c index ec1e0a188b..6a002b15e5 100644 --- a/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c +++ b/ShellPkg/Library/UefiShellNetwork1CommandsLib/Ping.c @@ -259,9 +259,11 @@ GetTimerPeriod ( EFI_EVENT TimerEvent; UINT32 StallCounter; EFI_TPL OldTpl; + UINT32 TimerPeriod; RttTimerTick = 0; StallCounter = 0; + TimerPeriod = 0; Status = gBS->CreateEvent ( EVT_TIMER | EVT_NOTIFY_SIGNAL, @@ -295,7 +297,12 @@ GetTimerPeriod ( gBS->SetTimer (TimerEvent, TimerCancel, 0); gBS->CloseEvent (TimerEvent); - return StallCounter / RttTimerTick; + TimerPeriod = StallCounter / RttTimerTick; + if (TimerPeriod != 0) { + return TimerPeriod; + } else { + return 1; + } } /** -- 2.30.0.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#86609): https://edk2.groups.io/g/devel/message/86609 Mute This Topic: https://groups.io/mt/89041103/21656 Group Owner: [email protected] Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
