.../PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
When the value type is defined as number in Redfish schema, floating
point number is allowed. RedfishCrtLib raises assert without handling
this case now. Follow the way in EDK2 to call AsciiStrDecimalToUintnS
and handle the floating point number.
Signed-off-by: Nickle Wang <nicklew@nvidia.com>
Cc: Abner Chang <abner.chang@amd.com>
Cc: Igor Kulchytskyy <igork@ami.com>
Cc: Nick Ramirez <nramirez@nvidia.com>
---
.../PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c b/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c
index 57a997f351..e88d874224 100644
--- a/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c
+++ b/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c
@@ -4,6 +4,7 @@
Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
+ Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -519,7 +520,7 @@ strtoull (
}
/**
- edk2 Jansson port does not support doubles, simply return 0.
+ edk2 Jansson port does not support doubles, simply return integer part.
These conversion functions convert the initial portion of the string
pointed to by nptr to double, float, and long double representation,
@@ -540,7 +541,7 @@ strtoull (
the return value), and ERANGE is stored in errno. If the correct value
would cause underflow, zero is returned and ERANGE is stored in errno.
- @return Return 0.
+ @return Integer part of decimal number.
**/
double
strtod (
@@ -548,9 +549,13 @@ strtod (
char **__restrict endptr
)
{
- DEBUG ((DEBUG_ERROR, "We don't supprot double type on edk2 yet!"));
- ASSERT (FALSE);
- return (double)0;
+ UINTN Data;
+
+ Data = 0;
+
+ AsciiStrDecimalToUintnS (nptr, endptr, &Data);
+ DEBUG ((DEBUG_WARN, "%a: We don't support double type on edk2 yet. Only integer part is returned\n", __func__));
+ return (double)Data;
}
static UINT8 BitMask[] = {
--
2.34.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#113708): https://edk2.groups.io/g/devel/message/113708
Mute This Topic: https://groups.io/mt/103680418/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
[AMD Official Use Only - General] Reviewed-by: Abner Chang <abner.chang@amd.com> > -----Original Message----- > From: Nickle Wang <nicklew@nvidia.com> > Sent: Friday, January 12, 2024 6:42 PM > To: devel@edk2.groups.io > Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy > <igork@ami.com>; Nick Ramirez <nramirez@nvidia.com> > Subject: [PATCH] RedfishPkg/RedfishCrtLib: handle floating point number in > JSON > > Caution: This message originated from an External Source. Use proper caution > when opening attachments, clicking links, or responding. > > > When the value type is defined as number in Redfish schema, floating > point number is allowed. RedfishCrtLib raises assert without handling > this case now. Follow the way in EDK2 to call AsciiStrDecimalToUintnS > and handle the floating point number. > > Signed-off-by: Nickle Wang <nicklew@nvidia.com> > Cc: Abner Chang <abner.chang@amd.com> > Cc: Igor Kulchytskyy <igork@ami.com> > Cc: Nick Ramirez <nramirez@nvidia.com> > --- > .../PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c > b/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c > index 57a997f351..e88d874224 100644 > --- a/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c > +++ b/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c > @@ -4,6 +4,7 @@ > > Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> > (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> > + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights > reserved. > > SPDX-License-Identifier: BSD-2-Clause-Patent > > @@ -519,7 +520,7 @@ strtoull ( > } > > /** > - edk2 Jansson port does not support doubles, simply return 0. > + edk2 Jansson port does not support doubles, simply return integer part. > > These conversion functions convert the initial portion of the string > pointed to by nptr to double, float, and long double representation, > @@ -540,7 +541,7 @@ strtoull ( > the return value), and ERANGE is stored in errno. If the correct value > would cause underflow, zero is returned and ERANGE is stored in errno. > > - @return Return 0. > + @return Integer part of decimal number. > **/ > double > strtod ( > @@ -548,9 +549,13 @@ strtod ( > char **__restrict endptr > ) > { > - DEBUG ((DEBUG_ERROR, "We don't supprot double type on edk2 yet!")); > - ASSERT (FALSE); > - return (double)0; > + UINTN Data; > + > + Data = 0; > + > + AsciiStrDecimalToUintnS (nptr, endptr, &Data); > + DEBUG ((DEBUG_WARN, "%a: We don't support double type on edk2 yet. > Only integer part is returned\n", __func__)); > + return (double)Data; > } > > static UINT8 BitMask[] = { > -- > 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113779): https://edk2.groups.io/g/devel/message/113779 Mute This Topic: https://groups.io/mt/103680418/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
Thanks Abner. I found an issue in this patch and resolved it in version 2 here: https://edk2.groups.io/g/devel/message/113780 Could you please help me to review it again? Regards, Nickle > -----Original Message----- > From: Chang, Abner <Abner.Chang@amd.com> > Sent: Saturday, January 13, 2024 10:19 PM > To: Nickle Wang <nicklew@nvidia.com>; devel@edk2.groups.io > Cc: Igor Kulchytskyy <igork@ami.com>; Nick Ramirez <nramirez@nvidia.com> > Subject: RE: [PATCH] RedfishPkg/RedfishCrtLib: handle floating point number in > JSON > > External email: Use caution opening links or attachments > > > [AMD Official Use Only - General] > > Reviewed-by: Abner Chang <abner.chang@amd.com> > > > -----Original Message----- > > From: Nickle Wang <nicklew@nvidia.com> > > Sent: Friday, January 12, 2024 6:42 PM > > To: devel@edk2.groups.io > > Cc: Chang, Abner <Abner.Chang@amd.com>; Igor Kulchytskyy > > <igork@ami.com>; Nick Ramirez <nramirez@nvidia.com> > > Subject: [PATCH] RedfishPkg/RedfishCrtLib: handle floating point > > number in JSON > > > > Caution: This message originated from an External Source. Use proper > > caution when opening attachments, clicking links, or responding. > > > > > > When the value type is defined as number in Redfish schema, floating > > point number is allowed. RedfishCrtLib raises assert without handling > > this case now. Follow the way in EDK2 to call AsciiStrDecimalToUintnS > > and handle the floating point number. > > > > Signed-off-by: Nickle Wang <nicklew@nvidia.com> > > Cc: Abner Chang <abner.chang@amd.com> > > Cc: Igor Kulchytskyy <igork@ami.com> > > Cc: Nick Ramirez <nramirez@nvidia.com> > > --- > > .../PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c | 15 > > ++++++++++----- > > 1 file changed, 10 insertions(+), 5 deletions(-) > > > > diff --git a/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c > > b/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c > > index 57a997f351..e88d874224 100644 > > --- a/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c > > +++ b/RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c > > @@ -4,6 +4,7 @@ > > > > Copyright (c) 2019, Intel Corporation. All rights reserved.<BR> > > (C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR> > > + Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights > > reserved. > > > > SPDX-License-Identifier: BSD-2-Clause-Patent > > > > @@ -519,7 +520,7 @@ strtoull ( > > } > > > > /** > > - edk2 Jansson port does not support doubles, simply return 0. > > + edk2 Jansson port does not support doubles, simply return integer part. > > > > These conversion functions convert the initial portion of the string > > pointed to by nptr to double, float, and long double > > representation, @@ -540,7 +541,7 @@ strtoull ( > > the return value), and ERANGE is stored in errno. If the correct value > > would cause underflow, zero is returned and ERANGE is stored in errno. > > > > - @return Return 0. > > + @return Integer part of decimal number. > > **/ > > double > > strtod ( > > @@ -548,9 +549,13 @@ strtod ( > > char **__restrict endptr > > ) > > { > > - DEBUG ((DEBUG_ERROR, "We don't supprot double type on edk2 yet!")); > > - ASSERT (FALSE); > > - return (double)0; > > + UINTN Data; > > + > > + Data = 0; > > + > > + AsciiStrDecimalToUintnS (nptr, endptr, &Data); DEBUG ((DEBUG_WARN, > > + "%a: We don't support double type on edk2 yet. > > Only integer part is returned\n", __func__)); > > + return (double)Data; > > } > > > > static UINT8 BitMask[] = { > > -- > > 2.34.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#113781): https://edk2.groups.io/g/devel/message/113781 Mute This Topic: https://groups.io/mt/103680418/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2024 Red Hat, Inc.