Browse Source

RedfishPkg: Apply uncrustify changes

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

Apply uncrustify changes to .c/.h files in the RedfishPkg package

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Abner Chang <abner.chang@hpe.com>
Michael Kubacki 2 years ago
parent
commit
39de741e2d
56 changed files with 5435 additions and 4086 deletions
  1. 46 47
      RedfishPkg/Include/IndustryStandard/RedfishHostInterface.h
  2. 8 8
      RedfishPkg/Include/Library/BaseUcs2Utf8Lib.h
  3. 96 93
      RedfishPkg/Include/Library/JsonLib.h
  4. 12 10
      RedfishPkg/Include/Library/RedfishContentCodingLib.h
  5. 8 6
      RedfishPkg/Include/Library/RedfishCredentialLib.h
  6. 413 115
      RedfishPkg/Include/Library/RedfishCrtLib.h
  7. 8 5
      RedfishPkg/Include/Library/RedfishHostInterfaceLib.h
  8. 5 5
      RedfishPkg/Include/Library/RestExLib.h
  9. 3 3
      RedfishPkg/Include/Pcd/RestExServiceDevicePath.h
  10. 14 15
      RedfishPkg/Include/Protocol/EdkIIRedfishConfigHandler.h
  11. 5 6
      RedfishPkg/Include/Protocol/EdkIIRedfishCredential.h
  12. 62 79
      RedfishPkg/Library/BaseUcs2Utf8Lib/BaseUcs2Utf8Lib.c
  13. 66 58
      RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c
  14. 116 113
      RedfishPkg/Library/JsonLib/JsonLib.c
  15. 5 5
      RedfishPkg/Library/JsonLib/jansson_config.h
  16. 3 3
      RedfishPkg/Library/JsonLib/jansson_private_config.h
  17. 1161 849
      RedfishPkg/Library/JsonLib/load.c
  18. 6 6
      RedfishPkg/Library/PlatformCredentialLibNull/PlatformCredentialLibNull.c
  19. 6 5
      RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c
  20. 10 10
      RedfishPkg/Library/RedfishContentCodingLibNull/RedfishContentCodingLibNull.c
  21. 1 0
      RedfishPkg/PrivateInclude/Crt/stdarg.h
  22. 1 0
      RedfishPkg/PrivateInclude/Crt/stdio.h
  23. 1 0
      RedfishPkg/PrivateInclude/Crt/sys/time.h
  24. 1 0
      RedfishPkg/PrivateInclude/Crt/sys/types.h
  25. 1 0
      RedfishPkg/PrivateInclude/Crt/time.h
  26. 70 65
      RedfishPkg/PrivateInclude/Library/RedfishLib.h
  27. 345 186
      RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c
  28. 191 151
      RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c
  29. 38 33
      RedfishPkg/PrivateLibrary/RedfishLib/RedfishMisc.c
  30. 8 8
      RedfishPkg/PrivateLibrary/RedfishLib/RedfishMisc.h
  31. 1 0
      RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfish.h
  32. 79 12
      RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfishPayload.h
  33. 90 40
      RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfishService.h
  34. 20 13
      RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redpath.h
  35. 666 586
      RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c
  36. 188 156
      RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/redpath.c
  37. 410 311
      RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c
  38. 48 40
      RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerCommon.c
  39. 6 6
      RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerCommon.h
  40. 94 80
      RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c
  41. 9 8
      RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.h
  42. 11 11
      RedfishPkg/RedfishCredentialDxe/RedfishCredentialDxe.c
  43. 8 6
      RedfishPkg/RedfishCredentialDxe/RedfishCredentialDxe.h
  44. 14 14
      RedfishPkg/RedfishDiscoverDxe/ComponentName.c
  45. 332 265
      RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c
  46. 67 67
      RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h
  47. 26 24
      RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c
  48. 67 49
      RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c
  49. 14 13
      RedfishPkg/RedfishRestExDxe/ComponentName.c
  50. 71 74
      RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.c
  51. 57 58
      RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h
  52. 40 33
      RedfishPkg/RedfishRestExDxe/RedfishRestExImpl.c
  53. 34 34
      RedfishPkg/RedfishRestExDxe/RedfishRestExInternal.h
  54. 121 100
      RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c
  55. 246 196
      RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.c
  56. 6 6
      RedfishPkg/RestJsonStructureDxe/RestJsonStructureInternal.h

+ 46 - 47
RedfishPkg/Include/IndustryStandard/RedfishHostInterface.h

@@ -12,72 +12,72 @@
 
 
 #include <IndustryStandard/SmBios.h>
 #include <IndustryStandard/SmBios.h>
 
 
-#define REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB         0x02 // We don't support this type of interface.
+#define REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB  0x02        // We don't support this type of interface.
                                                             // Use REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2 instead.
                                                             // Use REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2 instead.
-#define REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE    0x03 // We don't support this type of interface.
+#define REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE  0x03   // We don't support this type of interface.
                                                             // Use REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2 instead.
                                                             // Use REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2 instead.
-#define REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2      0x04
-#define REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2 0x05
+#define REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2       0x04
+#define REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2  0x05
 
 
-#define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_UNKNOWN            0x00
-#define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_STATIC             0x01
-#define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_DHCP               0x02
-#define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_AUTO_CONFIGURE     0x03
-#define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_HOST_SELECTED      0x04
+#define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_UNKNOWN         0x00
+#define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_STATIC          0x01
+#define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_DHCP            0x02
+#define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_AUTO_CONFIGURE  0x03
+#define REDFISH_HOST_INTERFACE_HOST_IP_ASSIGNMENT_TYPE_HOST_SELECTED   0x04
 
 
-#define REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN      0x00
-#define REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4          0x01
-#define REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6          0x02
+#define REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_UNKNOWN  0x00
+#define REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP4      0x01
+#define REDFISH_HOST_INTERFACE_HOST_IP_ADDRESS_FORMAT_IP6      0x02
 
 
 #pragma pack(1)
 #pragma pack(1)
 ///
 ///
 /// Structure definitions of Host Interface device type 04h (USB Network Interface V2)
 /// Structure definitions of Host Interface device type 04h (USB Network Interface V2)
 ///
 ///
 typedef struct {
 typedef struct {
-  UINT8                   Length;          ///< Length of the structure, including Device Type
+  UINT8     Length;                        ///< Length of the structure, including Device Type
                                            ///< and Length fields.
                                            ///< and Length fields.
-  UINT16                  IdVendor;        ///< The Vendor ID of the device, as read from the
+  UINT16    IdVendor;                      ///< The Vendor ID of the device, as read from the
                                            ///< idVendor field of the USB descriptor.
                                            ///< idVendor field of the USB descriptor.
-  UINT16                  IdProduct;       ///< The Product ID of the device, as read from the
+  UINT16    IdProduct;                     ///< The Product ID of the device, as read from the
                                            ///< idProduct field of the USB descriptor.
                                            ///< idProduct field of the USB descriptor.
-  UINT8                   SecialNumberStr; ///< The string number for the Serial Number of the
+  UINT8     SecialNumberStr;               ///< The string number for the Serial Number of the
                                            ///< device. The string data is read from the
                                            ///< device. The string data is read from the
                                            ///< iSerialNumber.bDescriptorType field of the USB
                                            ///< iSerialNumber.bDescriptorType field of the USB
                                            ///< descriptor, and is converted from Unicode to ASCII
                                            ///< descriptor, and is converted from Unicode to ASCII
                                            ///< and is NULL terminated.
                                            ///< and is NULL terminated.
-  UINT8                   MacAddress [6];  ///< The MAC address of the PCI/PCIe network device.
+  UINT8     MacAddress[6];                 ///< The MAC address of the PCI/PCIe network device.
 } USB_INTERFACE_DEVICE_DESCRIPTOR_V2;
 } USB_INTERFACE_DEVICE_DESCRIPTOR_V2;
 
 
 //
 //
 // Structure definitions of Host Interface device type 05h (PCI/PCIE V2)
 // Structure definitions of Host Interface device type 05h (PCI/PCIE V2)
 //
 //
 typedef struct {
 typedef struct {
-  UINT8                   Length;               ///< Length of the structure, including Device Type and Length fields.
-  UINT16                  VendorId;             ///< The Vendor ID of the PCI/PCIe device.
-  UINT16                  DeviceId;             ///< The Device ID of the PCI/PCIe device.
-  UINT16                  SubsystemVendorId;    ///< The Subsystem Vendor ID of the PCI/PCIe device.
-  UINT16                  SubsystemId;          ///< The Subsystem ID of the PCI/PCIe device.
-  UINT8                   MacAddress [6];       ///< The MAC address of the PCI/PCIe network device.
-  UINT16                  SegmemtGroupNumber;   ///< The Segment Group Number of the PCI/PCIe.
-  UINT8                   BusNumber;            ///< The Bus Number of the PCI/PCIe device.
-  UINT8                   DeviceFunctionNumber; ///< The Device/Function Number of the PCI/PCIe.
+  UINT8     Length;                             ///< Length of the structure, including Device Type and Length fields.
+  UINT16    VendorId;                           ///< The Vendor ID of the PCI/PCIe device.
+  UINT16    DeviceId;                           ///< The Device ID of the PCI/PCIe device.
+  UINT16    SubsystemVendorId;                  ///< The Subsystem Vendor ID of the PCI/PCIe device.
+  UINT16    SubsystemId;                        ///< The Subsystem ID of the PCI/PCIe device.
+  UINT8     MacAddress[6];                      ///< The MAC address of the PCI/PCIe network device.
+  UINT16    SegmemtGroupNumber;                 ///< The Segment Group Number of the PCI/PCIe.
+  UINT8     BusNumber;                          ///< The Bus Number of the PCI/PCIe device.
+  UINT8     DeviceFunctionNumber;               ///< The Device/Function Number of the PCI/PCIe.
 } PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2;
 } PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2;
 
 
 ///
 ///
 /// Structure definitions of Host Interface device type 80-FFh (OEM)
 /// Structure definitions of Host Interface device type 80-FFh (OEM)
 ///
 ///
 typedef struct {
 typedef struct {
-  UINT32                  VendorIana;          ///< The IANA code for the vendor (MSB first).
-  UINT8                   OemDefinedData[1];   ///< OEM defined data.
+  UINT32    VendorIana;                        ///< The IANA code for the vendor (MSB first).
+  UINT8     OemDefinedData[1];                 ///< OEM defined data.
 } OEM_DEVICE_DESCRIPTOR;
 } OEM_DEVICE_DESCRIPTOR;
 
 
 ///
 ///
 /// Define union for the Host Interface Device Descriptor
 /// Define union for the Host Interface Device Descriptor
 ///
 ///
 typedef union {
 typedef union {
-    USB_INTERFACE_DEVICE_DESCRIPTOR_V2          UsbDeviceV2;     ///< Device type USB V2 device discriptor.
-    PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2  PciPcieDeviceV2; ///< Device type PCI/PCIe V2 device discriptor.
-    OEM_DEVICE_DESCRIPTOR                       OemDevice;       ///< OEM type device discriptor.
+  USB_INTERFACE_DEVICE_DESCRIPTOR_V2            UsbDeviceV2;     ///< Device type USB V2 device discriptor.
+  PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2    PciPcieDeviceV2; ///< Device type PCI/PCIe V2 device discriptor.
+  OEM_DEVICE_DESCRIPTOR                         OemDevice;       ///< OEM type device discriptor.
 } DEVICE_DESCRITOR; /// Device descriptor data formated based on Device Type.
 } DEVICE_DESCRITOR; /// Device descriptor data formated based on Device Type.
 
 
 ///
 ///
@@ -87,15 +87,15 @@ typedef union {
 ///  specific Tape 42 table.
 ///  specific Tape 42 table.
 ///
 ///
 typedef struct {
 typedef struct {
-  UINT8            DeviceType;        ///< The Device Type of the interface.
-  DEVICE_DESCRITOR DeviceDescriptor;  ///< The Device descriptor.
+  UINT8               DeviceType;       ///< The Device Type of the interface.
+  DEVICE_DESCRITOR    DeviceDescriptor; ///< The Device descriptor.
 } REDFISH_INTERFACE_DATA;
 } REDFISH_INTERFACE_DATA;
 
 
 //
 //
 //  the protocol-specific data for the "Redfish Over IP" protocol
 //  the protocol-specific data for the "Redfish Over IP" protocol
 //
 //
 typedef struct {
 typedef struct {
-  EFI_GUID            ServiceUuid;  //same as Redfish Service UUID in Redfish Service Root resource
+  EFI_GUID    ServiceUuid;          // same as Redfish Service UUID in Redfish Service Root resource
 
 
   //
   //
   //  Unknown=00h,
   //  Unknown=00h,
@@ -105,7 +105,7 @@ typedef struct {
   //  HostSelected=04h,
   //  HostSelected=04h,
   //  other values reserved
   //  other values reserved
   //
   //
-  UINT8               HostIpAssignmentType;
+  UINT8    HostIpAssignmentType;
 
 
   //
   //
   //  Unknown=00h,
   //  Unknown=00h,
@@ -113,19 +113,19 @@ typedef struct {
   //  Ipv6=02h,
   //  Ipv6=02h,
   //  other values reserved
   //  other values reserved
   //
   //
-  UINT8               HostIpAddressFormat;
+  UINT8    HostIpAddressFormat;
 
 
   //
   //
   //  Used for Static and AutoConfigure.
   //  Used for Static and AutoConfigure.
   //  For IPV4, use the first 4 Bytes and zero fill the remaining bytes.
   //  For IPV4, use the first 4 Bytes and zero fill the remaining bytes.
   //
   //
-  UINT8               HostIpAddress[16];
+  UINT8    HostIpAddress[16];
 
 
   //
   //
   //  Used for Static and AutoConfigure.
   //  Used for Static and AutoConfigure.
   //  For IPV4, use the first 4 Bytes and zero fill the remaining bytes.
   //  For IPV4, use the first 4 Bytes and zero fill the remaining bytes.
   //
   //
-  UINT8               HostIpMask[16];
+  UINT8    HostIpMask[16];
 
 
   //
   //
   //  Unknown=00h,
   //  Unknown=00h,
@@ -135,7 +135,7 @@ typedef struct {
   //  HostSelected=04h,
   //  HostSelected=04h,
   //  other values reserved
   //  other values reserved
   //
   //
-  UINT8               RedfishServiceIpDiscoveryType;
+  UINT8     RedfishServiceIpDiscoveryType;
 
 
   //
   //
   //  Unknown=00h,
   //  Unknown=00h,
@@ -143,27 +143,26 @@ typedef struct {
   //  Ipv6=02h,
   //  Ipv6=02h,
   //  other values reserved
   //  other values reserved
   //
   //
-  UINT8               RedfishServiceIpAddressFormat;
+  UINT8     RedfishServiceIpAddressFormat;
 
 
   //
   //
   //  Used for Static and AutoConfigure.
   //  Used for Static and AutoConfigure.
   //  For IPV4, use the first 4 Bytes and zero fill the remaining bytes.
   //  For IPV4, use the first 4 Bytes and zero fill the remaining bytes.
   //
   //
-  UINT8               RedfishServiceIpAddress[16];
+  UINT8     RedfishServiceIpAddress[16];
 
 
   //
   //
   //  Used for Static and AutoConfigure.
   //  Used for Static and AutoConfigure.
   //  For IPV4, use the first 4 Bytes and zero fill the remaining bytes.
   //  For IPV4, use the first 4 Bytes and zero fill the remaining bytes.
   //
   //
-  UINT8               RedfishServiceIpMask[16];
+  UINT8     RedfishServiceIpMask[16];
 
 
-  UINT16              RedfishServiceIpPort;  // Used for Static and AutoConfigure.
-  UINT32              RedfishServiceVlanId;  // Used for Static and AutoConfigure.
-  UINT8               RedfishServiceHostnameLength;   // length of the following hostname string
-  UINT8               RedfishServiceHostname[1];  // hostname of Redfish Service
+  UINT16    RedfishServiceIpPort;            // Used for Static and AutoConfigure.
+  UINT32    RedfishServiceVlanId;            // Used for Static and AutoConfigure.
+  UINT8     RedfishServiceHostnameLength;    // length of the following hostname string
+  UINT8     RedfishServiceHostname[1];       // hostname of Redfish Service
 } REDFISH_OVER_IP_PROTOCOL_DATA;
 } REDFISH_OVER_IP_PROTOCOL_DATA;
 
 
 #pragma pack()
 #pragma pack()
 
 
 #endif
 #endif
-

+ 8 - 8
RedfishPkg/Include/Library/BaseUcs2Utf8Lib.h

@@ -14,11 +14,11 @@
 ///
 ///
 ///  L"\u0000"
 ///  L"\u0000"
 ///
 ///
-#define UNICODE_FORMAT_LEN         6
-#define UNICODE_FORMAT_CHAR_LEN    2
-#define UNICODE_FORMAT_CHAR_SIZE   3
+#define UNICODE_FORMAT_LEN        6
+#define UNICODE_FORMAT_CHAR_LEN   2
+#define UNICODE_FORMAT_CHAR_SIZE  3
 
 
-#define UTF8_BUFFER_FOR_UCS2_MAX_SIZE   3
+#define UTF8_BUFFER_FOR_UCS2_MAX_SIZE  3
 
 
 /**
 /**
   Convert a UCS2 string to a UTF8 encoded string.
   Convert a UCS2 string to a UTF8 encoded string.
@@ -34,8 +34,8 @@
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 UCS2StrToUTF8 (
 UCS2StrToUTF8 (
-  IN  CHAR16     *Ucs2Str,
-  OUT CHAR8      **Utf8StrAddr
+  IN  CHAR16  *Ucs2Str,
+  OUT CHAR8   **Utf8StrAddr
   );
   );
 
 
 /**
 /**
@@ -54,8 +54,8 @@ UCS2StrToUTF8 (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 UTF8StrToUCS2 (
 UTF8StrToUCS2 (
-  IN  CHAR8      *Utf8Str,
-  OUT CHAR16     **Ucs2StrAddr
+  IN  CHAR8   *Utf8Str,
+  OUT CHAR16  **Ucs2StrAddr
   );
   );
 
 
 #endif
 #endif

+ 96 - 93
RedfishPkg/Include/Library/JsonLib.h

@@ -7,17 +7,18 @@
     SPDX-License-Identifier: BSD-2-Clause-Patent
     SPDX-License-Identifier: BSD-2-Clause-Patent
 
 
 **/
 **/
+
 #ifndef JSON_LIB_H_
 #ifndef JSON_LIB_H_
 #define JSON_LIB_H_
 #define JSON_LIB_H_
 
 
-typedef    VOID*    EDKII_JSON_VALUE;
-typedef    VOID*    EDKII_JSON_ARRAY;
-typedef    VOID*    EDKII_JSON_OBJECT;
+typedef    VOID  *EDKII_JSON_VALUE;
+typedef    VOID  *EDKII_JSON_ARRAY;
+typedef    VOID  *EDKII_JSON_OBJECT;
 
 
 ///
 ///
 /// Map to json_int_t in jansson.h
 /// Map to json_int_t in jansson.h
 ///
 ///
-typedef    INT64   EDKII_JSON_INT_T; // #JSON_INTEGER_IS_LONG_LONG is set to 1
+typedef    INT64 EDKII_JSON_INT_T;   // #JSON_INTEGER_IS_LONG_LONG is set to 1
                                      // in jansson_Config.h
                                      // in jansson_Config.h
 
 
 ///
 ///
@@ -25,28 +26,28 @@ typedef    INT64   EDKII_JSON_INT_T; // #JSON_INTEGER_IS_LONG_LONG is set to 1
 /// See below URI for the JSON encoding flags reference.
 /// See below URI for the JSON encoding flags reference.
 /// https://jansson.readthedocs.io/en/2.13/apiref.html#encoding
 /// https://jansson.readthedocs.io/en/2.13/apiref.html#encoding
 ///
 ///
-#define EDKII_JSON_MAX_INDENT        0x1F
-#define EDKII_JSON_INDENT(n)         ((n) & EDKII_JSON_MAX_INDENT)
-
-#define EDKII_JSON_COMPACT           0x20
-#define EDKII_JSON_ENSURE_ASCII      0x40
-#define EDKII_JSON_SORT_KEYS         0x80
-#define EDKII_JSON_PRESERVE_ORDER    0x100
-#define EDKII_JSON_ENCODE_ANY        0x200
-#define EDKII_JSON_ESCAPE_SLASH      0x400
-#define EDKII_JSON_REAL_PRECISION(n) (((n) & 0x1F) << 11)
-#define EDKII_JSON_EMBED             0x10000
+#define EDKII_JSON_MAX_INDENT  0x1F
+#define EDKII_JSON_INDENT(n)  ((n) & EDKII_JSON_MAX_INDENT)
+
+#define EDKII_JSON_COMPACT         0x20
+#define EDKII_JSON_ENSURE_ASCII    0x40
+#define EDKII_JSON_SORT_KEYS       0x80
+#define EDKII_JSON_PRESERVE_ORDER  0x100
+#define EDKII_JSON_ENCODE_ANY      0x200
+#define EDKII_JSON_ESCAPE_SLASH    0x400
+#define EDKII_JSON_REAL_PRECISION(n)  (((n) & 0x1F) << 11)
+#define EDKII_JSON_EMBED  0x10000
 
 
 ///
 ///
 /// Map to the definitions in jansson.h
 /// Map to the definitions in jansson.h
 /// See below URI for the JSON decoding flags reference.
 /// See below URI for the JSON decoding flags reference.
 /// https://jansson.readthedocs.io/en/2.13/apiref.html?highlight=json_loadb#decoding
 /// https://jansson.readthedocs.io/en/2.13/apiref.html?highlight=json_loadb#decoding
 ///
 ///
-#define EDKII_JSON_REJECT_DUPLICATES  0x1
-#define EDKII_JSON_DISABLE_EOF_CHECK  0x2
-#define EDKII_JSON_DECODE_ANY         0x4
-#define EDKII_JSON_DECODE_INT_AS_REAL 0x8
-#define EDKII_JSON_ALLOW_NUL          0x10
+#define EDKII_JSON_REJECT_DUPLICATES   0x1
+#define EDKII_JSON_DISABLE_EOF_CHECK   0x2
+#define EDKII_JSON_DECODE_ANY          0x4
+#define EDKII_JSON_DECODE_INT_AS_REAL  0x8
+#define EDKII_JSON_ALLOW_NUL           0x10
 
 
 #define EDKII_JSON_ARRAY_FOREACH(Array, Index, Value) \
 #define EDKII_JSON_ARRAY_FOREACH(Array, Index, Value) \
   for(Index = 0; \
   for(Index = 0; \
@@ -63,28 +64,28 @@ typedef    INT64   EDKII_JSON_INT_T; // #JSON_INTEGER_IS_LONG_LONG is set to 1
 ///
 ///
 ///  Map to the json_error_t in jansson.h
 ///  Map to the json_error_t in jansson.h
 ///
 ///
-#define EDKII_JSON_ERROR_TEXT_LENGTH   160
-#define EDKII_JSON_ERROR_SOURCE_LENGTH 80
+#define EDKII_JSON_ERROR_TEXT_LENGTH    160
+#define EDKII_JSON_ERROR_SOURCE_LENGTH  80
 typedef struct {
 typedef struct {
-    INTN    Line;
-    INTN    Column;
-    INTN    Position;
-    CHAR8   Source [EDKII_JSON_ERROR_SOURCE_LENGTH];
-    CHAR8   Text [EDKII_JSON_ERROR_TEXT_LENGTH];
+  INTN     Line;
+  INTN     Column;
+  INTN     Position;
+  CHAR8    Source[EDKII_JSON_ERROR_SOURCE_LENGTH];
+  CHAR8    Text[EDKII_JSON_ERROR_TEXT_LENGTH];
 } EDKII_JSON_ERROR;
 } EDKII_JSON_ERROR;
 
 
 ///
 ///
 ///  Map to the json_type in jansson.h
 ///  Map to the json_type in jansson.h
 ///
 ///
 typedef enum {
 typedef enum {
-    EdkiiJsonTypeObject,
-    EdkiiJsonTypeArray,
-    EdkiiJsonTypeString,
-    EdkiiJsonTypeInteger,
-    EdkiiJsonTypeReal,
-    EdkiiJsonTypeTrue,
-    EdkiiJsonTypeFalse,
-    EdkiiJsonTypeNull
+  EdkiiJsonTypeObject,
+  EdkiiJsonTypeArray,
+  EdkiiJsonTypeString,
+  EdkiiJsonTypeInteger,
+  EdkiiJsonTypeReal,
+  EdkiiJsonTypeTrue,
+  EdkiiJsonTypeFalse,
+  EdkiiJsonTypeNull
 } EDKII_JSON_TYPE;
 } EDKII_JSON_TYPE;
 
 
 /**
 /**
@@ -147,7 +148,7 @@ JsonValueInitObject (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonValueInitAsciiString (
 JsonValueInitAsciiString (
-  IN    CONST CHAR8    *String
+  IN    CONST CHAR8  *String
   );
   );
 
 
 /**
 /**
@@ -170,7 +171,7 @@ JsonValueInitAsciiString (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonValueInitUnicodeString (
 JsonValueInitUnicodeString (
-  IN    CHAR16    *String
+  IN    CHAR16  *String
   );
   );
 
 
 /**
 /**
@@ -190,7 +191,7 @@ JsonValueInitUnicodeString (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonValueInitInteger (
 JsonValueInitInteger (
-  IN    INT64    Value
+  IN    INT64  Value
   );
   );
 
 
 /**
 /**
@@ -207,7 +208,7 @@ JsonValueInitInteger (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonValueInitBoolean (
 JsonValueInitBoolean (
-  IN    BOOLEAN    Value
+  IN    BOOLEAN  Value
   );
   );
 
 
 /**
 /**
@@ -278,7 +279,7 @@ JsonValueInitFalse (
 VOID
 VOID
 EFIAPI
 EFIAPI
 JsonValueFree (
 JsonValueFree (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -301,7 +302,7 @@ JsonValueFree (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonValueClone (
 JsonValueClone (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -316,7 +317,7 @@ JsonValueClone (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsArray (
 JsonValueIsArray (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -331,7 +332,7 @@ JsonValueIsArray (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsObject (
 JsonValueIsObject (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -347,7 +348,7 @@ JsonValueIsObject (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsString (
 JsonValueIsString (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -362,7 +363,7 @@ JsonValueIsString (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsInteger (
 JsonValueIsInteger (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -377,7 +378,7 @@ JsonValueIsInteger (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsNumber (
 JsonValueIsNumber (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -392,7 +393,7 @@ JsonValueIsNumber (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsBoolean (
 JsonValueIsBoolean (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -407,7 +408,7 @@ JsonValueIsBoolean (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsTrue (
 JsonValueIsTrue (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -422,7 +423,7 @@ JsonValueIsTrue (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsFalse (
 JsonValueIsFalse (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -437,7 +438,7 @@ JsonValueIsFalse (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsNull (
 JsonValueIsNull (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -453,7 +454,7 @@ JsonValueIsNull (
 EDKII_JSON_ARRAY
 EDKII_JSON_ARRAY
 EFIAPI
 EFIAPI
 JsonValueGetArray (
 JsonValueGetArray (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -469,7 +470,7 @@ JsonValueGetArray (
 EDKII_JSON_OBJECT
 EDKII_JSON_OBJECT
 EFIAPI
 EFIAPI
 JsonValueGetObject (
 JsonValueGetObject (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -485,7 +486,7 @@ JsonValueGetObject (
 CONST CHAR8 *
 CONST CHAR8 *
 EFIAPI
 EFIAPI
 JsonValueGetAsciiString (
 JsonValueGetAsciiString (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -499,10 +500,10 @@ JsonValueGetAsciiString (
   @retval      Return the associated Unicode string in JSON value or NULL.
   @retval      Return the associated Unicode string in JSON value or NULL.
 
 
 **/
 **/
-CHAR16*
+CHAR16 *
 EFIAPI
 EFIAPI
 JsonValueGetUnicodeString (
 JsonValueGetUnicodeString (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -519,7 +520,7 @@ JsonValueGetUnicodeString (
 INT64
 INT64
 EFIAPI
 EFIAPI
 JsonValueGetInteger (
 JsonValueGetInteger (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -536,7 +537,7 @@ JsonValueGetInteger (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueGetBoolean (
 JsonValueGetBoolean (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -549,10 +550,10 @@ JsonValueGetBoolean (
   @retval      Return the associated Ascii string in JSON value or NULL on errors.
   @retval      Return the associated Ascii string in JSON value or NULL on errors.
 
 
 **/
 **/
-CONST CHAR8*
+CONST CHAR8 *
 EFIAPI
 EFIAPI
 JsonValueGetString (
 JsonValueGetString (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -567,7 +568,7 @@ JsonValueGetString (
 UINTN
 UINTN
 EFIAPI
 EFIAPI
 JsonObjectSize (
 JsonObjectSize (
-  IN    EDKII_JSON_OBJECT    JsonObject
+  IN    EDKII_JSON_OBJECT  JsonObject
   );
   );
 
 
 /**
 /**
@@ -583,10 +584,10 @@ JsonObjectSize (
                JsonObj is not an JSON object, key count is zero or on other errors.
                JsonObj is not an JSON object, key count is zero or on other errors.
 
 
 **/
 **/
-CHAR8**
+CHAR8 **
 JsonObjectGetKeys (
 JsonObjectGetKeys (
-  IN    EDKII_JSON_OBJECT    JsonObj,
-  OUT   UINTN                *KeyCount
+  IN    EDKII_JSON_OBJECT  JsonObj,
+  OUT   UINTN              *KeyCount
   );
   );
 
 
 /**
 /**
@@ -608,8 +609,8 @@ JsonObjectGetKeys (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonObjectGetValue (
 JsonObjectGetValue (
-  IN    CONST EDKII_JSON_OBJECT    JsonObj,
-  IN    CONST CHAR8                *Key
+  IN    CONST EDKII_JSON_OBJECT  JsonObj,
+  IN    CONST CHAR8              *Key
   );
   );
 
 
 /**
 /**
@@ -633,9 +634,9 @@ JsonObjectGetValue (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 JsonObjectSetValue (
 JsonObjectSetValue (
-  IN    EDKII_JSON_OBJECT    JsonObj,
-  IN    CONST CHAR8          *Key,
-  IN    EDKII_JSON_VALUE     Json
+  IN    EDKII_JSON_OBJECT  JsonObj,
+  IN    CONST CHAR8        *Key,
+  IN    EDKII_JSON_VALUE   Json
   );
   );
 
 
 /**
 /**
@@ -650,7 +651,7 @@ JsonObjectSetValue (
 UINTN
 UINTN
 EFIAPI
 EFIAPI
 JsonArrayCount (
 JsonArrayCount (
-  IN    EDKII_JSON_ARRAY    JsonArray
+  IN    EDKII_JSON_ARRAY  JsonArray
   );
   );
 
 
 /**
 /**
@@ -672,8 +673,8 @@ JsonArrayCount (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonArrayGetValue (
 JsonArrayGetValue (
-  IN    EDKII_JSON_ARRAY    JsonArray,
-  IN    UINTN               Index
+  IN    EDKII_JSON_ARRAY  JsonArray,
+  IN    UINTN             Index
   );
   );
 
 
 /**
 /**
@@ -692,8 +693,8 @@ JsonArrayGetValue (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 JsonArrayAppendValue (
 JsonArrayAppendValue (
-  IN    EDKII_JSON_ARRAY    JsonArray,
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_ARRAY  JsonArray,
+  IN    EDKII_JSON_VALUE  Json
   );
   );
 
 
 /**
 /**
@@ -713,8 +714,8 @@ JsonArrayAppendValue (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 JsonArrayRemoveValue (
 JsonArrayRemoveValue (
-  IN    EDKII_JSON_ARRAY    JsonArray,
-  IN    UINTN               Index
+  IN    EDKII_JSON_ARRAY  JsonArray,
+  IN    UINTN             Index
   );
   );
 
 
 /**
 /**
@@ -742,8 +743,8 @@ JsonArrayRemoveValue (
 CHAR8 *
 CHAR8 *
 EFIAPI
 EFIAPI
 JsonDumpString (
 JsonDumpString (
-  IN    EDKII_JSON_VALUE    JsonValue,
-  IN    UINTN               Flags
+  IN    EDKII_JSON_VALUE  JsonValue,
+  IN    UINTN             Flags
   );
   );
 
 
 /**
 /**
@@ -766,9 +767,9 @@ JsonDumpString (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonLoadString (
 JsonLoadString (
-  IN    CONST CHAR8*     String,
-  IN    UINT64           Flags,
-  IN    EDKII_JSON_ERROR *Error
+  IN    CONST CHAR8       *String,
+  IN    UINT64            Flags,
+  IN    EDKII_JSON_ERROR  *Error
   );
   );
 
 
 /**
 /**
@@ -793,7 +794,7 @@ JsonLoadString (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonLoadBuffer (
 JsonLoadBuffer (
-  IN    CONST CHAR8       *Buffer,
+  IN    CONST CHAR8        *Buffer,
   IN    UINTN              BufferLen,
   IN    UINTN              BufferLen,
   IN    UINTN              Flags,
   IN    UINTN              Flags,
   IN OUT EDKII_JSON_ERROR  *Error
   IN OUT EDKII_JSON_ERROR  *Error
@@ -815,7 +816,7 @@ JsonLoadBuffer (
 VOID
 VOID
 EFIAPI
 EFIAPI
 JsonDecreaseReference (
 JsonDecreaseReference (
-  IN EDKII_JSON_VALUE JsonValue
+  IN EDKII_JSON_VALUE  JsonValue
   );
   );
 
 
 /**
 /**
@@ -833,8 +834,9 @@ JsonDecreaseReference (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonIncreaseReference (
 JsonIncreaseReference (
-  IN EDKII_JSON_VALUE JsonValue
+  IN EDKII_JSON_VALUE  JsonValue
   );
   );
+
 /**
 /**
   Returns an opaque iterator which can be used to iterate over all key-value pairs
   Returns an opaque iterator which can be used to iterate over all key-value pairs
   in object, or NULL if object is empty
   in object, or NULL if object is empty
@@ -844,7 +846,7 @@ JsonIncreaseReference (
 VOID *
 VOID *
 EFIAPI
 EFIAPI
 JsonObjectIterator (
 JsonObjectIterator (
-  IN EDKII_JSON_VALUE JsonValue
+  IN EDKII_JSON_VALUE  JsonValue
   );
   );
 
 
 /**
 /**
@@ -855,7 +857,7 @@ JsonObjectIterator (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonObjectIteratorValue (
 JsonObjectIteratorValue (
-  IN VOID *Iterator
+  IN VOID  *Iterator
   );
   );
 
 
 /**
 /**
@@ -869,8 +871,8 @@ JsonObjectIteratorValue (
 VOID *
 VOID *
 EFIAPI
 EFIAPI
 JsonObjectIteratorNext (
 JsonObjectIteratorNext (
-  IN EDKII_JSON_VALUE JsonValue,
-  IN VOID             *Iterator
+  IN EDKII_JSON_VALUE  JsonValue,
+  IN VOID              *Iterator
   );
   );
 
 
 /**
 /**
@@ -882,8 +884,8 @@ JsonObjectIteratorNext (
 CHAR8 *
 CHAR8 *
 EFIAPI
 EFIAPI
 JsonObjectIteratorKey (
 JsonObjectIteratorKey (
-  IN VOID *Iterator
-);
+  IN VOID  *Iterator
+  );
 
 
 /**
 /**
   Returns the pointer of iterator by key.
   Returns the pointer of iterator by key.
@@ -894,8 +896,8 @@ JsonObjectIteratorKey (
 VOID *
 VOID *
 EFIAPI
 EFIAPI
 JsonObjectKeyToIterator (
 JsonObjectKeyToIterator (
-  IN CHAR8 *Key
-);
+  IN CHAR8  *Key
+  );
 
 
 /**
 /**
   Returns the json type of this json value
   Returns the json type of this json value
@@ -905,7 +907,8 @@ JsonObjectKeyToIterator (
 **/
 **/
 EDKII_JSON_TYPE
 EDKII_JSON_TYPE
 EFIAPI
 EFIAPI
-JsonGetType(
-  IN EDKII_JSON_VALUE JsonValue
+JsonGetType (
+  IN EDKII_JSON_VALUE  JsonValue
   );
   );
+
 #endif
 #endif

+ 12 - 10
RedfishPkg/Include/Library/RedfishContentCodingLib.h

@@ -6,6 +6,7 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 
 **/
 **/
+
 #ifndef REDFISH_CONTENT_CODING_LIB_H_
 #ifndef REDFISH_CONTENT_CODING_LIB_H_
 #define REDFISH_CONTENT_CODING_LIB_H_
 #define REDFISH_CONTENT_CODING_LIB_H_
 
 
@@ -36,11 +37,11 @@
 
 
 EFI_STATUS
 EFI_STATUS
 RedfishContentEncode  (
 RedfishContentEncode  (
-  IN CHAR8  *ContentEncodedValue,
-  IN CHAR8  *OriginalContent,
-  IN UINTN  OriginalContentLength,
-  OUT VOID  **EncodedContentPointer,
-  OUT UINTN *EncodedLength
+  IN CHAR8   *ContentEncodedValue,
+  IN CHAR8   *OriginalContent,
+  IN UINTN   OriginalContentLength,
+  OUT VOID   **EncodedContentPointer,
+  OUT UINTN  *EncodedLength
   );
   );
 
 
 /**
 /**
@@ -69,10 +70,11 @@ RedfishContentEncode  (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishContentDecode (
 RedfishContentDecode (
-  IN CHAR8  *ContentEncodedValue,
-  IN VOID   *ContentPointer,
-  IN UINTN  ContentLength,
-  OUT VOID  **DecodedContentPointer,
-  OUT UINTN *DecodedLength
+  IN CHAR8   *ContentEncodedValue,
+  IN VOID    *ContentPointer,
+  IN UINTN   ContentLength,
+  OUT VOID   **DecodedContentPointer,
+  OUT UINTN  *DecodedLength
   );
   );
+
 #endif
 #endif

+ 8 - 6
RedfishPkg/Include/Library/RedfishCredentialLib.h

@@ -6,6 +6,7 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 
 **/
 **/
+
 #ifndef REDFISH_CREDENTIAL_LIB_H_
 #ifndef REDFISH_CREDENTIAL_LIB_H_
 #define REDFISH_CREDENTIAL_LIB_H_
 #define REDFISH_CREDENTIAL_LIB_H_
 
 
@@ -20,7 +21,7 @@ VOID
 EFIAPI
 EFIAPI
 LibCredentialExitBootServicesNotify (
 LibCredentialExitBootServicesNotify (
   IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This
   IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This
-);
+  );
 
 
 /**
 /**
   Notification of End of DXe.
   Notification of End of DXe.
@@ -31,7 +32,7 @@ VOID
 EFIAPI
 EFIAPI
 LibCredentialEndOfDxeNotify (
 LibCredentialEndOfDxeNotify (
   IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This
   IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This
-);
+  );
 
 
 /**
 /**
   Retrieve platform's Redfish authentication information.
   Retrieve platform's Redfish authentication information.
@@ -64,7 +65,7 @@ LibCredentialGetAuthInfo (
   OUT EDKII_REDFISH_AUTH_METHOD          *AuthMethod,
   OUT EDKII_REDFISH_AUTH_METHOD          *AuthMethod,
   OUT CHAR8                              **UserId,
   OUT CHAR8                              **UserId,
   OUT CHAR8                              **Password
   OUT CHAR8                              **Password
-);
+  );
 
 
 /**
 /**
   Notify the Redfish service provide to stop provide configuration service to this platform.
   Notify the Redfish service provide to stop provide configuration service to this platform.
@@ -85,7 +86,8 @@ LibCredentialGetAuthInfo (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 LibStopRedfishService (
 LibStopRedfishService (
-  IN     EDKII_REDFISH_CREDENTIAL_PROTOCOL          *This,
-  IN     EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
-);
+  IN     EDKII_REDFISH_CREDENTIAL_PROTOCOL           *This,
+  IN     EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE  ServiceStopType
+  );
+
 #endif
 #endif

+ 413 - 115
RedfishPkg/Include/Library/RedfishCrtLib.h

@@ -19,74 +19,76 @@
 #define MAX_STRING_SIZE  0x10000000
 #define MAX_STRING_SIZE  0x10000000
 
 
 // Minimum value for an object of type long long int.
 // Minimum value for an object of type long long int.
-#define LLONG_MIN   MIN_INT64
+#define LLONG_MIN  MIN_INT64
 
 
 // Maximum value for an object of type long long int.
 // Maximum value for an object of type long long int.
-#define LLONG_MAX   MAX_INT64
+#define LLONG_MAX  MAX_INT64
 
 
 // We dont support double on edk2
 // We dont support double on edk2
-#define HUGE_VAL    0
+#define HUGE_VAL  0
 
 
-#if defined(MDE_CPU_X64) || defined(MDE_CPU_AARCH64) || defined(MDE_CPU_RISCV64)
+#if defined (MDE_CPU_X64) || defined (MDE_CPU_AARCH64) || defined (MDE_CPU_RISCV64)
 //
 //
 // With GCC we would normally use SIXTY_FOUR_BIT_LONG, but MSVC needs
 // With GCC we would normally use SIXTY_FOUR_BIT_LONG, but MSVC needs
 // SIXTY_FOUR_BIT, because 'long' is 32-bit and only 'long long' is
 // SIXTY_FOUR_BIT, because 'long' is 32-bit and only 'long long' is
 // 64-bit. Since using 'long long' works fine on GCC too, just do that.
 // 64-bit. Since using 'long long' works fine on GCC too, just do that.
 //
 //
 #define SIXTY_FOUR_BIT
 #define SIXTY_FOUR_BIT
-#elif defined(MDE_CPU_IA32) || defined(MDE_CPU_ARM) || defined(MDE_CPU_EBC)
+#elif defined (MDE_CPU_IA32) || defined (MDE_CPU_ARM) || defined (MDE_CPU_EBC)
 #define THIRTY_TWO_BIT
 #define THIRTY_TWO_BIT
 #endif
 #endif
 
 
 //
 //
 // Map all va_xxxx elements to VA_xxx defined in MdePkg/Include/Base.h
 // Map all va_xxxx elements to VA_xxx defined in MdePkg/Include/Base.h
 //
 //
-#if !defined(__CC_ARM) // if va_list is not already defined
+#if !defined (__CC_ARM) // if va_list is not already defined
 #define va_list   VA_LIST
 #define va_list   VA_LIST
 #define va_arg    VA_ARG
 #define va_arg    VA_ARG
 #define va_start  VA_START
 #define va_start  VA_START
 #define va_end    VA_END
 #define va_end    VA_END
 #else // __CC_ARM
 #else // __CC_ARM
-#define va_start(Marker, Parameter)   __va_start(Marker, Parameter)
-#define va_arg(Marker, TYPE)          __va_arg(Marker, TYPE)
-#define va_end(Marker)                ((void)0)
+#define va_start(Marker, Parameter)  __va_start(Marker, Parameter)
+#define va_arg(Marker, TYPE)         __va_arg(Marker, TYPE)
+#define va_end(Marker)               ((void)0)
 #endif
 #endif
 
 
 //
 //
 // Definitions for global constants used by CRT library routines
 // Definitions for global constants used by CRT library routines
 //
 //
-#define INT_MAX      MAX_INT32        /* Maximum (signed) int value */
-#define LONG_MAX     0X7FFFFFFFL      /* max value for a long */
-#define LONG_MIN     (-LONG_MAX-1)    /* min value for a long */
-#define ULONG_MAX    0xFFFFFFFF       /* Maximum unsigned long value */
-#define CHAR_BIT     8                /* Number of bits in a char */
+#define INT_MAX    MAX_INT32          /* Maximum (signed) int value */
+#define LONG_MAX   0X7FFFFFFFL        /* max value for a long */
+#define LONG_MIN   (-LONG_MAX-1)      /* min value for a long */
+#define ULONG_MAX  0xFFFFFFFF         /* Maximum unsigned long value */
+#define CHAR_BIT   8                  /* Number of bits in a char */
 
 
 // Maximum value for an object of type unsigned long long int.
 // Maximum value for an object of type unsigned long long int.
 #define ULLONG_MAX  0xFFFFFFFFFFFFFFFFULL // 2^64 - 1
 #define ULLONG_MAX  0xFFFFFFFFFFFFFFFFULL // 2^64 - 1
 // Maximum value for an object of type unsigned char.
 // Maximum value for an object of type unsigned char.
-#define UCHAR_MAX   255  // 2^8 - 1
+#define UCHAR_MAX  255   // 2^8 - 1
 
 
 //
 //
 // Basic types mapping
 // Basic types mapping
 //
 //
-typedef UINTN          size_t;
-typedef INTN           ssize_t;
-typedef INT32          time_t;
-typedef UINT8          __uint8_t;
-typedef UINT8          sa_family_t;
-typedef UINT32         uid_t;
-typedef UINT32         gid_t;
-typedef INT32          int32_t;
-typedef UINT32         uint32_t;
-typedef UINT16         uint16_t;
-typedef UINT8          uint8_t;
-typedef enum {false, true} bool;
+typedef UINTN   size_t;
+typedef INTN    ssize_t;
+typedef INT32   time_t;
+typedef UINT8   __uint8_t;
+typedef UINT8   sa_family_t;
+typedef UINT32  uid_t;
+typedef UINT32  gid_t;
+typedef INT32   int32_t;
+typedef UINT32  uint32_t;
+typedef UINT16  uint16_t;
+typedef UINT8   uint8_t;
+typedef enum {
+  false, true
+} bool;
 
 
 //
 //
 // File operations are not required for EFI building,
 // File operations are not required for EFI building,
 // so FILE is mapped to VOID * to pass build
 // so FILE is mapped to VOID * to pass build
 //
 //
-typedef VOID  *FILE;
+typedef VOID *FILE;
 
 
 /**
 /**
   This is the Redfish version of CRT snprintf function, this function replaces "%s" to
   This is the Redfish version of CRT snprintf function, this function replaces "%s" to
@@ -133,110 +135,406 @@ RedfishAsciiSPrint (
 UINTN
 UINTN
 EFIAPI
 EFIAPI
 RedfishAsciiVSPrint (
 RedfishAsciiVSPrint (
-  OUT CHAR8         *StartOfBuffer,
-  IN  UINTN         BufferSize,
-  IN  CONST CHAR8   *FormatString,
-  IN  VA_LIST       Marker
+  OUT CHAR8        *StartOfBuffer,
+  IN  UINTN        BufferSize,
+  IN  CONST CHAR8  *FormatString,
+  IN  VA_LIST      Marker
   );
   );
 
 
 //
 //
 // Global variables
 // Global variables
 //
 //
-extern int  errno;
-extern FILE *stderr;
+extern int   errno;
+extern FILE  *stderr;
 
 
 //
 //
 // Function prototypes of CRT Library routines
 // Function prototypes of CRT Library routines
 //
 //
-void           *malloc     (size_t);
-void           *realloc    (void *, size_t);
-void           *calloc     (size_t Num, size_t Size);
-void           free        (void *);
-void           *memset     (void *, int, size_t);
-int            memcmp      (const void *, const void *, size_t);
-int            isdigit     (int);
-int            isspace     (int);
-int            tolower     (int);
-int            isupper     (int);
-int            isxdigit    (int);
-int            isalnum     (int);
-void           *memcpy     (void *, const void *, size_t);
-void           *memset     (void *, int, size_t);
-void           *memchr     (const void *, int, size_t);
-int            memcmp      (const void *, const void *, size_t);
-void           *memmove    (void *, const void *, size_t);
-int            strcmp      (const char *, const char *);
-int            strncmp     (const char *, const char *, size_t);
-char           *strcpy     (char *, const char *);
-size_t         strlen      (const char *);
-char           *strcat     (char *, const char *);
-char           *strchr     (const char *, int);
-int            strcasecmp  (const char *, const char *);
-int            strncasecmp (const char *, const char *, size_t);
-char           *strncpy    (char *, size_t, const char *, size_t);
-int            strncmp     (const char *, const char *, size_t);
-char           *strrchr    (const char *, int);
-unsigned long  strtoul     (const char *, char **, int);
-char *         strstr      (const char *s1 , const char *s2);
-long           strtol      (const char *, char **, int);
-char           *strerror   (int);
-size_t         strspn      (const char *, const char *);
-char *         strdup      (const char *str);
-char *         strpbrk     (const char *s1, const char *s2);
-unsigned long long strtoull(const char * nptr, char ** endptr, int base);
-long long      strtoll     (const char * nptr, char ** endptr, int base);
-long           strtol      (const char * nptr, char ** endptr, int base);
-double         strtod      (const char * __restrict nptr, char ** __restrict endptr);
-size_t         strcspn     (const char *, const char *);
-int            printf      (const char *, ...);
-int            sscanf      (const char *, const char *, ...);
-FILE           *fopen      (const char *, const char *);
-size_t         fread       (void *, size_t, size_t, FILE *);
-size_t         fwrite      (const void *, size_t, size_t, FILE *);
-int            fclose      (FILE *);
-int            fprintf     (FILE *, const char *, ...);
-int            fgetc       (FILE * _File);
-uid_t          getuid      (void);
-uid_t          geteuid     (void);
-gid_t          getgid      (void);
-gid_t          getegid     (void);
-void           qsort       (void *, size_t, size_t, int (*)(const void *, const void *));
-char           *getenv     (const char *);
-#if defined(__GNUC__) && (__GNUC__ >= 2)
-void           abort       (void) __attribute__((__noreturn__));
+void           *
+malloc     (
+  size_t
+  );
+
+void           *
+realloc    (
+  void *,
+  size_t
+  );
+
+void           *
+calloc     (
+  size_t  Num,
+  size_t  Size
+  );
+
+void
+free        (
+  void *
+  );
+
+void           *
+memset     (
+  void *,
+  int,
+  size_t
+  );
+
+int
+memcmp      (
+  const void *,
+  const void *,
+  size_t
+  );
+
+int
+isdigit     (
+  int
+  );
+
+int
+isspace     (
+  int
+  );
+
+int
+tolower     (
+  int
+  );
+
+int
+isupper     (
+  int
+  );
+
+int
+isxdigit    (
+  int
+  );
+
+int
+isalnum     (
+  int
+  );
+
+void           *
+memcpy     (
+  void *,
+  const void *,
+  size_t
+  );
+
+void           *
+memset     (
+  void *,
+  int,
+  size_t
+  );
+
+void           *
+memchr     (
+  const void *,
+  int,
+  size_t
+  );
+
+int
+memcmp      (
+  const void *,
+  const void *,
+  size_t
+  );
+
+void           *
+memmove    (
+  void *,
+  const void *,
+  size_t
+  );
+
+int
+strcmp      (
+  const char *,
+  const char *
+  );
+
+int
+strncmp     (
+  const char *,
+  const char *,
+  size_t
+  );
+
+char           *
+strcpy     (
+  char *,
+  const char *
+  );
+
+size_t
+strlen      (
+  const char *
+  );
+
+char           *
+strcat     (
+  char *,
+  const char *
+  );
+
+char           *
+strchr     (
+  const char *,
+  int
+  );
+
+int
+strcasecmp  (
+  const char *,
+  const char *
+  );
+
+int
+strncasecmp (
+  const char *,
+  const char *,
+  size_t
+  );
+
+char           *
+strncpy    (
+  char *,
+  size_t,
+  const char *,
+  size_t
+  );
+
+int
+strncmp     (
+  const char *,
+  const char *,
+  size_t
+  );
+
+char           *
+strrchr    (
+  const char *,
+  int
+  );
+
+unsigned long
+strtoul     (
+  const char *,
+  char **,
+  int
+  );
+
+char *
+strstr      (
+  const char  *s1,
+  const char  *s2
+  );
+
+long
+strtol      (
+  const char *,
+  char **,
+  int
+  );
+
+char           *
+strerror   (
+  int
+  );
+
+size_t
+strspn      (
+  const char *,
+  const char *
+  );
+
+char *
+strdup      (
+  const char  *str
+  );
+
+char *
+strpbrk     (
+  const char  *s1,
+  const char  *s2
+  );
+
+unsigned long long
+strtoull (
+  const char  *nptr,
+  char        **endptr,
+  int         base
+  );
+
+long long
+strtoll     (
+  const char  *nptr,
+  char        **endptr,
+  int         base
+  );
+
+long
+strtol      (
+  const char  *nptr,
+  char        **endptr,
+  int         base
+  );
+
+double
+strtod      (
+  const char *__restrict  nptr,
+  char **__restrict       endptr
+  );
+
+size_t
+strcspn     (
+  const char *,
+  const char *
+  );
+
+int
+printf      (
+  const char *,
+  ...
+  );
+
+int
+sscanf      (
+  const char *,
+  const char *,
+  ...
+  );
+
+FILE           *
+fopen      (
+  const char *,
+  const char *
+  );
+
+size_t
+fread       (
+  void *,
+  size_t,
+  size_t,
+  FILE *
+  );
+
+size_t
+fwrite      (
+  const void *,
+  size_t,
+  size_t,
+  FILE *
+  );
+
+int
+fclose      (
+  FILE *
+  );
+
+int
+fprintf     (
+  FILE *,
+  const char *,
+  ...
+  );
+
+int
+fgetc       (
+  FILE  *_File
+  );
+
+uid_t
+getuid      (
+  void
+  );
+
+uid_t
+geteuid     (
+  void
+  );
+
+gid_t
+getgid      (
+  void
+  );
+
+gid_t
+getegid     (
+  void
+  );
+
+void
+qsort       (
+  void *,
+  size_t,
+  size_t,
+  int (*)(const void *, const void *)
+  );
+
+char           *
+getenv     (
+  const char *
+  );
+
+#if defined (__GNUC__) && (__GNUC__ >= 2)
+void
+abort       (
+  void
+  ) __attribute__ ((__noreturn__));
+
 #else
 #else
-void           abort       (void);
+void
+abort       (
+  void
+  );
+
 #endif
 #endif
-int            toupper     (int);
-int            Digit2Val   (int);
-time_t         time        (time_t *);
+int
+toupper     (
+  int
+  );
+
+int
+Digit2Val   (
+  int
+  );
+
+time_t
+time        (
+  time_t *
+  );
 
 
 //
 //
 // Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions
 // Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions
 //
 //
-#define strcmp                            AsciiStrCmp
-#define memcpy(dest,source,count)         CopyMem(dest,source,(UINTN)(count))
-#define memset(dest,ch,count)             SetMem(dest,(UINTN)(count),(UINT8)(ch))
-#define memchr(buf,ch,count)              ScanMem8(buf,(UINTN)(count),(UINT8)ch)
-#define memcmp(buf1,buf2,count)           (int)(CompareMem(buf1,buf2,(UINTN)(count)))
-#define memmove(dest,source,count)        CopyMem(dest,source,(UINTN)(count))
-#define strlen(str)                       (size_t)(AsciiStrnLenS(str,MAX_STRING_SIZE))
-#define strcpy(strDest,strSource)         AsciiStrCpyS(strDest,(strlen(strSource)+1),strSource)
-#define strncpy(strDest,strSource,count)  AsciiStrnCpyS(strDest,(UINTN)count,strSource,(UINTN)count)
-#define strncpys(strDest, DestLen, strSource,count)  AsciiStrnCpyS(strDest,DestLen,strSource,(UINTN)count)
-#define strcat(strDest,strSource)         AsciiStrCatS(strDest,(strlen(strSource)+strlen(strDest)+1),strSource)
-#define strchr(str,ch)                    ScanMem8((VOID *)(str),AsciiStrSize(str),(UINT8)ch)
-#define strcasecmp(str1,str2)             (int)AsciiStriCmp(str1,str2)
-#define strstr(s1,s2)                     AsciiStrStr(s1,s2)
-#define snprintf(buf,len,...)             RedfishAsciiSPrint(buf,len,__VA_ARGS__)
-#define vsnprintf(buf,len,format,marker)  RedfishAsciiVSPrint((buf),(len),(format),(marker))
-#define assert(expression)                ASSERT(expression)
-#define offsetof(type,member)             OFFSET_OF(type,member)
-
-#define EOF (-1)
+#define strcmp  AsciiStrCmp
+#define memcpy(dest, source, count)                   CopyMem(dest,source,(UINTN)(count))
+#define memset(dest, ch, count)                       SetMem(dest,(UINTN)(count),(UINT8)(ch))
+#define memchr(buf, ch, count)                        ScanMem8(buf,(UINTN)(count),(UINT8)ch)
+#define memcmp(buf1, buf2, count)                     (int)(CompareMem(buf1,buf2,(UINTN)(count)))
+#define memmove(dest, source, count)                  CopyMem(dest,source,(UINTN)(count))
+#define strlen(str)                                   (size_t)(AsciiStrnLenS(str,MAX_STRING_SIZE))
+#define strcpy(strDest, strSource)                    AsciiStrCpyS(strDest,(strlen(strSource)+1),strSource)
+#define strncpy(strDest, strSource, count)            AsciiStrnCpyS(strDest,(UINTN)count,strSource,(UINTN)count)
+#define strncpys(strDest, DestLen, strSource, count)  AsciiStrnCpyS(strDest,DestLen,strSource,(UINTN)count)
+#define strcat(strDest, strSource)                    AsciiStrCatS(strDest,(strlen(strSource)+strlen(strDest)+1),strSource)
+#define strchr(str, ch)                               ScanMem8((VOID *)(str),AsciiStrSize(str),(UINT8)ch)
+#define strcasecmp(str1, str2)                        (int)AsciiStriCmp(str1,str2)
+#define strstr(s1, s2)                                AsciiStrStr(s1,s2)
+#define snprintf(buf, len, ...)                       RedfishAsciiSPrint(buf,len,__VA_ARGS__)
+#define vsnprintf(buf, len, format, marker)           RedfishAsciiVSPrint((buf),(len),(format),(marker))
+#define assert(expression)                            ASSERT(expression)
+#define offsetof(type, member)                        OFFSET_OF(type,member)
+
+#define EOF  (-1)
 
 
 extern int  errno;
 extern int  errno;
 
 
-#define ERANGE   34                /* 34   Result too large */
+#define ERANGE  34                 /* 34   Result too large */
 
 
 #endif
 #endif

+ 8 - 5
RedfishPkg/Include/Library/RedfishHostInterfaceLib.h

@@ -6,6 +6,7 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 
 **/
 **/
+
 #ifndef REDFISH_HOST_INTERFACE_LIB_H_
 #ifndef REDFISH_HOST_INTERFACE_LIB_H_
 #define REDFISH_HOST_INTERFACE_LIB_H_
 #define REDFISH_HOST_INTERFACE_LIB_H_
 
 
@@ -27,9 +28,10 @@
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8 *DeviceType,
+  IN UINT8                    *DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
-);
+  );
+
 /**
 /**
   Get platform Redfish host interface protocol data.
   Get platform Redfish host interface protocol data.
   Caller should pass NULL in ProtocolRecord to retrive the first protocol record.
   Caller should pass NULL in ProtocolRecord to retrive the first protocol record.
@@ -46,7 +48,8 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishPlatformHostInterfaceProtocolData (
 RedfishPlatformHostInterfaceProtocolData (
-  IN OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord,
-  IN UINT8  IndexOfProtocolData
-);
+  IN OUT MC_HOST_INTERFACE_PROTOCOL_RECORD  **ProtocolRecord,
+  IN UINT8                                  IndexOfProtocolData
+  );
+
 #endif
 #endif

+ 5 - 5
RedfishPkg/Include/Library/RestExLib.h

@@ -32,11 +32,11 @@
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RestExLibCreateChild (
 RestExLibCreateChild (
-  IN EFI_HANDLE Image,
+  IN EFI_HANDLE                       Image,
   IN EFI_REST_EX_SERVICE_ACCESS_MODE  AccessMode,
   IN EFI_REST_EX_SERVICE_ACCESS_MODE  AccessMode,
-  IN EFI_REST_EX_CONFIG_TYPE ConfigType,
-  IN EFI_REST_EX_SERVICE_TYPE ServiceType,
-  OUT EFI_HANDLE *ChildInstanceHandle
-);
+  IN EFI_REST_EX_CONFIG_TYPE          ConfigType,
+  IN EFI_REST_EX_SERVICE_TYPE         ServiceType,
+  OUT EFI_HANDLE                      *ChildInstanceHandle
+  );
 
 
 #endif
 #endif

+ 3 - 3
RedfishPkg/Include/Pcd/RestExServiceDevicePath.h

@@ -21,8 +21,8 @@ typedef enum {
 } DEVICE_PATH_MATCH_MODE;
 } DEVICE_PATH_MATCH_MODE;
 
 
 typedef struct {
 typedef struct {
-  UINT32 DevicePathMatchMode;
-  UINT32 DevicePathNum;
+  UINT32    DevicePathMatchMode;
+  UINT32    DevicePathNum;
   //
   //
   // Example:
   // Example:
   //   {DEVICE_PATH("PciRoot(0)/Pci(0,0)/MAC(005056C00002,0x1)")}
   //   {DEVICE_PATH("PciRoot(0)/Pci(0,0)/MAC(005056C00002,0x1)")}
@@ -32,7 +32,7 @@ typedef struct {
   //    0x03,0x0b,0x25,0x00,0x00,0x50,0x56,0xc0,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
   //    0x03,0x0b,0x25,0x00,0x00,0x50,0x56,0xc0,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
   //    0x7f,0xff,0x04,0x00}
   //    0x7f,0xff,0x04,0x00}
   //
   //
-  EFI_DEVICE_PATH_PROTOCOL      DevicePath[];
+  EFI_DEVICE_PATH_PROTOCOL    DevicePath[];
 } REST_EX_SERVICE_DEVICE_PATH_DATA;
 } REST_EX_SERVICE_DEVICE_PATH_DATA;
 
 
 #endif
 #endif

+ 14 - 15
RedfishPkg/Include/Protocol/EdkIIRedfishConfigHandler.h

@@ -19,15 +19,15 @@ typedef struct _EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL EDKII_REDFISH_CONFIG_HANDL
     }
     }
 
 
 typedef struct {
 typedef struct {
-  EFI_HANDLE        RedfishServiceRestExHandle; ///< REST EX EFI handle associated with this Redfish service.
-  UINTN             RedfishServiceVersion;      ///< Redfish service version.
-  CHAR16            *RedfishServiceLocation;    ///< Redfish service location.
-  CHAR16            *RedfishServiceUuid;        ///< Redfish service UUID.
-  CHAR16            *RedfishServiceOs;          ///< Redfish service OS.
-  CHAR16            *RedfishServiceOsVersion;   ///< Redfish service OS version.
-  CHAR16            *RedfishServiceProduct;     ///< Redfish service product name.
-  CHAR16            *RedfishServiceProductVer;  ///< Redfish service product version.
-  BOOLEAN           RedfishServiceUseHttps;     ///< Redfish service uses HTTPS.
+  EFI_HANDLE    RedfishServiceRestExHandle;     ///< REST EX EFI handle associated with this Redfish service.
+  UINTN         RedfishServiceVersion;          ///< Redfish service version.
+  CHAR16        *RedfishServiceLocation;        ///< Redfish service location.
+  CHAR16        *RedfishServiceUuid;            ///< Redfish service UUID.
+  CHAR16        *RedfishServiceOs;              ///< Redfish service OS.
+  CHAR16        *RedfishServiceOsVersion;       ///< Redfish service OS version.
+  CHAR16        *RedfishServiceProduct;         ///< Redfish service product name.
+  CHAR16        *RedfishServiceProductVer;      ///< Redfish service product version.
+  BOOLEAN       RedfishServiceUseHttps;         ///< Redfish service uses HTTPS.
 } REDFISH_CONFIG_SERVICE_INFORMATION;
 } REDFISH_CONFIG_SERVICE_INFORMATION;
 
 
 /**
 /**
@@ -47,7 +47,7 @@ typedef struct {
 **/
 **/
 typedef
 typedef
 EFI_STATUS
 EFI_STATUS
-(EFIAPI *EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_INIT) (
+(EFIAPI *EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_INIT)(
   IN  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This,
   IN  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *This,
   IN  REDFISH_CONFIG_SERVICE_INFORMATION  *RedfishServiceinfo
   IN  REDFISH_CONFIG_SERVICE_INFORMATION  *RedfishServiceinfo
   );
   );
@@ -63,16 +63,15 @@ EFI_STATUS
 **/
 **/
 typedef
 typedef
 EFI_STATUS
 EFI_STATUS
-(EFIAPI *EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_STOP) (
+(EFIAPI *EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_STOP)(
   IN     EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL    *This
   IN     EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL    *This
   );
   );
 
 
 struct _EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL {
 struct _EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL {
-  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_INIT      Init;
-  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_STOP      Stop;
+  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_INIT    Init;
+  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL_STOP    Stop;
 };
 };
 
 
-
-extern EFI_GUID gdkIIRedfishConfigHandlerProtocolGuid;
+extern EFI_GUID  gdkIIRedfishConfigHandlerProtocolGuid;
 
 
 #endif
 #endif

+ 5 - 6
RedfishPkg/Include/Protocol/EdkIIRedfishCredential.h

@@ -34,7 +34,6 @@ typedef enum {
   ServiceStopTypeMax
   ServiceStopTypeMax
 } EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE;
 } EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE;
 
 
-
 /**
 /**
   Retrieve platform's Redfish authentication information.
   Retrieve platform's Redfish authentication information.
 
 
@@ -61,7 +60,7 @@ typedef enum {
 **/
 **/
 typedef
 typedef
 EFI_STATUS
 EFI_STATUS
-(EFIAPI *EDKII_REDFISH_CREDENTIAL_PROTOCOL_GET_AUTH_INFO) (
+(EFIAPI *EDKII_REDFISH_CREDENTIAL_PROTOCOL_GET_AUTH_INFO)(
   IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL    *This,
   IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL    *This,
   OUT EDKII_REDFISH_AUTH_METHOD            *AuthMethod,
   OUT EDKII_REDFISH_AUTH_METHOD            *AuthMethod,
   OUT CHAR8                                **UserId,
   OUT CHAR8                                **UserId,
@@ -86,16 +85,16 @@ EFI_STATUS
 **/
 **/
 typedef
 typedef
 EFI_STATUS
 EFI_STATUS
-(EFIAPI *EDKII_REDFISH_CREDENTIAL_PROTOCOL_STOP_SERVICE) (
+(EFIAPI *EDKII_REDFISH_CREDENTIAL_PROTOCOL_STOP_SERVICE)(
   IN     EDKII_REDFISH_CREDENTIAL_PROTOCOL            *This,
   IN     EDKII_REDFISH_CREDENTIAL_PROTOCOL            *This,
   IN     EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE   ServiceStopType
   IN     EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE   ServiceStopType
   );
   );
 
 
 struct _EDKII_REDFISH_CREDENTIAL_PROTOCOL {
 struct _EDKII_REDFISH_CREDENTIAL_PROTOCOL {
-  EDKII_REDFISH_CREDENTIAL_PROTOCOL_GET_AUTH_INFO      GetAuthInfo;
-  EDKII_REDFISH_CREDENTIAL_PROTOCOL_STOP_SERVICE       StopService;
+  EDKII_REDFISH_CREDENTIAL_PROTOCOL_GET_AUTH_INFO    GetAuthInfo;
+  EDKII_REDFISH_CREDENTIAL_PROTOCOL_STOP_SERVICE     StopService;
 };
 };
 
 
-extern EFI_GUID gEdkIIRedfishCredentialProtocolGuid;
+extern EFI_GUID  gEdkIIRedfishCredentialProtocolGuid;
 
 
 #endif
 #endif

+ 62 - 79
RedfishPkg/Library/BaseUcs2Utf8Lib/BaseUcs2Utf8Lib.c

@@ -26,17 +26,16 @@
 **/
 **/
 UINT8
 UINT8
 GetUTF8SizeForUCS2 (
 GetUTF8SizeForUCS2 (
-  IN    CHAR8      *Utf8Buffer
+  IN    CHAR8  *Utf8Buffer
   )
   )
 {
 {
-  CHAR8    TempChar;
-  UINT8    Utf8Size;
+  CHAR8  TempChar;
+  UINT8  Utf8Size;
 
 
   ASSERT (Utf8Buffer != NULL);
   ASSERT (Utf8Buffer != NULL);
 
 
   TempChar = *Utf8Buffer;
   TempChar = *Utf8Buffer;
   if ((TempChar & 0xF0) == 0xF0) {
   if ((TempChar & 0xF0) == 0xF0) {
-
     //
     //
     // This format is not for UCS2.
     // This format is not for UCS2.
     //
     //
@@ -46,11 +45,9 @@ GetUTF8SizeForUCS2 (
   Utf8Size = 1;
   Utf8Size = 1;
   if ((TempChar & 0x80) == 0x80) {
   if ((TempChar & 0x80) == 0x80) {
     if ((TempChar & 0xC0) == 0xC0) {
     if ((TempChar & 0xC0) == 0xC0) {
-
-      Utf8Size ++;
+      Utf8Size++;
       if ((TempChar & 0xE0) == 0xE0) {
       if ((TempChar & 0xE0) == 0xE0) {
-
-        Utf8Size ++;
+        Utf8Size++;
       }
       }
     }
     }
   }
   }
@@ -74,16 +71,16 @@ GetUTF8SizeForUCS2 (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 GetUCS2CharByFormat (
 GetUCS2CharByFormat (
-  IN    CHAR8      *Utf8Buffer,
-  OUT   CHAR16     *Ucs2Char
+  IN    CHAR8   *Utf8Buffer,
+  OUT   CHAR16  *Ucs2Char
   )
   )
 {
 {
-  UINT8     Num1;
-  UINT8     Num2;
-  UINT8     Index;
-  CHAR8     Ucs2CharFormat[UNICODE_FORMAT_CHAR_SIZE];  /// two Hexadecimal digits Ascii string, like "3F"
+  UINT8  Num1;
+  UINT8  Num2;
+  UINT8  Index;
+  CHAR8  Ucs2CharFormat[UNICODE_FORMAT_CHAR_SIZE];     /// two Hexadecimal digits Ascii string, like "3F"
 
 
-  for (Index = 0; Index < 4; Index ++) {
+  for (Index = 0; Index < 4; Index++) {
     if ((*(Utf8Buffer + 2 + Index) & 0x80) != 0x00) {
     if ((*(Utf8Buffer + 2 + Index) & 0x80) != 0x00) {
       return EFI_INVALID_PARAMETER;
       return EFI_INVALID_PARAMETER;
     }
     }
@@ -95,19 +92,19 @@ GetUCS2CharByFormat (
   // Get the First Number, Offset is 2
   // Get the First Number, Offset is 2
   //
   //
   CopyMem (Ucs2CharFormat, Utf8Buffer + 2, UNICODE_FORMAT_CHAR_LEN);
   CopyMem (Ucs2CharFormat, Utf8Buffer + 2, UNICODE_FORMAT_CHAR_LEN);
-  Num1 = (UINT8) AsciiStrHexToUintn (Ucs2CharFormat);
+  Num1 = (UINT8)AsciiStrHexToUintn (Ucs2CharFormat);
 
 
   //
   //
   // Get the Second Number, Offset is 4
   // Get the Second Number, Offset is 4
   //
   //
   CopyMem (Ucs2CharFormat, Utf8Buffer + 4, UNICODE_FORMAT_CHAR_LEN);
   CopyMem (Ucs2CharFormat, Utf8Buffer + 4, UNICODE_FORMAT_CHAR_LEN);
-  Num2 = (UINT8) AsciiStrHexToUintn (Ucs2CharFormat);
+  Num2 = (UINT8)AsciiStrHexToUintn (Ucs2CharFormat);
 
 
   //
   //
   // Ucs2Char is Little-Endian
   // Ucs2Char is Little-Endian
   //
   //
-  *((CHAR8 *) Ucs2Char)        = Num2;
-  *(((CHAR8 *) Ucs2Char) + 1) = Num1;
+  *((CHAR8 *)Ucs2Char)       = Num2;
+  *(((CHAR8 *)Ucs2Char) + 1) = Num1;
 
 
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }
@@ -123,33 +120,30 @@ GetUCS2CharByFormat (
 **/
 **/
 UINT8
 UINT8
 UCS2CharToUTF8 (
 UCS2CharToUTF8 (
-  IN  CHAR16     Ucs2Char,
-  OUT CHAR8      *Utf8Buffer
+  IN  CHAR16  Ucs2Char,
+  OUT CHAR8   *Utf8Buffer
   )
   )
 {
 {
-  UINT16    Ucs2Number;
+  UINT16  Ucs2Number;
 
 
   ASSERT (Utf8Buffer != NULL);
   ASSERT (Utf8Buffer != NULL);
 
 
-  Ucs2Number = (UINT16) Ucs2Char;
+  Ucs2Number = (UINT16)Ucs2Char;
   if (Ucs2Number <= 0x007F) {
   if (Ucs2Number <= 0x007F) {
-
     //
     //
     // UTF8 format: 0xxxxxxx
     // UTF8 format: 0xxxxxxx
     //
     //
     *Utf8Buffer = Ucs2Char & 0x7F;
     *Utf8Buffer = Ucs2Char & 0x7F;
     return 1;
     return 1;
-
-  } else if (Ucs2Number >= 0x0080 && Ucs2Number <= 0x07FF) {
-
+  } else if ((Ucs2Number >= 0x0080) && (Ucs2Number <= 0x07FF)) {
     //
     //
     // UTF8 format: 110xxxxx 10xxxxxx
     // UTF8 format: 110xxxxx 10xxxxxx
     //
     //
     *(Utf8Buffer + 1) = (Ucs2Char & 0x3F) | 0x80;
     *(Utf8Buffer + 1) = (Ucs2Char & 0x3F) | 0x80;
     *Utf8Buffer       = ((Ucs2Char >> 6) & 0x1F) | 0xC0;
     *Utf8Buffer       = ((Ucs2Char >> 6) & 0x1F) | 0xC0;
     return 2;
     return 2;
-
-  } else {  /// Ucs2Number >= 0x0800 && Ucs2Number <= 0xFFFF
+  } else {
+    /// Ucs2Number >= 0x0800 && Ucs2Number <= 0xFFFF
 
 
     //
     //
     // UTF8 format: 1110xxxx 10xxxxxx 10xxxxxx
     // UTF8 format: 1110xxxx 10xxxxxx 10xxxxxx
@@ -174,23 +168,22 @@ UCS2CharToUTF8 (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 UTF8ToUCS2Char (
 UTF8ToUCS2Char (
-  IN   CHAR8      *Utf8Buffer,
-  OUT  CHAR16     *Ucs2Char
+  IN   CHAR8   *Utf8Buffer,
+  OUT  CHAR16  *Ucs2Char
   )
   )
 {
 {
-  UINT8    Utf8Size;
-  CHAR8    *Ucs2Buffer;
-  CHAR8    TempChar1;
-  CHAR8    TempChar2;
-  CHAR8    TempChar3;
+  UINT8  Utf8Size;
+  CHAR8  *Ucs2Buffer;
+  CHAR8  TempChar1;
+  CHAR8  TempChar2;
+  CHAR8  TempChar3;
 
 
   ASSERT (Utf8Buffer != NULL && Ucs2Char != NULL);
   ASSERT (Utf8Buffer != NULL && Ucs2Char != NULL);
   ZeroMem (Ucs2Char, sizeof (CHAR16));
   ZeroMem (Ucs2Char, sizeof (CHAR16));
-  Ucs2Buffer = (CHAR8 *) Ucs2Char;
+  Ucs2Buffer = (CHAR8 *)Ucs2Char;
 
 
   Utf8Size = GetUTF8SizeForUCS2 (Utf8Buffer);
   Utf8Size = GetUTF8SizeForUCS2 (Utf8Buffer);
   switch (Utf8Size) {
   switch (Utf8Size) {
-
     case 1:
     case 1:
 
 
       //
       //
@@ -271,27 +264,26 @@ UTF8ToUCS2Char (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 UCS2StrToUTF8 (
 UCS2StrToUTF8 (
-  IN  CHAR16     *Ucs2Str,
-  OUT CHAR8      **Utf8StrAddr
+  IN  CHAR16  *Ucs2Str,
+  OUT CHAR8   **Utf8StrAddr
   )
   )
 {
 {
-  UINTN    Ucs2StrIndex;
-  UINTN    Ucs2StrLength;
-  CHAR8    *Utf8Str;
-  UINTN    Utf8StrLength;
-  UINTN    Utf8StrIndex;
-  CHAR8    Utf8Buffer[UTF8_BUFFER_FOR_UCS2_MAX_SIZE];
-  UINT8    Utf8BufferSize;
-
-  if (Ucs2Str == NULL || Utf8StrAddr == NULL) {
+  UINTN  Ucs2StrIndex;
+  UINTN  Ucs2StrLength;
+  CHAR8  *Utf8Str;
+  UINTN  Utf8StrLength;
+  UINTN  Utf8StrIndex;
+  CHAR8  Utf8Buffer[UTF8_BUFFER_FOR_UCS2_MAX_SIZE];
+  UINT8  Utf8BufferSize;
+
+  if ((Ucs2Str == NULL) || (Utf8StrAddr == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
   Ucs2StrLength = StrLen (Ucs2Str);
   Ucs2StrLength = StrLen (Ucs2Str);
   Utf8StrLength = 0;
   Utf8StrLength = 0;
 
 
-  for (Ucs2StrIndex = 0; Ucs2StrIndex < Ucs2StrLength; Ucs2StrIndex ++) {
-
+  for (Ucs2StrIndex = 0; Ucs2StrIndex < Ucs2StrLength; Ucs2StrIndex++) {
     ZeroMem (Utf8Buffer, sizeof (Utf8Buffer));
     ZeroMem (Utf8Buffer, sizeof (Utf8Buffer));
     Utf8BufferSize = UCS2CharToUTF8 (Ucs2Str[Ucs2StrIndex], Utf8Buffer);
     Utf8BufferSize = UCS2CharToUTF8 (Ucs2Str[Ucs2StrIndex], Utf8Buffer);
     Utf8StrLength += Utf8BufferSize;
     Utf8StrLength += Utf8BufferSize;
@@ -303,8 +295,7 @@ UCS2StrToUTF8 (
   }
   }
 
 
   Utf8StrIndex = 0;
   Utf8StrIndex = 0;
-  for (Ucs2StrIndex = 0; Ucs2StrIndex < Ucs2StrLength; Ucs2StrIndex ++) {
-
+  for (Ucs2StrIndex = 0; Ucs2StrIndex < Ucs2StrLength; Ucs2StrIndex++) {
     ZeroMem (Utf8Buffer, sizeof (Utf8Buffer));
     ZeroMem (Utf8Buffer, sizeof (Utf8Buffer));
     Utf8BufferSize = UCS2CharToUTF8 (Ucs2Str[Ucs2StrIndex], Utf8Buffer);
     Utf8BufferSize = UCS2CharToUTF8 (Ucs2Str[Ucs2StrIndex], Utf8Buffer);
 
 
@@ -313,7 +304,7 @@ UCS2StrToUTF8 (
   }
   }
 
 
   Utf8Str[Utf8StrIndex] = '\0';
   Utf8Str[Utf8StrIndex] = '\0';
-  *Utf8StrAddr = Utf8Str;
+  *Utf8StrAddr          = Utf8Str;
 
 
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }
@@ -334,18 +325,18 @@ UCS2StrToUTF8 (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 UTF8StrToUCS2 (
 UTF8StrToUCS2 (
-  IN  CHAR8      *Utf8Str,
-  OUT CHAR16     **Ucs2StrAddr
+  IN  CHAR8   *Utf8Str,
+  OUT CHAR16  **Ucs2StrAddr
   )
   )
 {
 {
-  EFI_STATUS    Status;
-  UINTN         Utf8StrIndex;
-  UINTN         Utf8StrLength;
-  UINTN         Ucs2StrIndex;
-  UINT8         Utf8BufferSize;
-  CHAR16        *Ucs2StrTemp;
-
-  if (Utf8Str == NULL || Ucs2StrAddr == NULL) {
+  EFI_STATUS  Status;
+  UINTN       Utf8StrIndex;
+  UINTN       Utf8StrLength;
+  UINTN       Ucs2StrIndex;
+  UINT8       Utf8BufferSize;
+  CHAR16      *Ucs2StrTemp;
+
+  if ((Utf8Str == NULL) || (Ucs2StrAddr == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
@@ -354,7 +345,7 @@ UTF8StrToUCS2 (
   //
   //
   Utf8StrLength = 0;
   Utf8StrLength = 0;
   while (*(Utf8Str + Utf8StrLength) != '\0') {
   while (*(Utf8Str + Utf8StrLength) != '\0') {
-    Utf8StrLength ++;
+    Utf8StrLength++;
   }
   }
 
 
   //
   //
@@ -368,46 +359,39 @@ UTF8StrToUCS2 (
   Utf8StrIndex = 0;
   Utf8StrIndex = 0;
   Ucs2StrIndex = 0;
   Ucs2StrIndex = 0;
   while (Utf8Str[Utf8StrIndex] != '\0') {
   while (Utf8Str[Utf8StrIndex] != '\0') {
-
-    if (CompareMem (Utf8Str + Utf8StrIndex, "\\u", 2) == 0 &&
-      Utf8StrLength - Utf8StrIndex >= UNICODE_FORMAT_LEN) {
-
+    if ((CompareMem (Utf8Str + Utf8StrIndex, "\\u", 2) == 0) &&
+        (Utf8StrLength - Utf8StrIndex >= UNICODE_FORMAT_LEN))
+    {
       Status = GetUCS2CharByFormat (Utf8Str + Utf8StrIndex, Ucs2StrTemp + Ucs2StrIndex);
       Status = GetUCS2CharByFormat (Utf8Str + Utf8StrIndex, Ucs2StrTemp + Ucs2StrIndex);
       if (!EFI_ERROR (Status)) {
       if (!EFI_ERROR (Status)) {
-
         Utf8StrIndex += UNICODE_FORMAT_LEN;
         Utf8StrIndex += UNICODE_FORMAT_LEN;
-        Ucs2StrIndex ++;
+        Ucs2StrIndex++;
       } else {
       } else {
-
         StrCpyS (Ucs2StrTemp + Ucs2StrIndex, 3, L"\\u");
         StrCpyS (Ucs2StrTemp + Ucs2StrIndex, 3, L"\\u");
 
 
         Ucs2StrIndex += 2;
         Ucs2StrIndex += 2;
         Utf8StrIndex += 2;
         Utf8StrIndex += 2;
       }
       }
     } else {
     } else {
-
       Utf8BufferSize = GetUTF8SizeForUCS2 (Utf8Str + Utf8StrIndex);
       Utf8BufferSize = GetUTF8SizeForUCS2 (Utf8Str + Utf8StrIndex);
-      if (Utf8BufferSize == 0 || Utf8StrLength - Utf8StrIndex < Utf8BufferSize) {
-
+      if ((Utf8BufferSize == 0) || (Utf8StrLength - Utf8StrIndex < Utf8BufferSize)) {
         FreePool (Ucs2StrTemp);
         FreePool (Ucs2StrTemp);
         return EFI_INVALID_PARAMETER;
         return EFI_INVALID_PARAMETER;
       }
       }
 
 
       Status = UTF8ToUCS2Char (Utf8Str + Utf8StrIndex, Ucs2StrTemp + Ucs2StrIndex);
       Status = UTF8ToUCS2Char (Utf8Str + Utf8StrIndex, Ucs2StrTemp + Ucs2StrIndex);
       if (EFI_ERROR (Status)) {
       if (EFI_ERROR (Status)) {
-
         FreePool (Ucs2StrTemp);
         FreePool (Ucs2StrTemp);
         return EFI_INVALID_PARAMETER;
         return EFI_INVALID_PARAMETER;
       }
       }
 
 
-      Ucs2StrIndex ++;
+      Ucs2StrIndex++;
       Utf8StrIndex += Utf8BufferSize;
       Utf8StrIndex += Utf8BufferSize;
     }
     }
   }
   }
 
 
   *Ucs2StrAddr = AllocateZeroPool ((Ucs2StrIndex + 1) * sizeof (CHAR16));
   *Ucs2StrAddr = AllocateZeroPool ((Ucs2StrIndex + 1) * sizeof (CHAR16));
   if (*Ucs2StrAddr == NULL) {
   if (*Ucs2StrAddr == NULL) {
-
     FreePool (Ucs2StrTemp);
     FreePool (Ucs2StrTemp);
     return EFI_OUT_OF_RESOURCES;
     return EFI_OUT_OF_RESOURCES;
   }
   }
@@ -418,4 +402,3 @@ UTF8StrToUCS2 (
 
 
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }
-

+ 66 - 58
RedfishPkg/Library/DxeRestExLib/DxeRestExLib.c

@@ -15,7 +15,7 @@
 #include <Protocol/Http.h>
 #include <Protocol/Http.h>
 #include <Protocol/RestEx.h>
 #include <Protocol/RestEx.h>
 
 
-#define REST_EX_CONFIG_DATA_LEN_UNKNOWN 0xff
+#define REST_EX_CONFIG_DATA_LEN_UNKNOWN  0xff
 
 
 /**
 /**
   This function allows the caller to create child handle for specific
   This function allows the caller to create child handle for specific
@@ -33,27 +33,28 @@
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RestExLibCreateChild (
 RestExLibCreateChild (
-  IN EFI_HANDLE Image,
+  IN EFI_HANDLE                       Image,
   IN EFI_REST_EX_SERVICE_ACCESS_MODE  AccessMode,
   IN EFI_REST_EX_SERVICE_ACCESS_MODE  AccessMode,
-  IN EFI_REST_EX_CONFIG_TYPE ConfigType,
-  IN EFI_REST_EX_SERVICE_TYPE ServiceType,
-  OUT EFI_HANDLE *ChildInstanceHandle
-)
+  IN EFI_REST_EX_CONFIG_TYPE          ConfigType,
+  IN EFI_REST_EX_SERVICE_TYPE         ServiceType,
+  OUT EFI_HANDLE                      *ChildInstanceHandle
+  )
 {
 {
-  EFI_STATUS Status;
-  UINTN NoBuffer;
-  EFI_HANDLE *Handle;
-  EFI_HANDLE ChildHandle;
-  EFI_REST_EX_PROTOCOL *RestEx;
-  EFI_REST_EX_SERVICE_INFO *RestExServiceInfo;
-  UINT8 LenOfConfig;
-
-  if (Image == NULL ||
-      AccessMode >= EfiRestExServiceModeMax ||
-      ConfigType >= EfiRestExConfigTypeMax ||
-      ServiceType >= EfiRestExServiceTypeMax ||
-      ChildInstanceHandle == NULL
-      ) {
+  EFI_STATUS                Status;
+  UINTN                     NoBuffer;
+  EFI_HANDLE                *Handle;
+  EFI_HANDLE                ChildHandle;
+  EFI_REST_EX_PROTOCOL      *RestEx;
+  EFI_REST_EX_SERVICE_INFO  *RestExServiceInfo;
+  UINT8                     LenOfConfig;
+
+  if ((Image == NULL) ||
+      (AccessMode >= EfiRestExServiceModeMax) ||
+      (ConfigType >= EfiRestExConfigTypeMax) ||
+      (ServiceType >= EfiRestExServiceTypeMax) ||
+      (ChildInstanceHandle == NULL)
+      )
+  {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
@@ -61,29 +62,31 @@ RestExLibCreateChild (
   //
   //
   // Locate all REST EX binding service.
   // Locate all REST EX binding service.
   //
   //
-  Handle = NULL;
+  Handle   = NULL;
   NoBuffer = 0;
   NoBuffer = 0;
-  Status = gBS->LocateHandleBuffer (
-              ByProtocol,
-              &gEfiRestExServiceBindingProtocolGuid,
-              NULL,
-              &NoBuffer,
-              &Handle
-            );
-  if (EFI_ERROR (Status) && Status != EFI_BUFFER_TOO_SMALL) {
+  Status   = gBS->LocateHandleBuffer (
+                    ByProtocol,
+                    &gEfiRestExServiceBindingProtocolGuid,
+                    NULL,
+                    &NoBuffer,
+                    &Handle
+                    );
+  if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
     return Status;
     return Status;
   }
   }
-  Handle = (EFI_HANDLE *)AllocateZeroPool (sizeof(EFI_HANDLE) * NoBuffer);
+
+  Handle = (EFI_HANDLE *)AllocateZeroPool (sizeof (EFI_HANDLE) * NoBuffer);
   if (Handle == NULL) {
   if (Handle == NULL) {
     return EFI_OUT_OF_RESOURCES;
     return EFI_OUT_OF_RESOURCES;
   }
   }
+
   Status = gBS->LocateHandleBuffer (
   Status = gBS->LocateHandleBuffer (
-              ByProtocol,
-              &gEfiRestExServiceBindingProtocolGuid,
-              NULL,
-              &NoBuffer,
-              &Handle
-            );
+                  ByProtocol,
+                  &gEfiRestExServiceBindingProtocolGuid,
+                  NULL,
+                  &NoBuffer,
+                  &Handle
+                  );
   if (EFI_ERROR (Status)) {
   if (EFI_ERROR (Status)) {
     FreePool (Handle);
     FreePool (Handle);
     return Status;
     return Status;
@@ -94,21 +97,21 @@ RestExLibCreateChild (
   //
   //
   while (NoBuffer != 0) {
   while (NoBuffer != 0) {
     ChildHandle = NULL;
     ChildHandle = NULL;
-    Status = NetLibCreateServiceChild (
-                *(Handle + (NoBuffer - 1)),
-                Image,
-                &gEfiRestExServiceBindingProtocolGuid,
-                &ChildHandle
-                );
+    Status      = NetLibCreateServiceChild (
+                    *(Handle + (NoBuffer - 1)),
+                    Image,
+                    &gEfiRestExServiceBindingProtocolGuid,
+                    &ChildHandle
+                    );
     if (!EFI_ERROR (Status)) {
     if (!EFI_ERROR (Status)) {
       Status = gBS->OpenProtocol (
       Status = gBS->OpenProtocol (
-                  ChildHandle,
-                  &gEfiRestExProtocolGuid,
-                  (VOID **)&RestEx,
-                  Image,
-                  NULL,
-                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
-                  );
+                      ChildHandle,
+                      &gEfiRestExProtocolGuid,
+                      (VOID **)&RestEx,
+                      Image,
+                      NULL,
+                      EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                      );
       if (EFI_ERROR (Status)) {
       if (EFI_ERROR (Status)) {
         goto ON_ERROR;
         goto ON_ERROR;
       }
       }
@@ -117,12 +120,13 @@ RestExLibCreateChild (
       // Get the information of REST service provided by this EFI REST EX driver
       // Get the information of REST service provided by this EFI REST EX driver
       //
       //
       Status = RestEx->GetService (
       Status = RestEx->GetService (
-                            RestEx,
-                            &RestExServiceInfo
-                            );
+                         RestEx,
+                         &RestExServiceInfo
+                         );
       if (EFI_ERROR (Status)) {
       if (EFI_ERROR (Status)) {
         goto ON_ERROR;
         goto ON_ERROR;
       }
       }
+
       //
       //
       // Check REST EX property.
       // Check REST EX property.
       //
       //
@@ -138,13 +142,16 @@ RestExLibCreateChild (
         default:
         default:
           goto ON_ERROR;
           goto ON_ERROR;
       }
       }
-      if (RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceAccessMode != AccessMode ||
-          RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceType != ServiceType ||
-          RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigType != ConfigType ||
-          ((LenOfConfig != REST_EX_CONFIG_DATA_LEN_UNKNOWN) && (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigDataLength != LenOfConfig))) {
+
+      if ((RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceAccessMode != AccessMode) ||
+          (RestExServiceInfo->EfiRestExServiceInfoV10.RestServiceType != ServiceType) ||
+          (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigType != ConfigType) ||
+          ((LenOfConfig != REST_EX_CONFIG_DATA_LEN_UNKNOWN) && (RestExServiceInfo->EfiRestExServiceInfoV10.RestExConfigDataLength != LenOfConfig)))
+      {
         goto ON_ERROR;
         goto ON_ERROR;
       }
       }
     }
     }
+
     //
     //
     // This is proper REST EX instance.
     // This is proper REST EX instance.
     //
     //
@@ -159,8 +166,9 @@ ON_ERROR:;
       &gEfiRestExServiceBindingProtocolGuid,
       &gEfiRestExServiceBindingProtocolGuid,
       ChildHandle
       ChildHandle
       );
       );
-    NoBuffer --;
-  };
+    NoBuffer--;
+  }
+
   FreePool (Handle);
   FreePool (Handle);
   return EFI_NOT_FOUND;
   return EFI_NOT_FOUND;
 }
 }

+ 116 - 113
RedfishPkg/Library/JsonLib/JsonLib.c

@@ -36,7 +36,7 @@ JsonValueInitArray (
   VOID
   VOID
   )
   )
 {
 {
-  return (EDKII_JSON_VALUE)json_array();
+  return (EDKII_JSON_VALUE)json_array ();
 }
 }
 
 
 /**
 /**
@@ -58,7 +58,7 @@ JsonValueInitObject (
   VOID
   VOID
   )
   )
 {
 {
-  return (EDKII_JSON_VALUE)json_object();
+  return (EDKII_JSON_VALUE)json_object ();
 }
 }
 
 
 /**
 /**
@@ -83,10 +83,10 @@ JsonValueInitObject (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonValueInitAsciiString (
 JsonValueInitAsciiString (
-  IN    CONST CHAR8    *String
+  IN    CONST CHAR8  *String
   )
   )
 {
 {
-  UINTN    Index;
+  UINTN  Index;
 
 
   if (String == NULL) {
   if (String == NULL) {
     return NULL;
     return NULL;
@@ -124,11 +124,11 @@ JsonValueInitAsciiString (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonValueInitUnicodeString (
 JsonValueInitUnicodeString (
-  IN    CHAR16    *String
+  IN    CHAR16  *String
   )
   )
 {
 {
-  EFI_STATUS    Status;
-  CHAR8         *Utf8Str;
+  EFI_STATUS  Status;
+  CHAR8       *Utf8Str;
 
 
   if (String == NULL) {
   if (String == NULL) {
     return NULL;
     return NULL;
@@ -160,7 +160,7 @@ JsonValueInitUnicodeString (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonValueInitInteger (
 JsonValueInitInteger (
-  IN    INT64    Value
+  IN    INT64  Value
   )
   )
 {
 {
   return (EDKII_JSON_VALUE)json_integer (Value);
   return (EDKII_JSON_VALUE)json_integer (Value);
@@ -180,7 +180,7 @@ JsonValueInitInteger (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonValueInitBoolean (
 JsonValueInitBoolean (
-  IN    BOOLEAN    Value
+  IN    BOOLEAN  Value
   )
   )
 {
 {
   return (EDKII_JSON_VALUE)json_boolean (Value);
   return (EDKII_JSON_VALUE)json_boolean (Value);
@@ -201,7 +201,7 @@ JsonValueInitTrue (
   VOID
   VOID
   )
   )
 {
 {
-  return (EDKII_JSON_VALUE)json_true();
+  return (EDKII_JSON_VALUE)json_true ();
 }
 }
 
 
 /**
 /**
@@ -219,7 +219,7 @@ JsonValueInitFalse (
   VOID
   VOID
   )
   )
 {
 {
-  return (EDKII_JSON_VALUE)json_false();
+  return (EDKII_JSON_VALUE)json_false ();
 }
 }
 
 
 /**
 /**
@@ -237,7 +237,7 @@ JsonValueInitNull (
   VOID
   VOID
   )
   )
 {
 {
-  return (EDKII_JSON_VALUE)json_null();
+  return (EDKII_JSON_VALUE)json_null ();
 }
 }
 
 
 /**
 /**
@@ -263,10 +263,10 @@ JsonValueInitNull (
 VOID
 VOID
 EFIAPI
 EFIAPI
 JsonValueFree (
 JsonValueFree (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
-  json_decref((json_t *)Json);
+  json_decref ((json_t *)Json);
 }
 }
 
 
 /**
 /**
@@ -289,10 +289,10 @@ JsonValueFree (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonValueClone (
 JsonValueClone (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
-  return (EDKII_JSON_VALUE)json_deep_copy ((json_t *) Json);
+  return (EDKII_JSON_VALUE)json_deep_copy ((json_t *)Json);
 }
 }
 
 
 /**
 /**
@@ -307,10 +307,10 @@ JsonValueClone (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsArray (
 JsonValueIsArray (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
-  return json_is_array ((json_t *) Json);
+  return json_is_array ((json_t *)Json);
 }
 }
 
 
 /**
 /**
@@ -325,10 +325,10 @@ JsonValueIsArray (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsObject (
 JsonValueIsObject (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
-  return json_is_object ((json_t *) Json);
+  return json_is_object ((json_t *)Json);
 }
 }
 
 
 /**
 /**
@@ -344,10 +344,10 @@ JsonValueIsObject (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsString (
 JsonValueIsString (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
-  return json_is_string ((json_t *) Json);
+  return json_is_string ((json_t *)Json);
 }
 }
 
 
 /**
 /**
@@ -362,10 +362,10 @@ JsonValueIsString (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsInteger (
 JsonValueIsInteger (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
-  return json_is_integer ((json_t *) Json);
+  return json_is_integer ((json_t *)Json);
 }
 }
 
 
 /**
 /**
@@ -380,10 +380,10 @@ JsonValueIsInteger (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsNumber (
 JsonValueIsNumber (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
-  return json_is_number ((json_t *) Json);
+  return json_is_number ((json_t *)Json);
 }
 }
 
 
 /**
 /**
@@ -398,10 +398,10 @@ JsonValueIsNumber (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsBoolean (
 JsonValueIsBoolean (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
-  return json_is_boolean ((json_t *) Json);
+  return json_is_boolean ((json_t *)Json);
 }
 }
 
 
 /**
 /**
@@ -416,12 +416,13 @@ JsonValueIsBoolean (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsTrue (
 JsonValueIsTrue (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
   if (json_is_true ((json_t *)Json)) {
   if (json_is_true ((json_t *)Json)) {
     return TRUE;
     return TRUE;
   }
   }
+
   return FALSE;
   return FALSE;
 }
 }
 
 
@@ -437,14 +438,16 @@ JsonValueIsTrue (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsFalse (
 JsonValueIsFalse (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
   if (json_is_false ((json_t *)Json)) {
   if (json_is_false ((json_t *)Json)) {
     return TRUE;
     return TRUE;
   }
   }
+
   return FALSE;
   return FALSE;
 }
 }
+
 /**
 /**
   The function is used to return if the provided JSON value contains a JSON NULL.
   The function is used to return if the provided JSON value contains a JSON NULL.
 
 
@@ -457,10 +460,10 @@ JsonValueIsFalse (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueIsNull (
 JsonValueIsNull (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
-  return json_is_null ((json_t *) Json);
+  return json_is_null ((json_t *)Json);
 }
 }
 
 
 /**
 /**
@@ -476,10 +479,10 @@ JsonValueIsNull (
 EDKII_JSON_ARRAY
 EDKII_JSON_ARRAY
 EFIAPI
 EFIAPI
 JsonValueGetArray (
 JsonValueGetArray (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
-  if (Json == NULL || !JsonValueIsArray (Json)) {
+  if ((Json == NULL) || !JsonValueIsArray (Json)) {
     return NULL;
     return NULL;
   }
   }
 
 
@@ -499,10 +502,10 @@ JsonValueGetArray (
 EDKII_JSON_OBJECT
 EDKII_JSON_OBJECT
 EFIAPI
 EFIAPI
 JsonValueGetObject (
 JsonValueGetObject (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
-  if (Json == NULL || !JsonValueIsObject (Json)) {
+  if ((Json == NULL) || !JsonValueIsObject (Json)) {
     return NULL;
     return NULL;
   }
   }
 
 
@@ -522,13 +525,13 @@ JsonValueGetObject (
 CONST CHAR8 *
 CONST CHAR8 *
 EFIAPI
 EFIAPI
 JsonValueGetAsciiString (
 JsonValueGetAsciiString (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
-  CONST CHAR8    *AsciiStr;
-  UINTN          Index;
+  CONST CHAR8  *AsciiStr;
+  UINTN        Index;
 
 
-  AsciiStr = json_string_value ((json_t *) Json);
+  AsciiStr = json_string_value ((json_t *)Json);
   if (AsciiStr == NULL) {
   if (AsciiStr == NULL) {
     return NULL;
     return NULL;
   }
   }
@@ -556,22 +559,22 @@ JsonValueGetAsciiString (
   @retval      Return the associated Unicode string in JSON value or NULL.
   @retval      Return the associated Unicode string in JSON value or NULL.
 
 
 **/
 **/
-CHAR16*
+CHAR16 *
 EFIAPI
 EFIAPI
 JsonValueGetUnicodeString (
 JsonValueGetUnicodeString (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
-  EFI_STATUS     Status;
-  CONST CHAR8    *Utf8Str;
-  CHAR16         *Ucs2Str;
+  EFI_STATUS   Status;
+  CONST CHAR8  *Utf8Str;
+  CHAR16       *Ucs2Str;
 
 
-  Utf8Str = json_string_value ((json_t *) Json);
+  Utf8Str = json_string_value ((json_t *)Json);
   if (Utf8Str == NULL) {
   if (Utf8Str == NULL) {
     return NULL;
     return NULL;
   }
   }
 
 
-  Status = UTF8StrToUCS2 ((CHAR8*)Utf8Str, &Ucs2Str);
+  Status = UTF8StrToUCS2 ((CHAR8 *)Utf8Str, &Ucs2Str);
   if (EFI_ERROR (Status)) {
   if (EFI_ERROR (Status)) {
     return NULL;
     return NULL;
   }
   }
@@ -593,15 +596,15 @@ JsonValueGetUnicodeString (
 INT64
 INT64
 EFIAPI
 EFIAPI
 JsonValueGetInteger (
 JsonValueGetInteger (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
   ASSERT (Json != NULL && JsonValueIsInteger (Json));
   ASSERT (Json != NULL && JsonValueIsInteger (Json));
-  if (Json == NULL || !JsonValueIsInteger (Json)) {
+  if ((Json == NULL) || !JsonValueIsInteger (Json)) {
     return 0;
     return 0;
   }
   }
 
 
-  return json_integer_value ((json_t *) Json);
+  return json_integer_value ((json_t *)Json);
 }
 }
 
 
 /**
 /**
@@ -618,15 +621,15 @@ JsonValueGetInteger (
 BOOLEAN
 BOOLEAN
 EFIAPI
 EFIAPI
 JsonValueGetBoolean (
 JsonValueGetBoolean (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
   ASSERT (Json != NULL && JsonValueIsBoolean (Json));
   ASSERT (Json != NULL && JsonValueIsBoolean (Json));
-  if (Json == NULL || !JsonValueIsBoolean (Json)) {
+  if ((Json == NULL) || !JsonValueIsBoolean (Json)) {
     return FALSE;
     return FALSE;
   }
   }
 
 
-  return json_is_true ((json_t *) Json);
+  return json_is_true ((json_t *)Json);
 }
 }
 
 
 /**
 /**
@@ -639,10 +642,10 @@ JsonValueGetBoolean (
   @retval      Return the associated Ascii string in JSON value or NULL on errors.
   @retval      Return the associated Ascii string in JSON value or NULL on errors.
 
 
 **/
 **/
-CONST CHAR8*
+CONST CHAR8 *
 EFIAPI
 EFIAPI
 JsonValueGetString (
 JsonValueGetString (
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
   return json_string_value ((const json_t *)Json);
   return json_string_value ((const json_t *)Json);
@@ -660,10 +663,10 @@ JsonValueGetString (
 UINTN
 UINTN
 EFIAPI
 EFIAPI
 JsonObjectSize (
 JsonObjectSize (
-  IN    EDKII_JSON_OBJECT    JsonObject
+  IN    EDKII_JSON_OBJECT  JsonObject
   )
   )
 {
 {
-  return json_object_size ((json_t *) JsonObject);
+  return json_object_size ((json_t *)JsonObject);
 }
 }
 
 
 /**
 /**
@@ -679,24 +682,23 @@ JsonObjectSize (
                JsonObj is not an JSON object, key count is zero or on other errors.
                JsonObj is not an JSON object, key count is zero or on other errors.
 
 
 **/
 **/
-CHAR8**
+CHAR8 **
 JsonObjectGetKeys (
 JsonObjectGetKeys (
-  IN    EDKII_JSON_OBJECT    JsonObj,
-  OUT   UINTN                *KeyCount
+  IN    EDKII_JSON_OBJECT  JsonObj,
+  OUT   UINTN              *KeyCount
   )
   )
 {
 {
+  UINTN             Index;
+  CONST CHAR8       **KeyArray;
+  CONST CHAR8       *Key;
+  EDKII_JSON_VALUE  Value;
 
 
-  UINTN               Index;
-  CONST CHAR8         **KeyArray;
-  CONST CHAR8         *Key;
-  EDKII_JSON_VALUE    Value;
-
-  if (JsonObj == NULL || KeyCount == NULL) {
+  if ((JsonObj == NULL) || (KeyCount == NULL)) {
     return NULL;
     return NULL;
   }
   }
 
 
   Index = 0;
   Index = 0;
-  json_object_foreach(JsonObj, Key, Value) {
+  json_object_foreach (JsonObj, Key, Value) {
     Index++;
     Index++;
   }
   }
   if (Index == 0) {
   if (Index == 0) {
@@ -705,7 +707,7 @@ JsonObjectGetKeys (
   }
   }
 
 
   *KeyCount = Index;
   *KeyCount = Index;
-  KeyArray = (CONST CHAR8 **) AllocateZeroPool (*KeyCount * sizeof (CHAR8 *));
+  KeyArray  = (CONST CHAR8 **)AllocateZeroPool (*KeyCount * sizeof (CHAR8 *));
   if (KeyArray == NULL) {
   if (KeyArray == NULL) {
     return NULL;
     return NULL;
   }
   }
@@ -713,7 +715,7 @@ JsonObjectGetKeys (
   Key   = NULL;
   Key   = NULL;
   Value = NULL;
   Value = NULL;
   Index = 0;
   Index = 0;
-  json_object_foreach((json_t *) JsonObj, Key, Value) {
+  json_object_foreach ((json_t *)JsonObj, Key, Value) {
     KeyArray[Index] = Key;
     KeyArray[Index] = Key;
     Index++;
     Index++;
   }
   }
@@ -740,8 +742,8 @@ JsonObjectGetKeys (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonObjectGetValue (
 JsonObjectGetValue (
-  IN    CONST EDKII_JSON_OBJECT    JsonObj,
-  IN    CONST CHAR8                *Key
+  IN    CONST EDKII_JSON_OBJECT  JsonObj,
+  IN    CONST CHAR8              *Key
   )
   )
 {
 {
   return (EDKII_JSON_VALUE)json_object_get ((const json_t *)JsonObj, (const char *)Key);
   return (EDKII_JSON_VALUE)json_object_get ((const json_t *)JsonObj, (const char *)Key);
@@ -768,12 +770,12 @@ JsonObjectGetValue (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 JsonObjectSetValue (
 JsonObjectSetValue (
-  IN    EDKII_JSON_OBJECT    JsonObj,
-  IN    CONST CHAR8          *Key,
-  IN    EDKII_JSON_VALUE     Json
+  IN    EDKII_JSON_OBJECT  JsonObj,
+  IN    CONST CHAR8        *Key,
+  IN    EDKII_JSON_VALUE   Json
   )
   )
 {
 {
-  if (json_object_set ((json_t *) JsonObj, Key, (json_t *) Json) != 0) {
+  if (json_object_set ((json_t *)JsonObj, Key, (json_t *)Json) != 0) {
     return EFI_ABORTED;
     return EFI_ABORTED;
   } else {
   } else {
     return EFI_SUCCESS;
     return EFI_SUCCESS;
@@ -792,10 +794,10 @@ JsonObjectSetValue (
 UINTN
 UINTN
 EFIAPI
 EFIAPI
 JsonArrayCount (
 JsonArrayCount (
-  IN    EDKII_JSON_ARRAY    JsonArray
+  IN    EDKII_JSON_ARRAY  JsonArray
   )
   )
 {
 {
-  return json_array_size ((json_t *) JsonArray);
+  return json_array_size ((json_t *)JsonArray);
 }
 }
 
 
 /**
 /**
@@ -817,11 +819,11 @@ JsonArrayCount (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonArrayGetValue (
 JsonArrayGetValue (
-  IN    EDKII_JSON_ARRAY    JsonArray,
-  IN    UINTN               Index
+  IN    EDKII_JSON_ARRAY  JsonArray,
+  IN    UINTN             Index
   )
   )
 {
 {
-  return (EDKII_JSON_VALUE)json_array_get ((json_t *) JsonArray, Index);
+  return (EDKII_JSON_VALUE)json_array_get ((json_t *)JsonArray, Index);
 }
 }
 
 
 /**
 /**
@@ -840,11 +842,11 @@ JsonArrayGetValue (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 JsonArrayAppendValue (
 JsonArrayAppendValue (
-  IN    EDKII_JSON_ARRAY    JsonArray,
-  IN    EDKII_JSON_VALUE    Json
+  IN    EDKII_JSON_ARRAY  JsonArray,
+  IN    EDKII_JSON_VALUE  Json
   )
   )
 {
 {
-  if (json_array_append ((json_t *) JsonArray, (json_t *) Json) != 0) {
+  if (json_array_append ((json_t *)JsonArray, (json_t *)Json) != 0) {
     return EFI_ABORTED;
     return EFI_ABORTED;
   } else {
   } else {
     return EFI_SUCCESS;
     return EFI_SUCCESS;
@@ -868,11 +870,11 @@ JsonArrayAppendValue (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 JsonArrayRemoveValue (
 JsonArrayRemoveValue (
-  IN    EDKII_JSON_ARRAY    JsonArray,
-  IN    UINTN               Index
+  IN    EDKII_JSON_ARRAY  JsonArray,
+  IN    UINTN             Index
   )
   )
 {
 {
-  if (json_array_remove ((json_t *) JsonArray, Index) != 0) {
+  if (json_array_remove ((json_t *)JsonArray, Index) != 0) {
     return EFI_ABORTED;
     return EFI_ABORTED;
   } else {
   } else {
     return EFI_SUCCESS;
     return EFI_SUCCESS;
@@ -904,14 +906,15 @@ JsonArrayRemoveValue (
 CHAR8 *
 CHAR8 *
 EFIAPI
 EFIAPI
 JsonDumpString (
 JsonDumpString (
-  IN    EDKII_JSON_VALUE    JsonValue,
-  IN    UINTN               Flags
+  IN    EDKII_JSON_VALUE  JsonValue,
+  IN    UINTN             Flags
   )
   )
 {
 {
-    if (JsonValue == NULL) {
-      return NULL;
-    }
-    return json_dumps((json_t *)JsonValue, Flags);
+  if (JsonValue == NULL) {
+    return NULL;
+  }
+
+  return json_dumps ((json_t *)JsonValue, Flags);
 }
 }
 
 
 /**
 /**
@@ -934,12 +937,12 @@ JsonDumpString (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonLoadString (
 JsonLoadString (
-  IN    CONST CHAR8*     String,
-  IN    UINT64           Flags,
-  IN    EDKII_JSON_ERROR *Error
+  IN    CONST CHAR8       *String,
+  IN    UINT64            Flags,
+  IN    EDKII_JSON_ERROR  *Error
   )
   )
 {
 {
-  return (EDKII_JSON_VALUE) json_loads ((const char *)String, Flags, (json_error_t *)Error);
+  return (EDKII_JSON_VALUE)json_loads ((const char *)String, Flags, (json_error_t *)Error);
 }
 }
 
 
 /**
 /**
@@ -964,13 +967,13 @@ JsonLoadString (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonLoadBuffer (
 JsonLoadBuffer (
-  IN    CONST CHAR8       *Buffer,
+  IN    CONST CHAR8        *Buffer,
   IN    UINTN              BufferLen,
   IN    UINTN              BufferLen,
   IN    UINTN              Flags,
   IN    UINTN              Flags,
   IN OUT EDKII_JSON_ERROR  *Error
   IN OUT EDKII_JSON_ERROR  *Error
   )
   )
 {
 {
-  return json_loadb(Buffer, BufferLen, Flags, (json_error_t *)Error);
+  return json_loadb (Buffer, BufferLen, Flags, (json_error_t *)Error);
 }
 }
 
 
 /**
 /**
@@ -989,7 +992,7 @@ JsonLoadBuffer (
 VOID
 VOID
 EFIAPI
 EFIAPI
 JsonDecreaseReference (
 JsonDecreaseReference (
-  IN EDKII_JSON_VALUE JsonValue
+  IN EDKII_JSON_VALUE  JsonValue
   )
   )
 {
 {
   json_decref (JsonValue);
   json_decref (JsonValue);
@@ -1010,7 +1013,7 @@ JsonDecreaseReference (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonIncreaseReference (
 JsonIncreaseReference (
-  IN EDKII_JSON_VALUE JsonValue
+  IN EDKII_JSON_VALUE  JsonValue
   )
   )
 {
 {
   return json_incref (JsonValue);
   return json_incref (JsonValue);
@@ -1026,7 +1029,7 @@ JsonIncreaseReference (
 VOID *
 VOID *
 EFIAPI
 EFIAPI
 JsonObjectIterator (
 JsonObjectIterator (
-  IN EDKII_JSON_VALUE JsonValue
+  IN EDKII_JSON_VALUE  JsonValue
   )
   )
 {
 {
   return json_object_iter (JsonValue);
   return json_object_iter (JsonValue);
@@ -1041,10 +1044,10 @@ JsonObjectIterator (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 JsonObjectIteratorValue (
 JsonObjectIteratorValue (
-  IN VOID *Iterator
+  IN VOID  *Iterator
   )
   )
 {
 {
-  return json_object_iter_value(Iterator);
+  return json_object_iter_value (Iterator);
 }
 }
 
 
 /**
 /**
@@ -1058,11 +1061,11 @@ JsonObjectIteratorValue (
 VOID *
 VOID *
 EFIAPI
 EFIAPI
 JsonObjectIteratorNext (
 JsonObjectIteratorNext (
-  IN EDKII_JSON_VALUE JsonValue,
-  IN VOID             *Iterator
+  IN EDKII_JSON_VALUE  JsonValue,
+  IN VOID              *Iterator
   )
   )
 {
 {
-  return json_object_iter_next(JsonValue, Iterator);
+  return json_object_iter_next (JsonValue, Iterator);
 }
 }
 
 
 /**
 /**
@@ -1074,10 +1077,10 @@ JsonObjectIteratorNext (
 CHAR8 *
 CHAR8 *
 EFIAPI
 EFIAPI
 JsonObjectIteratorKey (
 JsonObjectIteratorKey (
-  IN VOID *Iterator
-)
+  IN VOID  *Iterator
+  )
 {
 {
-  return (CHAR8 *)json_object_iter_key(Iterator);
+  return (CHAR8 *)json_object_iter_key (Iterator);
 }
 }
 
 
 /**
 /**
@@ -1089,10 +1092,10 @@ JsonObjectIteratorKey (
 VOID *
 VOID *
 EFIAPI
 EFIAPI
 JsonObjectKeyToIterator (
 JsonObjectKeyToIterator (
-  IN CHAR8 *Key
-)
+  IN CHAR8  *Key
+  )
 {
 {
-  return json_object_key_to_iter(Key);
+  return json_object_key_to_iter (Key);
 }
 }
 
 
 /**
 /**
@@ -1104,7 +1107,7 @@ JsonObjectKeyToIterator (
 EDKII_JSON_TYPE
 EDKII_JSON_TYPE
 EFIAPI
 EFIAPI
 JsonGetType (
 JsonGetType (
-  IN EDKII_JSON_VALUE JsonValue
+  IN EDKII_JSON_VALUE  JsonValue
   )
   )
 {
 {
   return ((json_t *)JsonValue)->type;
   return ((json_t *)JsonValue)->type;

+ 5 - 5
RedfishPkg/Library/JsonLib/jansson_config.h

@@ -16,26 +16,26 @@
 ///
 ///
 /// We support long long on edk2
 /// We support long long on edk2
 ///
 ///
-#define JSON_INTEGER_IS_LONG_LONG 1
+#define JSON_INTEGER_IS_LONG_LONG  1
 
 
 ///
 ///
 /// We don't support locale on edk2
 /// We don't support locale on edk2
 ///
 ///
-#define JSON_HAVE_LOCALECONV 0
+#define JSON_HAVE_LOCALECONV  0
 
 
 ///
 ///
 /// We don't support atomic builtins on edk2
 /// We don't support atomic builtins on edk2
 ///
 ///
-#define JSON_HAVE_ATOMIC_BUILTINS 0
+#define JSON_HAVE_ATOMIC_BUILTINS  0
 
 
 ///
 ///
 /// We don't support sync builtins on edk2
 /// We don't support sync builtins on edk2
 ///
 ///
-#define JSON_HAVE_SYNC_BUILTINS 0
+#define JSON_HAVE_SYNC_BUILTINS  0
 
 
 ///
 ///
 /// Mzximum deepth is set to 2048
 /// Mzximum deepth is set to 2048
 ///
 ///
-#define JSON_PARSER_MAX_DEPTH 2048
+#define JSON_PARSER_MAX_DEPTH  2048
 
 
 #endif
 #endif

+ 3 - 3
RedfishPkg/Library/JsonLib/jansson_private_config.h

@@ -11,9 +11,9 @@
 #ifndef JANSSON_PRIVATE_CONFIG_H_
 #ifndef JANSSON_PRIVATE_CONFIG_H_
 #define JANSSON_PRIVATE_CONFIG_H_
 #define JANSSON_PRIVATE_CONFIG_H_
 
 
-#define HAVE_SYS_TIME_H 1
-#define HAVE_SYS_TYPES_H 1
+#define HAVE_SYS_TIME_H   1
+#define HAVE_SYS_TYPES_H  1
 
 
-#define INITIAL_HASHTABLE_ORDER 3
+#define INITIAL_HASHTABLE_ORDER  3
 
 
 #endif
 #endif

+ 1161 - 849
RedfishPkg/Library/JsonLib/load.c

@@ -22,1090 +22,1402 @@
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
 #ifdef HAVE_UNISTD_H
 #ifdef HAVE_UNISTD_H
-#include <unistd.h>
+  #include <unistd.h>
 #endif
 #endif
 
 
 #include "jansson.h"
 #include "jansson.h"
 #include "strbuffer.h"
 #include "strbuffer.h"
 #include "utf.h"
 #include "utf.h"
 
 
-#define STREAM_STATE_OK    0
-#define STREAM_STATE_EOF   -1
-#define STREAM_STATE_ERROR -2
+#define STREAM_STATE_OK     0
+#define STREAM_STATE_EOF    -1
+#define STREAM_STATE_ERROR  -2
 
 
-#define TOKEN_INVALID -1
-#define TOKEN_EOF     0
-#define TOKEN_STRING  256
-#define TOKEN_INTEGER 257
-#define TOKEN_REAL    258
-#define TOKEN_TRUE    259
-#define TOKEN_FALSE   260
-#define TOKEN_NULL    261
+#define TOKEN_INVALID  -1
+#define TOKEN_EOF      0
+#define TOKEN_STRING   256
+#define TOKEN_INTEGER  257
+#define TOKEN_REAL     258
+#define TOKEN_TRUE     259
+#define TOKEN_FALSE    260
+#define TOKEN_NULL     261
 
 
 /* Locale independent versions of isxxx() functions */
 /* Locale independent versions of isxxx() functions */
-#define l_isupper(c) ('A' <= (c) && (c) <= 'Z')
-#define l_islower(c) ('a' <= (c) && (c) <= 'z')
-#define l_isalpha(c) (l_isupper(c) || l_islower(c))
-#define l_isdigit(c) ('0' <= (c) && (c) <= '9')
+#define l_isupper(c)  ('A' <= (c) && (c) <= 'Z')
+#define l_islower(c)  ('a' <= (c) && (c) <= 'z')
+#define l_isalpha(c)  (l_isupper(c) || l_islower(c))
+#define l_isdigit(c)  ('0' <= (c) && (c) <= '9')
 #define l_isxdigit(c)                                                                    \
 #define l_isxdigit(c)                                                                    \
     (l_isdigit(c) || ('A' <= (c) && (c) <= 'F') || ('a' <= (c) && (c) <= 'f'))
     (l_isdigit(c) || ('A' <= (c) && (c) <= 'F') || ('a' <= (c) && (c) <= 'f'))
 
 
 /* Read one byte from stream, convert to unsigned char, then int, and
 /* Read one byte from stream, convert to unsigned char, then int, and
    return. return EOF on end of file. This corresponds to the
    return. return EOF on end of file. This corresponds to the
    behaviour of fgetc(). */
    behaviour of fgetc(). */
-typedef int (*get_func)(void *data);
+typedef int (*get_func)(
+  void  *data
+  );
 
 
 typedef struct {
 typedef struct {
-    get_func get;
-    void *data;
-    char buffer[5];
-    size_t buffer_pos;
-    int state;
-    int line;
-    int column, last_column;
-    size_t position;
+  get_func    get;
+  void        *data;
+  char        buffer[5];
+  size_t      buffer_pos;
+  int         state;
+  int         line;
+  int         column, last_column;
+  size_t      position;
 } stream_t;
 } stream_t;
 
 
 typedef struct {
 typedef struct {
-    stream_t stream;
-    strbuffer_t saved_text;
-    size_t flags;
-    size_t depth;
-    int token;
-    union {
-        struct {
-            char *val;
-            size_t len;
-        } string;
-        json_int_t integer;
-        double real;
-    } value;
+  stream_t       stream;
+  strbuffer_t    saved_text;
+  size_t         flags;
+  size_t         depth;
+  int            token;
+  union {
+    struct {
+      char      *val;
+      size_t    len;
+    } string;
+    json_int_t    integer;
+    double        real;
+  } value;
 } lex_t;
 } lex_t;
 
 
-#define stream_to_lex(stream) container_of(stream, lex_t, stream)
+#define stream_to_lex(stream)  container_of(stream, lex_t, stream)
 
 
 /*** error reporting ***/
 /*** error reporting ***/
 
 
-static void error_set(json_error_t *error, const lex_t *lex, enum json_error_code code,
-                      const char *msg, ...) {
-    va_list ap;
-    char msg_text[JSON_ERROR_TEXT_LENGTH];
-    char msg_with_context[JSON_ERROR_TEXT_LENGTH];
-
-    int line = -1, col = -1;
-    size_t pos = 0;
-    const char *result = msg_text;
-
-    if (!error)
-        return;
-
-    va_start(ap, msg);
-    vsnprintf(msg_text, JSON_ERROR_TEXT_LENGTH, msg, ap);
-    msg_text[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
-    va_end(ap);
-
-    if (lex) {
-        const char *saved_text = strbuffer_value(&lex->saved_text);
-
-        line = lex->stream.line;
-        col = lex->stream.column;
-        pos = lex->stream.position;
-
-        if (saved_text && saved_text[0]) {
-            if (lex->saved_text.length <= 20) {
-                snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH, "%s near '%s'",
-                         msg_text, saved_text);
-                msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
-                result = msg_with_context;
-            }
-        } else {
-            if (code == json_error_invalid_syntax) {
-                /* More specific error code for premature end of file. */
-                code = json_error_premature_end_of_input;
-            }
-            if (lex->stream.state == STREAM_STATE_ERROR) {
-                /* No context for UTF-8 decoding errors */
-                result = msg_text;
-            } else {
-                snprintf(msg_with_context, JSON_ERROR_TEXT_LENGTH, "%s near end of file",
-                         msg_text);
-                msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
-                result = msg_with_context;
-            }
-        }
+static void
+error_set (
+  json_error_t          *error,
+  const lex_t           *lex,
+  enum json_error_code  code,
+  const char            *msg,
+  ...
+  )
+{
+  va_list  ap;
+  char     msg_text[JSON_ERROR_TEXT_LENGTH];
+  char     msg_with_context[JSON_ERROR_TEXT_LENGTH];
+
+  int         line = -1, col = -1;
+  size_t      pos     = 0;
+  const char  *result = msg_text;
+
+  if (!error) {
+    return;
+  }
+
+  va_start (ap, msg);
+  vsnprintf (msg_text, JSON_ERROR_TEXT_LENGTH, msg, ap);
+  msg_text[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
+  va_end (ap);
+
+  if (lex) {
+    const char  *saved_text = strbuffer_value (&lex->saved_text);
+
+    line = lex->stream.line;
+    col  = lex->stream.column;
+    pos  = lex->stream.position;
+
+    if (saved_text && saved_text[0]) {
+      if (lex->saved_text.length <= 20) {
+        snprintf (
+          msg_with_context,
+          JSON_ERROR_TEXT_LENGTH,
+          "%s near '%s'",
+          msg_text,
+          saved_text
+          );
+        msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
+        result                                       = msg_with_context;
+      }
+    } else {
+      if (code == json_error_invalid_syntax) {
+        /* More specific error code for premature end of file. */
+        code = json_error_premature_end_of_input;
+      }
+
+      if (lex->stream.state == STREAM_STATE_ERROR) {
+        /* No context for UTF-8 decoding errors */
+        result = msg_text;
+      } else {
+        snprintf (
+          msg_with_context,
+          JSON_ERROR_TEXT_LENGTH,
+          "%s near end of file",
+          msg_text
+          );
+        msg_with_context[JSON_ERROR_TEXT_LENGTH - 1] = '\0';
+        result                                       = msg_with_context;
+      }
     }
     }
+  }
 
 
-    jsonp_error_set(error, line, col, pos, code, "%s", result);
+  jsonp_error_set (error, line, col, pos, code, "%s", result);
 }
 }
 
 
 /*** lexical analyzer ***/
 /*** lexical analyzer ***/
 
 
-static void stream_init(stream_t *stream, get_func get, void *data) {
-    stream->get = get;
-    stream->data = data;
-    stream->buffer[0] = '\0';
-    stream->buffer_pos = 0;
-
-    stream->state = STREAM_STATE_OK;
-    stream->line = 1;
-    stream->column = 0;
-    stream->position = 0;
+static void
+stream_init (
+  stream_t  *stream,
+  get_func  get,
+  void      *data
+  )
+{
+  stream->get        = get;
+  stream->data       = data;
+  stream->buffer[0]  = '\0';
+  stream->buffer_pos = 0;
+
+  stream->state    = STREAM_STATE_OK;
+  stream->line     = 1;
+  stream->column   = 0;
+  stream->position = 0;
 }
 }
 
 
-static int stream_get(stream_t *stream, json_error_t *error) {
-    int c;
-
-    if (stream->state != STREAM_STATE_OK)
-        return stream->state;
-
-    if (!stream->buffer[stream->buffer_pos]) {
-        c = stream->get(stream->data);
-        if (c == EOF) {
-            stream->state = STREAM_STATE_EOF;
-            return STREAM_STATE_EOF;
-        }
+static int
+stream_get (
+  stream_t      *stream,
+  json_error_t  *error
+  )
+{
+  int  c;
+
+  if (stream->state != STREAM_STATE_OK) {
+    return stream->state;
+  }
+
+  if (!stream->buffer[stream->buffer_pos]) {
+    c = stream->get (stream->data);
+    if (c == EOF) {
+      stream->state = STREAM_STATE_EOF;
+      return STREAM_STATE_EOF;
+    }
 
 
-        stream->buffer[0] = c;
-        stream->buffer_pos = 0;
+    stream->buffer[0]  = c;
+    stream->buffer_pos = 0;
 
 
-        if (0x80 <= c && c <= 0xFF) {
-            /* multi-byte UTF-8 sequence */
-            size_t i, count;
+    if ((0x80 <= c) && (c <= 0xFF)) {
+      /* multi-byte UTF-8 sequence */
+      size_t  i, count;
 
 
-            count = utf8_check_first(c);
-            if (!count)
-                goto out;
+      count = utf8_check_first (c);
+      if (!count) {
+        goto out;
+      }
 
 
-            assert(count >= 2);
+      assert (count >= 2);
 
 
-            for (i = 1; i < count; i++)
-                stream->buffer[i] = stream->get(stream->data);
+      for (i = 1; i < count; i++) {
+        stream->buffer[i] = stream->get (stream->data);
+      }
 
 
-            if (!utf8_check_full(stream->buffer, count, NULL))
-                goto out;
+      if (!utf8_check_full (stream->buffer, count, NULL)) {
+        goto out;
+      }
 
 
-            stream->buffer[count] = '\0';
-        } else
-            stream->buffer[1] = '\0';
+      stream->buffer[count] = '\0';
+    } else {
+      stream->buffer[1] = '\0';
     }
     }
+  }
 
 
-    c = stream->buffer[stream->buffer_pos++];
-
-    stream->position++;
-    if (c == '\n') {
-        stream->line++;
-        stream->last_column = stream->column;
-        stream->column = 0;
-    } else if (utf8_check_first(c)) {
-        /* track the Unicode character column, so increment only if
-           this is the first character of a UTF-8 sequence */
-        stream->column++;
-    }
+  c = stream->buffer[stream->buffer_pos++];
 
 
-    return c;
+  stream->position++;
+  if (c == '\n') {
+    stream->line++;
+    stream->last_column = stream->column;
+    stream->column      = 0;
+  } else if (utf8_check_first (c)) {
+    /* track the Unicode character column, so increment only if
+       this is the first character of a UTF-8 sequence */
+    stream->column++;
+  }
+
+  return c;
 
 
 out:
 out:
-    stream->state = STREAM_STATE_ERROR;
-    error_set(error, stream_to_lex(stream), json_error_invalid_utf8,
-              "unable to decode byte 0x%x", c);
-    return STREAM_STATE_ERROR;
+  stream->state = STREAM_STATE_ERROR;
+  error_set (
+    error,
+    stream_to_lex (stream),
+    json_error_invalid_utf8,
+    "unable to decode byte 0x%x",
+    c
+    );
+  return STREAM_STATE_ERROR;
 }
 }
 
 
-static void stream_unget(stream_t *stream, int c) {
-    if (c == STREAM_STATE_EOF || c == STREAM_STATE_ERROR)
-        return;
-
-    stream->position--;
-    if (c == '\n') {
-        stream->line--;
-        stream->column = stream->last_column;
-    } else if (utf8_check_first(c))
-        stream->column--;
+static void
+stream_unget (
+  stream_t  *stream,
+  int       c
+  )
+{
+  if ((c == STREAM_STATE_EOF) || (c == STREAM_STATE_ERROR)) {
+    return;
+  }
+
+  stream->position--;
+  if (c == '\n') {
+    stream->line--;
+    stream->column = stream->last_column;
+  } else if (utf8_check_first (c)) {
+    stream->column--;
+  }
+
+  assert (stream->buffer_pos > 0);
+  stream->buffer_pos--;
+  assert (stream->buffer[stream->buffer_pos] == c);
+}
 
 
-    assert(stream->buffer_pos > 0);
-    stream->buffer_pos--;
-    assert(stream->buffer[stream->buffer_pos] == c);
+static int
+lex_get (
+  lex_t         *lex,
+  json_error_t  *error
+  )
+{
+  return stream_get (&lex->stream, error);
 }
 }
 
 
-static int lex_get(lex_t *lex, json_error_t *error) {
-    return stream_get(&lex->stream, error);
+static void
+lex_save (
+  lex_t  *lex,
+  int    c
+  )
+{
+  strbuffer_append_byte (&lex->saved_text, c);
 }
 }
 
 
-static void lex_save(lex_t *lex, int c) { strbuffer_append_byte(&lex->saved_text, c); }
+static int
+lex_get_save (
+  lex_t         *lex,
+  json_error_t  *error
+  )
+{
+  int  c = stream_get (&lex->stream, error);
 
 
-static int lex_get_save(lex_t *lex, json_error_t *error) {
-    int c = stream_get(&lex->stream, error);
-    if (c != STREAM_STATE_EOF && c != STREAM_STATE_ERROR)
-        lex_save(lex, c);
-    return c;
+  if ((c != STREAM_STATE_EOF) && (c != STREAM_STATE_ERROR)) {
+    lex_save (lex, c);
+  }
+
+  return c;
 }
 }
 
 
-static void lex_unget(lex_t *lex, int c) { stream_unget(&lex->stream, c); }
+static void
+lex_unget (
+  lex_t  *lex,
+  int    c
+  )
+{
+  stream_unget (&lex->stream, c);
+}
 
 
-static void lex_unget_unsave(lex_t *lex, int c) {
-    if (c != STREAM_STATE_EOF && c != STREAM_STATE_ERROR) {
-/* Since we treat warnings as errors, when assertions are turned
- * off the "d" variable would be set but never used. Which is
- * treated as an error by GCC.
- */
-#ifndef NDEBUG
-        char d;
-#endif
-        stream_unget(&lex->stream, c);
-#ifndef NDEBUG
-        d =
-#endif
-            strbuffer_pop(&lex->saved_text);
-        assert(c == d);
-    }
+static void
+lex_unget_unsave (
+  lex_t  *lex,
+  int    c
+  )
+{
+  if ((c != STREAM_STATE_EOF) && (c != STREAM_STATE_ERROR)) {
+    /* Since we treat warnings as errors, when assertions are turned
+     * off the "d" variable would be set but never used. Which is
+     * treated as an error by GCC.
+     */
+ #ifndef NDEBUG
+    char  d;
+ #endif
+    stream_unget (&lex->stream, c);
+ #ifndef NDEBUG
+    d =
+ #endif
+    strbuffer_pop (&lex->saved_text);
+    assert (c == d);
+  }
 }
 }
 
 
-static void lex_save_cached(lex_t *lex) {
-    while (lex->stream.buffer[lex->stream.buffer_pos] != '\0') {
-        lex_save(lex, lex->stream.buffer[lex->stream.buffer_pos]);
-        lex->stream.buffer_pos++;
-        lex->stream.position++;
-    }
+static void
+lex_save_cached (
+  lex_t  *lex
+  )
+{
+  while (lex->stream.buffer[lex->stream.buffer_pos] != '\0') {
+    lex_save (lex, lex->stream.buffer[lex->stream.buffer_pos]);
+    lex->stream.buffer_pos++;
+    lex->stream.position++;
+  }
 }
 }
 
 
-static void lex_free_string(lex_t *lex) {
-    jsonp_free(lex->value.string.val);
-    lex->value.string.val = NULL;
-    lex->value.string.len = 0;
+static void
+lex_free_string (
+  lex_t  *lex
+  )
+{
+  jsonp_free (lex->value.string.val);
+  lex->value.string.val = NULL;
+  lex->value.string.len = 0;
 }
 }
 
 
 /* assumes that str points to 'u' plus at least 4 valid hex digits */
 /* assumes that str points to 'u' plus at least 4 valid hex digits */
-static int32_t decode_unicode_escape(const char *str) {
-    int i;
-    int32_t value = 0;
-
-    assert(str[0] == 'u');
-
-    for (i = 1; i <= 4; i++) {
-        char c = str[i];
-        value <<= 4;
-        if (l_isdigit(c))
-            value += c - '0';
-        else if (l_islower(c))
-            value += c - 'a' + 10;
-        else if (l_isupper(c))
-            value += c - 'A' + 10;
-        else
-            return -1;
+static int32_t
+decode_unicode_escape (
+  const char  *str
+  )
+{
+  int      i;
+  int32_t  value = 0;
+
+  assert (str[0] == 'u');
+
+  for (i = 1; i <= 4; i++) {
+    char  c = str[i];
+    value <<= 4;
+    if (l_isdigit (c)) {
+      value += c - '0';
+    } else if (l_islower (c)) {
+      value += c - 'a' + 10;
+    } else if (l_isupper (c)) {
+      value += c - 'A' + 10;
+    } else {
+      return -1;
     }
     }
+  }
 
 
-    return value;
+  return value;
 }
 }
 
 
-static void lex_scan_string(lex_t *lex, json_error_t *error) {
-    int c;
-    const char *p;
-    char *t;
-    int i;
+static void
+lex_scan_string (
+  lex_t         *lex,
+  json_error_t  *error
+  )
+{
+  int         c;
+  const char  *p;
+  char        *t;
+  int         i;
 
 
-    lex->value.string.val = NULL;
-    lex->token = TOKEN_INVALID;
+  lex->value.string.val = NULL;
+  lex->token            = TOKEN_INVALID;
 
 
-    c = lex_get_save(lex, error);
+  c = lex_get_save (lex, error);
 
 
-    while (c != '"') {
-        if (c == STREAM_STATE_ERROR)
+  while (c != '"') {
+    if (c == STREAM_STATE_ERROR) {
+      goto out;
+    } else if (c == STREAM_STATE_EOF) {
+      error_set (
+        error,
+        lex,
+        json_error_premature_end_of_input,
+        "premature end of input"
+        );
+      goto out;
+    } else if ((0 <= c) && (c <= 0x1F)) {
+      /* control character */
+      lex_unget_unsave (lex, c);
+      if (c == '\n') {
+        error_set (error, lex, json_error_invalid_syntax, "unexpected newline");
+      } else {
+        error_set (
+          error,
+          lex,
+          json_error_invalid_syntax,
+          "control character 0x%x",
+          c
+          );
+      }
+
+      goto out;
+    } else if (c == '\\') {
+      c = lex_get_save (lex, error);
+      if (c == 'u') {
+        c = lex_get_save (lex, error);
+        for (i = 0; i < 4; i++) {
+          if (!l_isxdigit (c)) {
+            error_set (
+              error,
+              lex,
+              json_error_invalid_syntax,
+              "invalid escape"
+              );
             goto out;
             goto out;
+          }
 
 
-        else if (c == STREAM_STATE_EOF) {
-            error_set(error, lex, json_error_premature_end_of_input,
-                      "premature end of input");
-            goto out;
+          c = lex_get_save (lex, error);
         }
         }
-
-        else if (0 <= c && c <= 0x1F) {
-            /* control character */
-            lex_unget_unsave(lex, c);
-            if (c == '\n')
-                error_set(error, lex, json_error_invalid_syntax, "unexpected newline");
-            else
-                error_set(error, lex, json_error_invalid_syntax, "control character 0x%x",
-                          c);
-            goto out;
+      } else if ((c == '"') || (c == '\\') || (c == '/') || (c == 'b') || (c == 'f') ||
+                 (c == 'n') || (c == 'r') || (c == 't'))
+      {
+        c = lex_get_save (lex, error);
+      } else {
+        error_set (error, lex, json_error_invalid_syntax, "invalid escape");
+        goto out;
+      }
+    } else {
+      c = lex_get_save (lex, error);
+    }
+  }
+
+  /* the actual value is at most of the same length as the source
+     string, because:
+       - shortcut escapes (e.g. "\t") (length 2) are converted to 1 byte
+       - a single \uXXXX escape (length 6) is converted to at most 3 bytes
+       - two \uXXXX escapes (length 12) forming an UTF-16 surrogate pair
+         are converted to 4 bytes
+  */
+  t = jsonp_malloc (lex->saved_text.length + 1);
+  if (!t) {
+    /* this is not very nice, since TOKEN_INVALID is returned */
+    goto out;
+  }
+
+  lex->value.string.val = t;
+
+  /* + 1 to skip the " */
+  p = strbuffer_value (&lex->saved_text) + 1;
+
+  while (*p != '"') {
+    if (*p == '\\') {
+      p++;
+      if (*p == 'u') {
+        size_t   length;
+        int32_t  value;
+
+        value = decode_unicode_escape (p);
+        if (value < 0) {
+          error_set (
+            error,
+            lex,
+            json_error_invalid_syntax,
+            "invalid Unicode escape '%.6s'",
+            p - 1
+            );
+          goto out;
         }
         }
 
 
-        else if (c == '\\') {
-            c = lex_get_save(lex, error);
-            if (c == 'u') {
-                c = lex_get_save(lex, error);
-                for (i = 0; i < 4; i++) {
-                    if (!l_isxdigit(c)) {
-                        error_set(error, lex, json_error_invalid_syntax,
-                                  "invalid escape");
-                        goto out;
-                    }
-                    c = lex_get_save(lex, error);
-                }
-            } else if (c == '"' || c == '\\' || c == '/' || c == 'b' || c == 'f' ||
-                       c == 'n' || c == 'r' || c == 't')
-                c = lex_get_save(lex, error);
-            else {
-                error_set(error, lex, json_error_invalid_syntax, "invalid escape");
-                goto out;
+        p += 5;
+
+        if ((0xD800 <= value) && (value <= 0xDBFF)) {
+          /* surrogate pair */
+          if ((*p == '\\') && (*(p + 1) == 'u')) {
+            int32_t  value2 = decode_unicode_escape (++p);
+            if (value2 < 0) {
+              error_set (
+                error,
+                lex,
+                json_error_invalid_syntax,
+                "invalid Unicode escape '%.6s'",
+                p - 1
+                );
+              goto out;
             }
             }
-        } else
-            c = lex_get_save(lex, error);
-    }
 
 
-    /* the actual value is at most of the same length as the source
-       string, because:
-         - shortcut escapes (e.g. "\t") (length 2) are converted to 1 byte
-         - a single \uXXXX escape (length 6) is converted to at most 3 bytes
-         - two \uXXXX escapes (length 12) forming an UTF-16 surrogate pair
-           are converted to 4 bytes
-    */
-    t = jsonp_malloc(lex->saved_text.length + 1);
-    if (!t) {
-        /* this is not very nice, since TOKEN_INVALID is returned */
-        goto out;
-    }
-    lex->value.string.val = t;
-
-    /* + 1 to skip the " */
-    p = strbuffer_value(&lex->saved_text) + 1;
-
-    while (*p != '"') {
-        if (*p == '\\') {
-            p++;
-            if (*p == 'u') {
-                size_t length;
-                int32_t value;
-
-                value = decode_unicode_escape(p);
-                if (value < 0) {
-                    error_set(error, lex, json_error_invalid_syntax,
-                              "invalid Unicode escape '%.6s'", p - 1);
-                    goto out;
-                }
-                p += 5;
-
-                if (0xD800 <= value && value <= 0xDBFF) {
-                    /* surrogate pair */
-                    if (*p == '\\' && *(p + 1) == 'u') {
-                        int32_t value2 = decode_unicode_escape(++p);
-                        if (value2 < 0) {
-                            error_set(error, lex, json_error_invalid_syntax,
-                                      "invalid Unicode escape '%.6s'", p - 1);
-                            goto out;
-                        }
-                        p += 5;
-
-                        if (0xDC00 <= value2 && value2 <= 0xDFFF) {
-                            /* valid second surrogate */
-                            value =
-                                ((value - 0xD800) << 10) + (value2 - 0xDC00) + 0x10000;
-                        } else {
-                            /* invalid second surrogate */
-                            error_set(error, lex, json_error_invalid_syntax,
-                                      "invalid Unicode '\\u%04X\\u%04X'", value, value2);
-                            goto out;
-                        }
-                    } else {
-                        /* no second surrogate */
-                        error_set(error, lex, json_error_invalid_syntax,
-                                  "invalid Unicode '\\u%04X'", value);
-                        goto out;
-                    }
-                } else if (0xDC00 <= value && value <= 0xDFFF) {
-                    error_set(error, lex, json_error_invalid_syntax,
-                              "invalid Unicode '\\u%04X'", value);
-                    goto out;
-                }
-
-                if (utf8_encode(value, t, &length))
-                    assert(0);
-                t += length;
+            p += 5;
+
+            if ((0xDC00 <= value2) && (value2 <= 0xDFFF)) {
+              /* valid second surrogate */
+              value =
+                ((value - 0xD800) << 10) + (value2 - 0xDC00) + 0x10000;
             } else {
             } else {
-                switch (*p) {
-                    case '"':
-                    case '\\':
-                    case '/':
-                        *t = *p;
-                        break;
-                    case 'b':
-                        *t = '\b';
-                        break;
-                    case 'f':
-                        *t = '\f';
-                        break;
-                    case 'n':
-                        *t = '\n';
-                        break;
-                    case 'r':
-                        *t = '\r';
-                        break;
-                    case 't':
-                        *t = '\t';
-                        break;
-                    default:
-                        assert(0);
-                }
-                t++;
-                p++;
+              /* invalid second surrogate */
+              error_set (
+                error,
+                lex,
+                json_error_invalid_syntax,
+                "invalid Unicode '\\u%04X\\u%04X'",
+                value,
+                value2
+                );
+              goto out;
             }
             }
-        } else
-            *(t++) = *(p++);
+          } else {
+            /* no second surrogate */
+            error_set (
+              error,
+              lex,
+              json_error_invalid_syntax,
+              "invalid Unicode '\\u%04X'",
+              value
+              );
+            goto out;
+          }
+        } else if ((0xDC00 <= value) && (value <= 0xDFFF)) {
+          error_set (
+            error,
+            lex,
+            json_error_invalid_syntax,
+            "invalid Unicode '\\u%04X'",
+            value
+            );
+          goto out;
+        }
+
+        if (utf8_encode (value, t, &length)) {
+          assert (0);
+        }
+
+        t += length;
+      } else {
+        switch (*p) {
+          case '"':
+          case '\\':
+          case '/':
+            *t = *p;
+            break;
+          case 'b':
+            *t = '\b';
+            break;
+          case 'f':
+            *t = '\f';
+            break;
+          case 'n':
+            *t = '\n';
+            break;
+          case 'r':
+            *t = '\r';
+            break;
+          case 't':
+            *t = '\t';
+            break;
+          default:
+            assert (0);
+        }
+
+        t++;
+        p++;
+      }
+    } else {
+      *(t++) = *(p++);
     }
     }
-    *t = '\0';
-    lex->value.string.len = t - lex->value.string.val;
-    lex->token = TOKEN_STRING;
-    return;
+  }
+
+  *t                    = '\0';
+  lex->value.string.len = t - lex->value.string.val;
+  lex->token            = TOKEN_STRING;
+  return;
 
 
 out:
 out:
-    lex_free_string(lex);
+  lex_free_string (lex);
 }
 }
 
 
 #ifndef JANSSON_USING_CMAKE /* disabled if using cmake */
 #ifndef JANSSON_USING_CMAKE /* disabled if using cmake */
-#if JSON_INTEGER_IS_LONG_LONG
-#ifdef _MSC_VER /* Microsoft Visual Studio */
-#define json_strtoint _strtoi64
-#else
-#define json_strtoint strtoll
-#endif
-#else
-#define json_strtoint strtol
-#endif
+  #if JSON_INTEGER_IS_LONG_LONG
+    #ifdef _MSC_VER /* Microsoft Visual Studio */
+#define json_strtoint  _strtoi64
+    #else
+#define json_strtoint  strtoll
+    #endif
+  #else
+#define json_strtoint  strtol
+  #endif
 #endif
 #endif
 
 
-static int lex_scan_number(lex_t *lex, int c, json_error_t *error) {
-    const char *saved_text;
-    char *end;
-    double doubleval;
-
-    lex->token = TOKEN_INVALID;
-
-    if (c == '-')
-        c = lex_get_save(lex, error);
-
-    if (c == '0') {
-        c = lex_get_save(lex, error);
-        if (l_isdigit(c)) {
-            lex_unget_unsave(lex, c);
-            goto out;
-        }
-    } else if (l_isdigit(c)) {
-        do
-            c = lex_get_save(lex, error);
-        while (l_isdigit(c));
-    } else {
-        lex_unget_unsave(lex, c);
-        goto out;
+static int
+lex_scan_number (
+  lex_t         *lex,
+  int           c,
+  json_error_t  *error
+  )
+{
+  const char  *saved_text;
+  char        *end;
+  double      doubleval;
+
+  lex->token = TOKEN_INVALID;
+
+  if (c == '-') {
+    c = lex_get_save (lex, error);
+  }
+
+  if (c == '0') {
+    c = lex_get_save (lex, error);
+    if (l_isdigit (c)) {
+      lex_unget_unsave (lex, c);
+      goto out;
+    }
+  } else if (l_isdigit (c)) {
+    do {
+      c = lex_get_save (lex, error);
+    } while (l_isdigit (c));
+  } else {
+    lex_unget_unsave (lex, c);
+    goto out;
+  }
+
+  if (!(lex->flags & JSON_DECODE_INT_AS_REAL) && (c != '.') && (c != 'E') && (c != 'e')) {
+    json_int_t  intval;
+
+    lex_unget_unsave (lex, c);
+
+    saved_text = strbuffer_value (&lex->saved_text);
+
+    errno  = 0;
+    intval = json_strtoint (saved_text, &end, 10);
+    if (errno == ERANGE) {
+      if (intval < 0) {
+        error_set (
+          error,
+          lex,
+          json_error_numeric_overflow,
+          "too big negative integer"
+          );
+      } else {
+        error_set (error, lex, json_error_numeric_overflow, "too big integer");
+      }
+
+      goto out;
     }
     }
 
 
-    if (!(lex->flags & JSON_DECODE_INT_AS_REAL) && c != '.' && c != 'E' && c != 'e') {
-        json_int_t intval;
+    assert (end == saved_text + lex->saved_text.length);
 
 
-        lex_unget_unsave(lex, c);
+    lex->token         = TOKEN_INTEGER;
+    lex->value.integer = intval;
+    return 0;
+  }
 
 
-        saved_text = strbuffer_value(&lex->saved_text);
+  if (c == '.') {
+    c = lex_get (lex, error);
+    if (!l_isdigit (c)) {
+      lex_unget (lex, c);
+      goto out;
+    }
 
 
-        errno = 0;
-        intval = json_strtoint(saved_text, &end, 10);
-        if (errno == ERANGE) {
-            if (intval < 0)
-                error_set(error, lex, json_error_numeric_overflow,
-                          "too big negative integer");
-            else
-                error_set(error, lex, json_error_numeric_overflow, "too big integer");
-            goto out;
-        }
+    lex_save (lex, c);
 
 
-        assert(end == saved_text + lex->saved_text.length);
+    do {
+      c = lex_get_save (lex, error);
+    } while (l_isdigit (c));
+  }
 
 
-        lex->token = TOKEN_INTEGER;
-        lex->value.integer = intval;
-        return 0;
+  if ((c == 'E') || (c == 'e')) {
+    c = lex_get_save (lex, error);
+    if ((c == '+') || (c == '-')) {
+      c = lex_get_save (lex, error);
     }
     }
 
 
-    if (c == '.') {
-        c = lex_get(lex, error);
-        if (!l_isdigit(c)) {
-            lex_unget(lex, c);
-            goto out;
-        }
-        lex_save(lex, c);
-
-        do
-            c = lex_get_save(lex, error);
-        while (l_isdigit(c));
+    if (!l_isdigit (c)) {
+      lex_unget_unsave (lex, c);
+      goto out;
     }
     }
 
 
-    if (c == 'E' || c == 'e') {
-        c = lex_get_save(lex, error);
-        if (c == '+' || c == '-')
-            c = lex_get_save(lex, error);
+    do {
+      c = lex_get_save (lex, error);
+    } while (l_isdigit (c));
+  }
 
 
-        if (!l_isdigit(c)) {
-            lex_unget_unsave(lex, c);
-            goto out;
-        }
+  lex_unget_unsave (lex, c);
 
 
-        do
-            c = lex_get_save(lex, error);
-        while (l_isdigit(c));
-    }
+  if (jsonp_strtod (&lex->saved_text, &doubleval)) {
+    error_set (error, lex, json_error_numeric_overflow, "real number overflow");
+    goto out;
+  }
 
 
-    lex_unget_unsave(lex, c);
-
-    if (jsonp_strtod(&lex->saved_text, &doubleval)) {
-        error_set(error, lex, json_error_numeric_overflow, "real number overflow");
-        goto out;
-    }
-
-    lex->token = TOKEN_REAL;
-    lex->value.real = doubleval;
-    return 0;
+  lex->token      = TOKEN_REAL;
+  lex->value.real = doubleval;
+  return 0;
 
 
 out:
 out:
-    return -1;
+  return -1;
 }
 }
 
 
-static int lex_scan(lex_t *lex, json_error_t *error) {
-    int c;
+static int
+lex_scan (
+  lex_t         *lex,
+  json_error_t  *error
+  )
+{
+  int  c;
 
 
-    strbuffer_clear(&lex->saved_text);
+  strbuffer_clear (&lex->saved_text);
 
 
-    if (lex->token == TOKEN_STRING)
-        lex_free_string(lex);
+  if (lex->token == TOKEN_STRING) {
+    lex_free_string (lex);
+  }
 
 
-    do
-        c = lex_get(lex, error);
-    while (c == ' ' || c == '\t' || c == '\n' || c == '\r');
+  do {
+    c = lex_get (lex, error);
+  } while (c == ' ' || c == '\t' || c == '\n' || c == '\r');
 
 
-    if (c == STREAM_STATE_EOF) {
-        lex->token = TOKEN_EOF;
-        goto out;
-    }
+  if (c == STREAM_STATE_EOF) {
+    lex->token = TOKEN_EOF;
+    goto out;
+  }
 
 
-    if (c == STREAM_STATE_ERROR) {
-        lex->token = TOKEN_INVALID;
-        goto out;
+  if (c == STREAM_STATE_ERROR) {
+    lex->token = TOKEN_INVALID;
+    goto out;
+  }
+
+  lex_save (lex, c);
+
+  if ((c == '{') || (c == '}') || (c == '[') || (c == ']') || (c == ':') || (c == ',')) {
+    lex->token = c;
+  } else if (c == '"') {
+    lex_scan_string (lex, error);
+  } else if (l_isdigit (c) || (c == '-')) {
+    if (lex_scan_number (lex, c, error)) {
+      goto out;
     }
     }
+  } else if (l_isalpha (c)) {
+    /* eat up the whole identifier for clearer error messages */
+    const char  *saved_text;
 
 
-    lex_save(lex, c);
+    do {
+      c = lex_get_save (lex, error);
+    } while (l_isalpha (c));
 
 
-    if (c == '{' || c == '}' || c == '[' || c == ']' || c == ':' || c == ',')
-        lex->token = c;
+    lex_unget_unsave (lex, c);
 
 
-    else if (c == '"')
-        lex_scan_string(lex, error);
-
-    else if (l_isdigit(c) || c == '-') {
-        if (lex_scan_number(lex, c, error))
-            goto out;
-    }
+    saved_text = strbuffer_value (&lex->saved_text);
 
 
-    else if (l_isalpha(c)) {
-        /* eat up the whole identifier for clearer error messages */
-        const char *saved_text;
-
-        do
-            c = lex_get_save(lex, error);
-        while (l_isalpha(c));
-        lex_unget_unsave(lex, c);
-
-        saved_text = strbuffer_value(&lex->saved_text);
-
-        if (strcmp(saved_text, "true") == 0)
-            lex->token = TOKEN_TRUE;
-        else if (strcmp(saved_text, "false") == 0)
-            lex->token = TOKEN_FALSE;
-        else if (strcmp(saved_text, "null") == 0)
-            lex->token = TOKEN_NULL;
-        else
-            lex->token = TOKEN_INVALID;
-    }
-
-    else {
-        /* save the rest of the input UTF-8 sequence to get an error
-           message of valid UTF-8 */
-        lex_save_cached(lex);
-        lex->token = TOKEN_INVALID;
+    if (strcmp (saved_text, "true") == 0) {
+      lex->token = TOKEN_TRUE;
+    } else if (strcmp (saved_text, "false") == 0) {
+      lex->token = TOKEN_FALSE;
+    } else if (strcmp (saved_text, "null") == 0) {
+      lex->token = TOKEN_NULL;
+    } else {
+      lex->token = TOKEN_INVALID;
     }
     }
+  } else {
+    /* save the rest of the input UTF-8 sequence to get an error
+       message of valid UTF-8 */
+    lex_save_cached (lex);
+    lex->token = TOKEN_INVALID;
+  }
 
 
 out:
 out:
-    return lex->token;
+  return lex->token;
 }
 }
 
 
-static char *lex_steal_string(lex_t *lex, size_t *out_len) {
-    char *result = NULL;
-    if (lex->token == TOKEN_STRING) {
-        result = lex->value.string.val;
-        *out_len = lex->value.string.len;
-        lex->value.string.val = NULL;
-        lex->value.string.len = 0;
-    }
-    return result;
+static char *
+lex_steal_string (
+  lex_t   *lex,
+  size_t  *out_len
+  )
+{
+  char  *result = NULL;
+
+  if (lex->token == TOKEN_STRING) {
+    result                = lex->value.string.val;
+    *out_len              = lex->value.string.len;
+    lex->value.string.val = NULL;
+    lex->value.string.len = 0;
+  }
+
+  return result;
 }
 }
 
 
-static int lex_init(lex_t *lex, get_func get, size_t flags, void *data) {
-    stream_init(&lex->stream, get, data);
-    if (strbuffer_init(&lex->saved_text))
-        return -1;
+static int
+lex_init (
+  lex_t     *lex,
+  get_func  get,
+  size_t    flags,
+  void      *data
+  )
+{
+  stream_init (&lex->stream, get, data);
+  if (strbuffer_init (&lex->saved_text)) {
+    return -1;
+  }
 
 
-    lex->flags = flags;
-    lex->token = TOKEN_INVALID;
-    return 0;
+  lex->flags = flags;
+  lex->token = TOKEN_INVALID;
+  return 0;
 }
 }
 
 
-static void lex_close(lex_t *lex) {
-    if (lex->token == TOKEN_STRING)
-        lex_free_string(lex);
-    strbuffer_close(&lex->saved_text);
+static void
+lex_close (
+  lex_t  *lex
+  )
+{
+  if (lex->token == TOKEN_STRING) {
+    lex_free_string (lex);
+  }
+
+  strbuffer_close (&lex->saved_text);
 }
 }
 
 
 /*** parser ***/
 /*** parser ***/
 
 
-static json_t *parse_value(lex_t *lex, size_t flags, json_error_t *error);
-
-static json_t *parse_object(lex_t *lex, size_t flags, json_error_t *error) {
-    json_t *object = json_object();
-    if (!object)
-        return NULL;
+static json_t *
+parse_value (
+  lex_t         *lex,
+  size_t        flags,
+  json_error_t  *error
+  );
+
+static json_t *
+parse_object (
+  lex_t         *lex,
+  size_t        flags,
+  json_error_t  *error
+  )
+{
+  json_t  *object = json_object ();
+
+  if (!object) {
+    return NULL;
+  }
 
 
-    lex_scan(lex, error);
-    if (lex->token == '}')
-        return object;
+  lex_scan (lex, error);
+  if (lex->token == '}') {
+    return object;
+  }
 
 
-    while (1) {
-        char *key;
-        size_t len;
-        json_t *value;
+  while (1) {
+    char    *key;
+    size_t  len;
+    json_t  *value;
 
 
-        if (lex->token != TOKEN_STRING) {
-            error_set(error, lex, json_error_invalid_syntax, "string or '}' expected");
-            goto error;
-        }
+    if (lex->token != TOKEN_STRING) {
+      error_set (error, lex, json_error_invalid_syntax, "string or '}' expected");
+      goto error;
+    }
 
 
-        key = lex_steal_string(lex, &len);
-        if (!key)
-            return NULL;
-        if (memchr(key, '\0', len)) {
-            jsonp_free(key);
-            error_set(error, lex, json_error_null_byte_in_key,
-                      "NUL byte in object key not supported");
-            goto error;
-        }
+    key = lex_steal_string (lex, &len);
+    if (!key) {
+      return NULL;
+    }
 
 
-        if (flags & JSON_REJECT_DUPLICATES) {
-            if (json_object_get(object, key)) {
-                jsonp_free(key);
-                error_set(error, lex, json_error_duplicate_key, "duplicate object key");
-                goto error;
-            }
-        }
+    if (memchr (key, '\0', len)) {
+      jsonp_free (key);
+      error_set (
+        error,
+        lex,
+        json_error_null_byte_in_key,
+        "NUL byte in object key not supported"
+        );
+      goto error;
+    }
 
 
-        lex_scan(lex, error);
-        if (lex->token != ':') {
-            jsonp_free(key);
-            error_set(error, lex, json_error_invalid_syntax, "':' expected");
-            goto error;
-        }
+    if (flags & JSON_REJECT_DUPLICATES) {
+      if (json_object_get (object, key)) {
+        jsonp_free (key);
+        error_set (error, lex, json_error_duplicate_key, "duplicate object key");
+        goto error;
+      }
+    }
 
 
-        lex_scan(lex, error);
-        value = parse_value(lex, flags, error);
-        if (!value) {
-            jsonp_free(key);
-            goto error;
-        }
+    lex_scan (lex, error);
+    if (lex->token != ':') {
+      jsonp_free (key);
+      error_set (error, lex, json_error_invalid_syntax, "':' expected");
+      goto error;
+    }
 
 
-        if (json_object_set_new_nocheck(object, key, value)) {
-            jsonp_free(key);
-            goto error;
-        }
+    lex_scan (lex, error);
+    value = parse_value (lex, flags, error);
+    if (!value) {
+      jsonp_free (key);
+      goto error;
+    }
 
 
-        jsonp_free(key);
+    if (json_object_set_new_nocheck (object, key, value)) {
+      jsonp_free (key);
+      goto error;
+    }
 
 
-        lex_scan(lex, error);
-        if (lex->token != ',')
-            break;
+    jsonp_free (key);
 
 
-        lex_scan(lex, error);
+    lex_scan (lex, error);
+    if (lex->token != ',') {
+      break;
     }
     }
 
 
-    if (lex->token != '}') {
-        error_set(error, lex, json_error_invalid_syntax, "'}' expected");
-        goto error;
-    }
+    lex_scan (lex, error);
+  }
 
 
-    return object;
+  if (lex->token != '}') {
+    error_set (error, lex, json_error_invalid_syntax, "'}' expected");
+    goto error;
+  }
+
+  return object;
 
 
 error:
 error:
-    json_decref(object);
-    return NULL;
+  json_decref (object);
+  return NULL;
 }
 }
 
 
-static json_t *parse_array(lex_t *lex, size_t flags, json_error_t *error) {
-    json_t *array = json_array();
-    if (!array)
-        return NULL;
+static json_t *
+parse_array (
+  lex_t         *lex,
+  size_t        flags,
+  json_error_t  *error
+  )
+{
+  json_t  *array = json_array ();
 
 
-    lex_scan(lex, error);
-    if (lex->token == ']')
-        return array;
-
-    while (lex->token) {
-        json_t *elem = parse_value(lex, flags, error);
-        if (!elem)
-            goto error;
+  if (!array) {
+    return NULL;
+  }
 
 
-        if (json_array_append_new(array, elem)) {
-            goto error;
-        }
+  lex_scan (lex, error);
+  if (lex->token == ']') {
+    return array;
+  }
 
 
-        lex_scan(lex, error);
-        if (lex->token != ',')
-            break;
+  while (lex->token) {
+    json_t  *elem = parse_value (lex, flags, error);
+    if (!elem) {
+      goto error;
+    }
 
 
-        lex_scan(lex, error);
+    if (json_array_append_new (array, elem)) {
+      goto error;
     }
     }
 
 
-    if (lex->token != ']') {
-        error_set(error, lex, json_error_invalid_syntax, "']' expected");
-        goto error;
+    lex_scan (lex, error);
+    if (lex->token != ',') {
+      break;
     }
     }
 
 
-    return array;
+    lex_scan (lex, error);
+  }
+
+  if (lex->token != ']') {
+    error_set (error, lex, json_error_invalid_syntax, "']' expected");
+    goto error;
+  }
+
+  return array;
 
 
 error:
 error:
-    json_decref(array);
-    return NULL;
+  json_decref (array);
+  return NULL;
 }
 }
 
 
-static json_t *parse_value(lex_t *lex, size_t flags, json_error_t *error) {
-    json_t *json;
+static json_t *
+parse_value (
+  lex_t         *lex,
+  size_t        flags,
+  json_error_t  *error
+  )
+{
+  json_t  *json;
+
+  lex->depth++;
+  if (lex->depth > JSON_PARSER_MAX_DEPTH) {
+    error_set (error, lex, json_error_stack_overflow, "maximum parsing depth reached");
+    return NULL;
+  }
+
+  switch (lex->token) {
+    case TOKEN_STRING:
+    {
+      const char  *value = lex->value.string.val;
+      size_t      len    = lex->value.string.len;
+
+      if (!(flags & JSON_ALLOW_NUL)) {
+        if (memchr (value, '\0', len)) {
+          error_set (
+            error,
+            lex,
+            json_error_null_character,
+            "\\u0000 is not allowed without JSON_ALLOW_NUL"
+            );
+          return NULL;
+        }
+      }
 
 
-    lex->depth++;
-    if (lex->depth > JSON_PARSER_MAX_DEPTH) {
-        error_set(error, lex, json_error_stack_overflow, "maximum parsing depth reached");
-        return NULL;
+      json                  = jsonp_stringn_nocheck_own (value, len);
+      lex->value.string.val = NULL;
+      lex->value.string.len = 0;
+      break;
     }
     }
 
 
-    switch (lex->token) {
-        case TOKEN_STRING: {
-            const char *value = lex->value.string.val;
-            size_t len = lex->value.string.len;
-
-            if (!(flags & JSON_ALLOW_NUL)) {
-                if (memchr(value, '\0', len)) {
-                    error_set(error, lex, json_error_null_character,
-                              "\\u0000 is not allowed without JSON_ALLOW_NUL");
-                    return NULL;
-                }
-            }
-
-            json = jsonp_stringn_nocheck_own(value, len);
-            lex->value.string.val = NULL;
-            lex->value.string.len = 0;
-            break;
-        }
-
-        case TOKEN_INTEGER: {
-            json = json_integer(lex->value.integer);
-            break;
-        }
+    case TOKEN_INTEGER:
+    {
+      json = json_integer (lex->value.integer);
+      break;
+    }
 
 
-        case TOKEN_REAL: {
-            json = json_real(lex->value.real);
-            break;
-        }
+    case TOKEN_REAL:
+    {
+      json = json_real (lex->value.real);
+      break;
+    }
 
 
-        case TOKEN_TRUE:
-            json = json_true();
-            break;
+    case TOKEN_TRUE:
+      json = json_true ();
+      break;
 
 
-        case TOKEN_FALSE:
-            json = json_false();
-            break;
+    case TOKEN_FALSE:
+      json = json_false ();
+      break;
 
 
-        case TOKEN_NULL:
-            json = json_null();
-            break;
+    case TOKEN_NULL:
+      json = json_null ();
+      break;
 
 
-        case '{':
-            json = parse_object(lex, flags, error);
-            break;
+    case '{':
+      json = parse_object (lex, flags, error);
+      break;
 
 
-        case '[':
-            json = parse_array(lex, flags, error);
-            break;
+    case '[':
+      json = parse_array (lex, flags, error);
+      break;
 
 
-        case TOKEN_INVALID:
-            error_set(error, lex, json_error_invalid_syntax, "invalid token");
-            return NULL;
+    case TOKEN_INVALID:
+      error_set (error, lex, json_error_invalid_syntax, "invalid token");
+      return NULL;
 
 
-        default:
-            error_set(error, lex, json_error_invalid_syntax, "unexpected token");
-            return NULL;
-    }
+    default:
+      error_set (error, lex, json_error_invalid_syntax, "unexpected token");
+      return NULL;
+  }
 
 
-    if (!json)
-        return NULL;
+  if (!json) {
+    return NULL;
+  }
 
 
-    lex->depth--;
-    return json;
+  lex->depth--;
+  return json;
 }
 }
 
 
-static json_t *parse_json(lex_t *lex, size_t flags, json_error_t *error) {
-    json_t *result;
-
-    lex->depth = 0;
-
-    lex_scan(lex, error);
-    if (!(flags & JSON_DECODE_ANY)) {
-        if (lex->token != '[' && lex->token != '{') {
-            error_set(error, lex, json_error_invalid_syntax, "'[' or '{' expected");
-            return NULL;
-        }
+static json_t *
+parse_json (
+  lex_t         *lex,
+  size_t        flags,
+  json_error_t  *error
+  )
+{
+  json_t  *result;
+
+  lex->depth = 0;
+
+  lex_scan (lex, error);
+  if (!(flags & JSON_DECODE_ANY)) {
+    if ((lex->token != '[') && (lex->token != '{')) {
+      error_set (error, lex, json_error_invalid_syntax, "'[' or '{' expected");
+      return NULL;
     }
     }
+  }
 
 
-    result = parse_value(lex, flags, error);
-    if (!result)
-        return NULL;
-
-    if (!(flags & JSON_DISABLE_EOF_CHECK)) {
-        lex_scan(lex, error);
-        if (lex->token != TOKEN_EOF) {
-            error_set(error, lex, json_error_end_of_input_expected,
-                      "end of file expected");
-            json_decref(result);
-            return NULL;
-        }
+  result = parse_value (lex, flags, error);
+  if (!result) {
+    return NULL;
+  }
+
+  if (!(flags & JSON_DISABLE_EOF_CHECK)) {
+    lex_scan (lex, error);
+    if (lex->token != TOKEN_EOF) {
+      error_set (
+        error,
+        lex,
+        json_error_end_of_input_expected,
+        "end of file expected"
+        );
+      json_decref (result);
+      return NULL;
     }
     }
+  }
 
 
-    if (error) {
-        /* Save the position even though there was no error */
-        error->position = (int)lex->stream.position;
-    }
+  if (error) {
+    /* Save the position even though there was no error */
+    error->position = (int)lex->stream.position;
+  }
 
 
-    return result;
+  return result;
 }
 }
 
 
 typedef struct {
 typedef struct {
-    const char *data;
-    size_t pos;
+  const char    *data;
+  size_t        pos;
 } string_data_t;
 } string_data_t;
 
 
-static int string_get(void *data) {
-    char c;
-    string_data_t *stream = (string_data_t *)data;
-    c = stream->data[stream->pos];
-    if (c == '\0')
-        return EOF;
-    else {
-        stream->pos++;
-        return (unsigned char)c;
-    }
-}
-
-json_t *json_loads(const char *string, size_t flags, json_error_t *error) {
-    lex_t lex;
-    json_t *result;
-    string_data_t stream_data;
+static int
+string_get (
+  void  *data
+  )
+{
+  char           c;
+  string_data_t  *stream = (string_data_t *)data;
 
 
-    jsonp_error_init(error, "<string>");
+  c = stream->data[stream->pos];
+  if (c == '\0') {
+    return EOF;
+  } else {
+    stream->pos++;
+    return (unsigned char)c;
+  }
+}
 
 
-    if (string == NULL) {
-        error_set(error, NULL, json_error_invalid_argument, "wrong arguments");
-        return NULL;
-    }
+json_t *
+json_loads (
+  const char    *string,
+  size_t        flags,
+  json_error_t  *error
+  )
+{
+  lex_t          lex;
+  json_t         *result;
+  string_data_t  stream_data;
+
+  jsonp_error_init (error, "<string>");
+
+  if (string == NULL) {
+    error_set (error, NULL, json_error_invalid_argument, "wrong arguments");
+    return NULL;
+  }
 
 
-    stream_data.data = string;
-    stream_data.pos = 0;
+  stream_data.data = string;
+  stream_data.pos  = 0;
 
 
-    if (lex_init(&lex, string_get, flags, (void *)&stream_data))
-        return NULL;
+  if (lex_init (&lex, string_get, flags, (void *)&stream_data)) {
+    return NULL;
+  }
 
 
-    result = parse_json(&lex, flags, error);
+  result = parse_json (&lex, flags, error);
 
 
-    lex_close(&lex);
-    return result;
+  lex_close (&lex);
+  return result;
 }
 }
 
 
 typedef struct {
 typedef struct {
-    const char *data;
-    size_t len;
-    size_t pos;
+  const char    *data;
+  size_t        len;
+  size_t        pos;
 } buffer_data_t;
 } buffer_data_t;
 
 
-static int buffer_get(void *data) {
-    char c;
-    buffer_data_t *stream = data;
-    if (stream->pos >= stream->len)
-        return EOF;
+static int
+buffer_get (
+  void  *data
+  )
+{
+  char           c;
+  buffer_data_t  *stream = data;
 
 
-    c = stream->data[stream->pos];
-    stream->pos++;
-    return (unsigned char)c;
-}
-
-json_t *json_loadb(const char *buffer, size_t buflen, size_t flags, json_error_t *error) {
-    lex_t lex;
-    json_t *result;
-    buffer_data_t stream_data;
+  if (stream->pos >= stream->len) {
+    return EOF;
+  }
 
 
-    jsonp_error_init(error, "<buffer>");
+  c = stream->data[stream->pos];
+  stream->pos++;
+  return (unsigned char)c;
+}
 
 
-    if (buffer == NULL) {
-        error_set(error, NULL, json_error_invalid_argument, "wrong arguments");
-        return NULL;
-    }
+json_t *
+json_loadb (
+  const char    *buffer,
+  size_t        buflen,
+  size_t        flags,
+  json_error_t  *error
+  )
+{
+  lex_t          lex;
+  json_t         *result;
+  buffer_data_t  stream_data;
+
+  jsonp_error_init (error, "<buffer>");
+
+  if (buffer == NULL) {
+    error_set (error, NULL, json_error_invalid_argument, "wrong arguments");
+    return NULL;
+  }
 
 
-    stream_data.data = buffer;
-    stream_data.pos = 0;
-    stream_data.len = buflen;
+  stream_data.data = buffer;
+  stream_data.pos  = 0;
+  stream_data.len  = buflen;
 
 
-    if (lex_init(&lex, buffer_get, flags, (void *)&stream_data))
-        return NULL;
+  if (lex_init (&lex, buffer_get, flags, (void *)&stream_data)) {
+    return NULL;
+  }
 
 
-    result = parse_json(&lex, flags, error);
+  result = parse_json (&lex, flags, error);
 
 
-    lex_close(&lex);
-    return result;
+  lex_close (&lex);
+  return result;
 }
 }
 
 
-json_t *json_loadf(FILE *input, size_t flags, json_error_t *error) {
-    lex_t lex;
-    const char *source;
-    json_t *result;
-#ifdef HAVE_UNISTD_H
-    if (input == stdin)
-        source = "<stdin>";
-    else
-#endif
-        source = "<stream>";
-
-    jsonp_error_init(error, source);
-
-    if (input == NULL) {
-        error_set(error, NULL, json_error_invalid_argument, "wrong arguments");
-        return NULL;
-    }
+json_t *
+json_loadf (
+  FILE          *input,
+  size_t        flags,
+  json_error_t  *error
+  )
+{
+  lex_t       lex;
+  const char  *source;
+  json_t      *result;
+
+ #ifdef HAVE_UNISTD_H
+  if (input == stdin) {
+    source = "<stdin>";
+  } else
+ #endif
+  source = "<stream>";
+
+  jsonp_error_init (error, source);
+
+  if (input == NULL) {
+    error_set (error, NULL, json_error_invalid_argument, "wrong arguments");
+    return NULL;
+  }
 
 
-    if (lex_init(&lex, (get_func)fgetc, flags, input))
-        return NULL;
+  if (lex_init (&lex, (get_func)fgetc, flags, input)) {
+    return NULL;
+  }
 
 
-    result = parse_json(&lex, flags, error);
+  result = parse_json (&lex, flags, error);
 
 
-    lex_close(&lex);
-    return result;
-}
-
-static int fd_get_func(int *fd) {
-#ifdef HAVE_UNISTD_H
-    uint8_t c;
-    if (read(*fd, &c, 1) == 1)
-        return c;
-#endif
-    return EOF;
+  lex_close (&lex);
+  return result;
 }
 }
 
 
-json_t *json_loadfd(int input, size_t flags, json_error_t *error) {
-    lex_t lex;
-    const char *source;
-    json_t *result;
-
-#ifdef HAVE_UNISTD_H
-    if (input == STDIN_FILENO)
-        source = "<stdin>";
-    else
-#endif
-        source = "<stream>";
+static int
+fd_get_func (
+  int  *fd
+  )
+{
+ #ifdef HAVE_UNISTD_H
+  uint8_t  c;
+  if (read (*fd, &c, 1) == 1) {
+    return c;
+  }
 
 
-    jsonp_error_init(error, source);
+ #endif
+  return EOF;
+}
 
 
-    if (input < 0) {
-        error_set(error, NULL, json_error_invalid_argument, "wrong arguments");
-        return NULL;
-    }
+json_t *
+json_loadfd (
+  int           input,
+  size_t        flags,
+  json_error_t  *error
+  )
+{
+  lex_t       lex;
+  const char  *source;
+  json_t      *result;
+
+ #ifdef HAVE_UNISTD_H
+  if (input == STDIN_FILENO) {
+    source = "<stdin>";
+  } else
+ #endif
+  source = "<stream>";
+
+  jsonp_error_init (error, source);
+
+  if (input < 0) {
+    error_set (error, NULL, json_error_invalid_argument, "wrong arguments");
+    return NULL;
+  }
 
 
-    if (lex_init(&lex, (get_func)fd_get_func, flags, &input))
-        return NULL;
+  if (lex_init (&lex, (get_func)fd_get_func, flags, &input)) {
+    return NULL;
+  }
 
 
-    result = parse_json(&lex, flags, error);
+  result = parse_json (&lex, flags, error);
 
 
-    lex_close(&lex);
-    return result;
+  lex_close (&lex);
+  return result;
 }
 }
 
 
-json_t *json_load_file(const char *path, size_t flags, json_error_t *error) {
-    json_t *result;
-    FILE *fp;
+json_t *
+json_load_file (
+  const char    *path,
+  size_t        flags,
+  json_error_t  *error
+  )
+{
+  json_t  *result;
+  FILE    *fp;
 
 
-    jsonp_error_init(error, path);
-
-    if (path == NULL) {
-        error_set(error, NULL, json_error_invalid_argument, "wrong arguments");
-        return NULL;
-    }
+  jsonp_error_init (error, path);
 
 
-    fp = fopen(path, "rb");
-    if (!fp) {
-        error_set(error, NULL, json_error_cannot_open_file, "unable to open %s: %s", path,
-                  strerror(errno));
-        return NULL;
-    }
+  if (path == NULL) {
+    error_set (error, NULL, json_error_invalid_argument, "wrong arguments");
+    return NULL;
+  }
+
+  fp = fopen (path, "rb");
+  if (!fp) {
+    error_set (
+      error,
+      NULL,
+      json_error_cannot_open_file,
+      "unable to open %s: %s",
+      path,
+      strerror (errno)
+      );
+    return NULL;
+  }
 
 
-    result = json_loadf(fp, flags, error);
+  result = json_loadf (fp, flags, error);
 
 
-    fclose(fp);
-    return result;
+  fclose (fp);
+  return result;
 }
 }
 
 
-#define MAX_BUF_LEN 1024
+#define MAX_BUF_LEN  1024
 
 
 typedef struct {
 typedef struct {
-    char data[MAX_BUF_LEN];
-    size_t len;
-    size_t pos;
-    json_load_callback_t callback;
-    void *arg;
+  char                    data[MAX_BUF_LEN];
+  size_t                  len;
+  size_t                  pos;
+  json_load_callback_t    callback;
+  void                    *arg;
 } callback_data_t;
 } callback_data_t;
 
 
-static int callback_get(void *data) {
-    char c;
-    callback_data_t *stream = data;
-
-    if (stream->pos >= stream->len) {
-        stream->pos = 0;
-        stream->len = stream->callback(stream->data, MAX_BUF_LEN, stream->arg);
-        if (stream->len == 0 || stream->len == (size_t)-1)
-            return EOF;
+static int
+callback_get (
+  void  *data
+  )
+{
+  char             c;
+  callback_data_t  *stream = data;
+
+  if (stream->pos >= stream->len) {
+    stream->pos = 0;
+    stream->len = stream->callback (stream->data, MAX_BUF_LEN, stream->arg);
+    if ((stream->len == 0) || (stream->len == (size_t)-1)) {
+      return EOF;
     }
     }
+  }
 
 
-    c = stream->data[stream->pos];
-    stream->pos++;
-    return (unsigned char)c;
+  c = stream->data[stream->pos];
+  stream->pos++;
+  return (unsigned char)c;
 }
 }
 
 
-json_t *json_load_callback(json_load_callback_t callback, void *arg, size_t flags,
-                           json_error_t *error) {
-    lex_t lex;
-    json_t *result;
+json_t *
+json_load_callback (
+  json_load_callback_t  callback,
+  void                  *arg,
+  size_t                flags,
+  json_error_t          *error
+  )
+{
+  lex_t   lex;
+  json_t  *result;
 
 
-    callback_data_t stream_data;
+  callback_data_t  stream_data;
 
 
-    memset(&stream_data, 0, sizeof(stream_data));
-    stream_data.callback = callback;
-    stream_data.arg = arg;
+  memset (&stream_data, 0, sizeof (stream_data));
+  stream_data.callback = callback;
+  stream_data.arg      = arg;
 
 
-    jsonp_error_init(error, "<callback>");
+  jsonp_error_init (error, "<callback>");
 
 
-    if (callback == NULL) {
-        error_set(error, NULL, json_error_invalid_argument, "wrong arguments");
-        return NULL;
-    }
+  if (callback == NULL) {
+    error_set (error, NULL, json_error_invalid_argument, "wrong arguments");
+    return NULL;
+  }
 
 
-    if (lex_init(&lex, (get_func)callback_get, flags, &stream_data))
-        return NULL;
+  if (lex_init (&lex, (get_func)callback_get, flags, &stream_data)) {
+    return NULL;
+  }
 
 
-    result = parse_json(&lex, flags, error);
+  result = parse_json (&lex, flags, error);
 
 
-    lex_close(&lex);
-    return result;
+  lex_close (&lex);
+  return result;
 }
 }

+ 6 - 6
RedfishPkg/Library/PlatformCredentialLibNull/PlatformCredentialLibNull.c

@@ -8,6 +8,7 @@
 **/
 **/
 #include <Uefi.h>
 #include <Uefi.h>
 #include <Protocol/EdkIIRedfishCredential.h>
 #include <Protocol/EdkIIRedfishCredential.h>
+
 /**
 /**
   Notification of Exit Boot Service.
   Notification of Exit Boot Service.
 
 
@@ -17,7 +18,7 @@ VOID
 EFIAPI
 EFIAPI
 LibCredentialExitBootServicesNotify (
 LibCredentialExitBootServicesNotify (
   IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This
   IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This
-)
+  )
 {
 {
   return;
   return;
 }
 }
@@ -31,7 +32,7 @@ VOID
 EFIAPI
 EFIAPI
 LibCredentialEndOfDxeNotify (
 LibCredentialEndOfDxeNotify (
   IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This
   IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This
-)
+  )
 {
 {
   return;
   return;
 }
 }
@@ -67,7 +68,7 @@ LibCredentialGetAuthInfo (
   OUT EDKII_REDFISH_AUTH_METHOD          *AuthMethod,
   OUT EDKII_REDFISH_AUTH_METHOD          *AuthMethod,
   OUT CHAR8                              **UserId,
   OUT CHAR8                              **UserId,
   OUT CHAR8                              **Password
   OUT CHAR8                              **Password
-)
+  )
 {
 {
   return EFI_UNSUPPORTED;
   return EFI_UNSUPPORTED;
 }
 }
@@ -92,10 +93,9 @@ LibCredentialGetAuthInfo (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 LibStopRedfishService (
 LibStopRedfishService (
-  IN     EDKII_REDFISH_CREDENTIAL_PROTOCOL    *This,
-  IN     EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
+  IN     EDKII_REDFISH_CREDENTIAL_PROTOCOL           *This,
+  IN     EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE  ServiceStopType
   )
   )
 {
 {
   return EFI_UNSUPPORTED;
   return EFI_UNSUPPORTED;
 }
 }
-

+ 6 - 5
RedfishPkg/Library/PlatformHostInterfaceLibNull/PlatformHostInterfaceLibNull.c

@@ -23,12 +23,13 @@
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishPlatformHostInterfaceDeviceDescriptor (
 RedfishPlatformHostInterfaceDeviceDescriptor (
-  IN UINT8 *DeviceType,
+  IN UINT8                    *DeviceType,
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
   OUT REDFISH_INTERFACE_DATA  **DeviceDescriptor
-)
+  )
 {
 {
   return EFI_NOT_FOUND;
   return EFI_NOT_FOUND;
 }
 }
+
 /**
 /**
   Get platform Redfish host interface protocol data.
   Get platform Redfish host interface protocol data.
   Caller should pass NULL in ProtocolRecord to retrive the first protocol record.
   Caller should pass NULL in ProtocolRecord to retrive the first protocol record.
@@ -44,9 +45,9 @@ RedfishPlatformHostInterfaceDeviceDescriptor (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishPlatformHostInterfaceProtocolData (
 RedfishPlatformHostInterfaceProtocolData (
-  IN OUT MC_HOST_INTERFACE_PROTOCOL_RECORD **ProtocolRecord,
-  IN UINT8  IndexOfProtocolData
-)
+  IN OUT MC_HOST_INTERFACE_PROTOCOL_RECORD  **ProtocolRecord,
+  IN UINT8                                  IndexOfProtocolData
+  )
 {
 {
   return EFI_NOT_FOUND;
   return EFI_NOT_FOUND;
 }
 }

+ 10 - 10
RedfishPkg/Library/RedfishContentCodingLibNull/RedfishContentCodingLibNull.c

@@ -34,11 +34,11 @@
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishContentEncode  (
 RedfishContentEncode  (
-  IN CHAR8  *ContentEncodedValue,
-  IN CHAR8  *OriginalContent,
-  IN UINTN  OriginalContentLength,
-  OUT VOID  **EncodedContentPointer,
-  OUT UINTN *EncodedContentLength
+  IN CHAR8   *ContentEncodedValue,
+  IN CHAR8   *OriginalContent,
+  IN UINTN   OriginalContentLength,
+  OUT VOID   **EncodedContentPointer,
+  OUT UINTN  *EncodedContentLength
   )
   )
 {
 {
   return EFI_UNSUPPORTED;
   return EFI_UNSUPPORTED;
@@ -70,11 +70,11 @@ RedfishContentEncode  (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishContentDecode (
 RedfishContentDecode (
-  IN CHAR8  *ContentDecodedValue,
-  IN VOID   *ContentPointer,
-  IN UINTN  ContentLength,
-  OUT VOID  **DecodedContentPointer,
-  OUT UINTN *DecodedContentLength
+  IN CHAR8   *ContentDecodedValue,
+  IN VOID    *ContentPointer,
+  IN UINTN   ContentLength,
+  OUT VOID   **DecodedContentPointer,
+  OUT UINTN  *DecodedContentLength
   )
   )
 {
 {
   return EFI_UNSUPPORTED;
   return EFI_UNSUPPORTED;

+ 1 - 0
RedfishPkg/PrivateInclude/Crt/stdarg.h

@@ -7,6 +7,7 @@
     SPDX-License-Identifier: BSD-2-Clause-Patent
     SPDX-License-Identifier: BSD-2-Clause-Patent
 
 
 **/
 **/
+
 #ifndef REDFISH_CRT_STDARG_H_
 #ifndef REDFISH_CRT_STDARG_H_
 #define REDFISH_CRT_STDARG_H_
 #define REDFISH_CRT_STDARG_H_
 
 

+ 1 - 0
RedfishPkg/PrivateInclude/Crt/stdio.h

@@ -7,6 +7,7 @@
     SPDX-License-Identifier: BSD-2-Clause-Patent
     SPDX-License-Identifier: BSD-2-Clause-Patent
 
 
 **/
 **/
+
 #ifndef REDFISH_CRT_STDIO_H_
 #ifndef REDFISH_CRT_STDIO_H_
 #define REDFISH_CRT_STDIO_H_
 #define REDFISH_CRT_STDIO_H_
 
 

+ 1 - 0
RedfishPkg/PrivateInclude/Crt/sys/time.h

@@ -7,6 +7,7 @@
     SPDX-License-Identifier: BSD-2-Clause-Patent
     SPDX-License-Identifier: BSD-2-Clause-Patent
 
 
 **/
 **/
+
 #ifndef REDFISH_CRT_SYS_TIME_H_
 #ifndef REDFISH_CRT_SYS_TIME_H_
 #define REDFISH_CRT_SYS_TIME_H_
 #define REDFISH_CRT_SYS_TIME_H_
 
 

+ 1 - 0
RedfishPkg/PrivateInclude/Crt/sys/types.h

@@ -7,6 +7,7 @@
     SPDX-License-Identifier: BSD-2-Clause-Patent
     SPDX-License-Identifier: BSD-2-Clause-Patent
 
 
 **/
 **/
+
 #ifndef REDFISH_CRT_SYS_TYPES_H_
 #ifndef REDFISH_CRT_SYS_TYPES_H_
 #define REDFISH_CRT_SYS_TYPES_H_
 #define REDFISH_CRT_SYS_TYPES_H_
 
 

+ 1 - 0
RedfishPkg/PrivateInclude/Crt/time.h

@@ -7,6 +7,7 @@
     SPDX-License-Identifier: BSD-2-Clause-Patent
     SPDX-License-Identifier: BSD-2-Clause-Patent
 
 
 **/
 **/
+
 #ifndef REDFISH_CRT_TIME_H_
 #ifndef REDFISH_CRT_TIME_H_
 #define REDFISH_CRT_TIME_H_
 #define REDFISH_CRT_TIME_H_
 
 

+ 70 - 65
RedfishPkg/PrivateInclude/Library/RedfishLib.h

@@ -80,25 +80,25 @@
 ///
 ///
 /// Library class public defines
 /// Library class public defines
 ///
 ///
-typedef  VOID*   REDFISH_SERVICE;
-typedef  VOID*   REDFISH_PAYLOAD;
+typedef  VOID  *REDFISH_SERVICE;
+typedef  VOID  *REDFISH_PAYLOAD;
 
 
 ///
 ///
 /// Library class public structures/unions
 /// Library class public structures/unions
 ///
 ///
 typedef struct {
 typedef struct {
-  EFI_HTTP_STATUS_CODE  *StatusCode;
-  UINTN                 HeaderCount;
-  EFI_HTTP_HEADER       *Headers;
-  REDFISH_PAYLOAD       Payload;
+  EFI_HTTP_STATUS_CODE    *StatusCode;
+  UINTN                   HeaderCount;
+  EFI_HTTP_HEADER         *Headers;
+  REDFISH_PAYLOAD         Payload;
 } REDFISH_RESPONSE;
 } REDFISH_RESPONSE;
 
 
 ///
 ///
 /// Odata type-name mapping structure.
 /// Odata type-name mapping structure.
 ///
 ///
 typedef struct {
 typedef struct {
-  CONST CHAR8    OdataTypeName [ODATA_TYPE_NAME_MAX_SIZE];
-  CONST CHAR8    OdataType [ODATA_TYPE_MAX_SIZE];
+  CONST CHAR8    OdataTypeName[ODATA_TYPE_NAME_MAX_SIZE];
+  CONST CHAR8    OdataType[ODATA_TYPE_MAX_SIZE];
 } REDFISH_ODATA_TYPE_MAPPING;
 } REDFISH_ODATA_TYPE_MAPPING;
 
 
 /**
 /**
@@ -117,7 +117,7 @@ typedef struct {
 REDFISH_SERVICE
 REDFISH_SERVICE
 EFIAPI
 EFIAPI
 RedfishCreateService (
 RedfishCreateService (
-  IN  REDFISH_CONFIG_SERVICE_INFORMATION   *RedfishConfigServiceInfo
+  IN  REDFISH_CONFIG_SERVICE_INFORMATION  *RedfishConfigServiceInfo
   );
   );
 
 
 /**
 /**
@@ -129,7 +129,7 @@ RedfishCreateService (
 VOID
 VOID
 EFIAPI
 EFIAPI
 RedfishCleanupService (
 RedfishCleanupService (
-  IN REDFISH_SERVICE   RedfishService
+  IN REDFISH_SERVICE  RedfishService
   );
   );
 
 
 /**
 /**
@@ -150,8 +150,8 @@ RedfishCleanupService (
 REDFISH_PAYLOAD
 REDFISH_PAYLOAD
 EFIAPI
 EFIAPI
 RedfishCreatePayload (
 RedfishCreatePayload (
-  IN EDKII_JSON_VALUE           Value,
-  IN REDFISH_SERVICE            RedfishService
+  IN EDKII_JSON_VALUE  Value,
+  IN REDFISH_SERVICE   RedfishService
   );
   );
 
 
 /**
 /**
@@ -163,7 +163,7 @@ RedfishCreatePayload (
 VOID
 VOID
 EFIAPI
 EFIAPI
 RedfishCleanupPayload (
 RedfishCleanupPayload (
-  IN REDFISH_PAYLOAD          Payload
+  IN REDFISH_PAYLOAD  Payload
   );
   );
 
 
 /**
 /**
@@ -180,7 +180,7 @@ RedfishCleanupPayload (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 RedfishJsonInPayload (
 RedfishJsonInPayload (
-  IN REDFISH_PAYLOAD          Payload
+  IN REDFISH_PAYLOAD  Payload
   );
   );
 
 
 /**
 /**
@@ -205,9 +205,9 @@ RedfishJsonInPayload (
 CHAR8 *
 CHAR8 *
 EFIAPI
 EFIAPI
 RedfishBuildPathWithSystemUuid (
 RedfishBuildPathWithSystemUuid (
-  IN CONST CHAR8    *RedPath,
-  IN BOOLEAN        FromSmbios,
-  IN CHAR8          *IdString OPTIONAL
+  IN CONST CHAR8  *RedPath,
+  IN BOOLEAN      FromSmbios,
+  IN CHAR8        *IdString OPTIONAL
   );
   );
 
 
 /**
 /**
@@ -236,9 +236,9 @@ RedfishBuildPathWithSystemUuid (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishGetByService (
 RedfishGetByService (
-  IN     REDFISH_SERVICE      RedfishService,
-  IN     CONST CHAR8          *RedPath,
-  OUT    REDFISH_RESPONSE     *RedResponse
+  IN     REDFISH_SERVICE   RedfishService,
+  IN     CONST CHAR8       *RedPath,
+  OUT    REDFISH_RESPONSE  *RedResponse
   );
   );
 
 
 /**
 /**
@@ -266,9 +266,9 @@ RedfishGetByService (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishGetByUri (
 RedfishGetByUri (
-  IN     REDFISH_SERVICE      RedfishService,
-  IN     CONST CHAR8          *Uri,
-  OUT    REDFISH_RESPONSE     *RedResponse
+  IN     REDFISH_SERVICE   RedfishService,
+  IN     CONST CHAR8       *Uri,
+  OUT    REDFISH_RESPONSE  *RedResponse
   );
   );
 
 
 /**
 /**
@@ -300,9 +300,9 @@ RedfishGetByUri (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishGetByPayload (
 RedfishGetByPayload (
-  IN     REDFISH_PAYLOAD          Payload,
-  IN     CONST CHAR8              *RedPath,
-  OUT    REDFISH_RESPONSE         *RedResponse
+  IN     REDFISH_PAYLOAD   Payload,
+  IN     CONST CHAR8       *RedPath,
+  OUT    REDFISH_RESPONSE  *RedResponse
   );
   );
 
 
 /**
 /**
@@ -338,10 +338,10 @@ RedfishGetByPayload (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishPatchToUri (
 RedfishPatchToUri (
-  IN     REDFISH_SERVICE            RedfishService,
-  IN     CONST CHAR8                *Uri,
-  IN     CONST CHAR8                *Content,
-  OUT    REDFISH_RESPONSE           *RedResponse
+  IN     REDFISH_SERVICE   RedfishService,
+  IN     CONST CHAR8       *Uri,
+  IN     CONST CHAR8       *Content,
+  OUT    REDFISH_RESPONSE  *RedResponse
   );
   );
 
 
 /**
 /**
@@ -375,9 +375,9 @@ RedfishPatchToUri (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishPatchToPayload (
 RedfishPatchToPayload (
-  IN     REDFISH_PAYLOAD          Target,
-  IN     REDFISH_PAYLOAD          Payload,
-  OUT    REDFISH_RESPONSE         *RedResponse
+  IN     REDFISH_PAYLOAD   Target,
+  IN     REDFISH_PAYLOAD   Payload,
+  OUT    REDFISH_RESPONSE  *RedResponse
   );
   );
 
 
 /**
 /**
@@ -410,9 +410,9 @@ RedfishPatchToPayload (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishPostToPayload (
 RedfishPostToPayload (
-  IN     REDFISH_PAYLOAD          Target,
-  IN     REDFISH_PAYLOAD          Payload,
-  OUT    REDFISH_RESPONSE         *RedResponse
+  IN     REDFISH_PAYLOAD   Target,
+  IN     REDFISH_PAYLOAD   Payload,
+  OUT    REDFISH_RESPONSE  *RedResponse
   );
   );
 
 
 /**
 /**
@@ -445,9 +445,9 @@ RedfishPostToPayload (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishDeleteByUri (
 RedfishDeleteByUri (
-  IN     REDFISH_SERVICE            RedfishService,
-  IN     CONST CHAR8                *Uri,
-  OUT    REDFISH_RESPONSE           *RedResponse
+  IN     REDFISH_SERVICE   RedfishService,
+  IN     CONST CHAR8       *Uri,
+  OUT    REDFISH_RESPONSE  *RedResponse
   );
   );
 
 
 /**
 /**
@@ -458,7 +458,7 @@ RedfishDeleteByUri (
 **/
 **/
 VOID
 VOID
 RedfishDumpJsonStringFractions (
 RedfishDumpJsonStringFractions (
-  IN CHAR8 *String
+  IN CHAR8  *String
   );
   );
 
 
 /**
 /**
@@ -469,8 +469,9 @@ RedfishDumpJsonStringFractions (
 **/
 **/
 VOID
 VOID
 RedfishDumpPayload (
 RedfishDumpPayload (
-  IN REDFISH_PAYLOAD       Payload
+  IN REDFISH_PAYLOAD  Payload
   );
   );
+
 /**
 /**
   Dump text in JSON value.
   Dump text in JSON value.
 
 
@@ -481,6 +482,7 @@ VOID
 RedfishDumpJson (
 RedfishDumpJson (
   IN EDKII_JSON_VALUE  JsonValue
   IN EDKII_JSON_VALUE  JsonValue
   );
   );
+
 /**
 /**
   This function will cleanup the HTTP header and Redfish payload resources.
   This function will cleanup the HTTP header and Redfish payload resources.
 
 
@@ -511,10 +513,10 @@ RedfishFreeResponse (
 **/
 **/
 BOOLEAN
 BOOLEAN
 RedfishIsValidOdataType (
 RedfishIsValidOdataType (
-  IN REDFISH_PAYLOAD              Payload,
-  IN CONST CHAR8                  *OdataTypeName,
-  IN REDFISH_ODATA_TYPE_MAPPING   *OdataTypeMappingList,
-  IN UINTN                        OdataTypeMappingListSize
+  IN REDFISH_PAYLOAD             Payload,
+  IN CONST CHAR8                 *OdataTypeName,
+  IN REDFISH_ODATA_TYPE_MAPPING  *OdataTypeMappingList,
+  IN UINTN                       OdataTypeMappingListSize
   );
   );
 
 
 /**
 /**
@@ -527,8 +529,9 @@ RedfishIsValidOdataType (
 **/
 **/
 BOOLEAN
 BOOLEAN
 RedfishIsPayloadCollection (
 RedfishIsPayloadCollection (
-  IN REDFISH_PAYLOAD Payload
-);
+  IN REDFISH_PAYLOAD  Payload
+  );
+
 /**
 /**
   Get collection size.
   Get collection size.
 
 
@@ -539,10 +542,11 @@ RedfishIsPayloadCollection (
   @return EFI_INVALID_PARAMETER    The payload is not a collection.
   @return EFI_INVALID_PARAMETER    The payload is not a collection.
 **/
 **/
 EFI_STATUS
 EFI_STATUS
-RedfishGetCollectionSize(
-  IN REDFISH_PAYLOAD Payload,
-  IN UINTN *CollectionSize
-);
+RedfishGetCollectionSize (
+  IN REDFISH_PAYLOAD  Payload,
+  IN UINTN            *CollectionSize
+  );
+
 /**
 /**
   Get Redfish payload of collection member
   Get Redfish payload of collection member
 
 
@@ -554,9 +558,9 @@ RedfishGetCollectionSize(
 **/
 **/
 REDFISH_PAYLOAD
 REDFISH_PAYLOAD
 RedfishGetPayloadByIndex (
 RedfishGetPayloadByIndex (
-  IN REDFISH_PAYLOAD Payload,
-  IN UINTN  Index
-);
+  IN REDFISH_PAYLOAD  Payload,
+  IN UINTN            Index
+  );
 
 
 /**
 /**
   Check and return Redfish resource of the given Redpath.
   Check and return Redfish resource of the given Redpath.
@@ -569,10 +573,10 @@ RedfishGetPayloadByIndex (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishCheckIfRedpathExist (
 RedfishCheckIfRedpathExist (
-  IN REDFISH_SERVICE RedfishService,
-  IN CHAR8 *Redpath,
-  IN REDFISH_RESPONSE *Response OPTIONAL
-);
+  IN REDFISH_SERVICE   RedfishService,
+  IN CHAR8             *Redpath,
+  IN REDFISH_RESPONSE  *Response OPTIONAL
+  );
 
 
 /**
 /**
   This function returns the string of Redfish service version.
   This function returns the string of Redfish service version.
@@ -584,9 +588,9 @@ RedfishCheckIfRedpathExist (
 
 
 **/
 **/
 EFI_STATUS
 EFI_STATUS
-RedfishGetServiceVersion(
-  IN  REDFISH_SERVICE RedfishService,
-  OUT CHAR8 **ServiceVersionStr
+RedfishGetServiceVersion (
+  IN  REDFISH_SERVICE  RedfishService,
+  OUT CHAR8            **ServiceVersionStr
   );
   );
 
 
 /**
 /**
@@ -603,9 +607,10 @@ RedfishGetServiceVersion(
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishBuildRedpathUseId (
 RedfishBuildRedpathUseId (
-  IN  CHAR8 *ServiceVerisonStr,
-  IN  CHAR8 *Url,
-  IN  CHAR8 *Id,
-  OUT CHAR8 **Redpath
+  IN  CHAR8  *ServiceVerisonStr,
+  IN  CHAR8  *Url,
+  IN  CHAR8  *Id,
+  OUT CHAR8  **Redpath
   );
   );
+
 #endif
 #endif

+ 345 - 186
RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.c

@@ -14,17 +14,20 @@
 #include <Library/SortLib.h>
 #include <Library/SortLib.h>
 #include <Library/UefiRuntimeServicesTableLib.h>
 #include <Library/UefiRuntimeServicesTableLib.h>
 
 
-int  errno = 0;
-char errnum_message [] = "We don't support to map errnum to the error message on edk2 Redfish\n";
+int   errno            = 0;
+char  errnum_message[] = "We don't support to map errnum to the error message on edk2 Redfish\n";
 
 
 // This is required to keep VC++ happy if you use floating-point
 // This is required to keep VC++ happy if you use floating-point
-int _fltused  = 1;
+int  _fltused = 1;
 
 
 /**
 /**
   Determine if a particular character is an alphanumeric character
   Determine if a particular character is an alphanumeric character
   @return  Returns 1 if c is an alphanumeric character, otherwise returns 0.
   @return  Returns 1 if c is an alphanumeric character, otherwise returns 0.
 **/
 **/
-int isalnum (int c)
+int
+isalnum (
+  int  c
+  )
 {
 {
   //
   //
   // <alnum> ::= [0-9] | [a-z] | [A-Z]
   // <alnum> ::= [0-9] | [a-z] | [A-Z]
@@ -39,7 +42,10 @@ int isalnum (int c)
 
 
   @return  Returns 1 if c is an digital character, otherwise returns 0.
   @return  Returns 1 if c is an digital character, otherwise returns 0.
 **/
 **/
-int isdchar (int c)
+int
+isdchar (
+  int  c
+  )
 {
 {
   //
   //
   // [0-9] | [e +-.]
   // [0-9] | [e +-.]
@@ -55,7 +61,10 @@ int isdchar (int c)
 
 
   @return  Returns 1 if c is a space character
   @return  Returns 1 if c is a space character
 **/
 **/
-int isspace (int c)
+int
+isspace (
+  int  c
+  )
 {
 {
   //
   //
   // <space> ::= [ ]
   // <space> ::= [ ]
@@ -66,15 +75,21 @@ int isspace (int c)
 /**
 /**
   Allocates memory blocks
   Allocates memory blocks
 */
 */
-void *malloc (size_t size)
+void *
+malloc (
+  size_t  size
+  )
 {
 {
-  return AllocatePool ((UINTN) size);
+  return AllocatePool ((UINTN)size);
 }
 }
 
 
 /**
 /**
   De-allocates or frees a memory block
   De-allocates or frees a memory block
 */
 */
-void free (void *ptr)
+void
+free (
+  void  *ptr
+  )
 {
 {
   //
   //
   // In Standard C, free() handles a null pointer argument transparently. This
   // In Standard C, free() handles a null pointer argument transparently. This
@@ -90,15 +105,20 @@ void free (void *ptr)
 
 
   @return  Returns the pointer to duplicated string.
   @return  Returns the pointer to duplicated string.
 **/
 **/
-char * strdup(const char *str)
+char *
+strdup (
+  const char  *str
+  )
 {
 {
-  size_t len;
-  char *copy;
+  size_t  len;
+  char    *copy;
 
 
-  len = strlen(str) + 1;
-  if ((copy = malloc(len)) == NULL)
+  len = strlen (str) + 1;
+  if ((copy = malloc (len)) == NULL) {
     return (NULL);
     return (NULL);
-  memcpy(copy, str, len);
+  }
+
+  memcpy (copy, str, len);
   return (copy);
   return (copy);
 }
 }
 
 
@@ -115,13 +135,14 @@ char * strdup(const char *str)
               returned unchanged.
               returned unchanged.
 **/
 **/
 int
 int
-toupper(
-  IN  int c
+toupper (
+  IN  int  c
   )
   )
 {
 {
-  if ( (c >= 'a') && (c <= 'z') ) {
+  if ((c >= 'a') && (c <= 'z')) {
     c = c - ('a' - 'A');
     c = c - ('a' - 'A');
   }
   }
+
   return c;
   return c;
 }
 }
 
 
@@ -131,15 +152,18 @@ toupper(
   @return  Returns the value of digit.
   @return  Returns the value of digit.
 **/
 **/
 int
 int
-Digit2Val( int c)
+Digit2Val (
+  int  c
+  )
 {
 {
-  if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) {  /* If c is one of [A-Za-z]... */
-    c = toupper(c) - 7;   // Adjust so 'A' is ('9' + 1)
+  if (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))) {
+    /* If c is one of [A-Za-z]... */
+    c = toupper (c) - 7;   // Adjust so 'A' is ('9' + 1)
   }
   }
+
   return c - '0';   // Value returned is between 0 and 35, inclusive.
   return c - '0';   // Value returned is between 0 and 35, inclusive.
 }
 }
 
 
-
 /** The strtoll function converts the initial portion of the string pointed to
 /** The strtoll function converts the initial portion of the string pointed to
     by nptr to long long int representation.
     by nptr to long long int representation.
 
 
@@ -152,9 +176,13 @@ Digit2Val( int c)
             and the value of the macro ERANGE is stored in errno.
             and the value of the macro ERANGE is stored in errno.
 **/
 **/
 long long
 long long
-strtoll(const char * nptr, char ** endptr, int base)
+strtoll (
+  const char  *nptr,
+  char        **endptr,
+  int         base
+  )
 {
 {
-  const char *pEnd;
+  const char  *pEnd;
   long long   Result = 0;
   long long   Result = 0;
   long long   Previous;
   long long   Previous;
   int         temp;
   int         temp;
@@ -162,71 +190,86 @@ strtoll(const char * nptr, char ** endptr, int base)
 
 
   pEnd = nptr;
   pEnd = nptr;
 
 
-  if((base < 0) || (base == 1) || (base > 36)) {
-    if(endptr != NULL) {
-    *endptr = NULL;
+  if ((base < 0) || (base == 1) || (base > 36)) {
+    if (endptr != NULL) {
+      *endptr = NULL;
     }
     }
+
     return 0;
     return 0;
   }
   }
+
   // Skip leading spaces.
   // Skip leading spaces.
-  while(isspace(*nptr))   ++nptr;
+  while (isspace (*nptr)) {
+    ++nptr;
+  }
 
 
   // Process Subject sequence: optional sign followed by digits.
   // Process Subject sequence: optional sign followed by digits.
-  if(*nptr == '+') {
+  if (*nptr == '+') {
     Negative = FALSE;
     Negative = FALSE;
     ++nptr;
     ++nptr;
-  }
-  else if(*nptr == '-') {
+  } else if (*nptr == '-') {
     Negative = TRUE;
     Negative = TRUE;
     ++nptr;
     ++nptr;
   }
   }
 
 
-  if(*nptr == '0') {  /* Might be Octal or Hex */
-    if(toupper(nptr[1]) == 'X') {   /* Looks like Hex */
-      if((base == 0) || (base == 16)) {
+  if (*nptr == '0') {
+    /* Might be Octal or Hex */
+    if (toupper (nptr[1]) == 'X') {
+      /* Looks like Hex */
+      if ((base == 0) || (base == 16)) {
         nptr += 2;  /* Skip the "0X"      */
         nptr += 2;  /* Skip the "0X"      */
-        base = 16;  /* In case base was 0 */
+        base  = 16; /* In case base was 0 */
       }
       }
-    }
-    else {    /* Looks like Octal */
-      if((base == 0) || (base == 8)) {
+    } else {
+      /* Looks like Octal */
+      if ((base == 0) || (base == 8)) {
         ++nptr;     /* Skip the leading "0" */
         ++nptr;     /* Skip the leading "0" */
         base = 8;   /* In case base was 0   */
         base = 8;   /* In case base was 0   */
       }
       }
     }
     }
   }
   }
-  if(base == 0) {   /* If still zero then must be decimal */
+
+  if (base == 0) {
+    /* If still zero then must be decimal */
     base = 10;
     base = 10;
   }
   }
-  if(*nptr  == '0') {
-    for( ; *nptr == '0'; ++nptr);  /* Skip any remaining leading zeros */
+
+  if (*nptr  == '0') {
+    for ( ; *nptr == '0'; ++nptr) {
+      /* Skip any remaining leading zeros */
+    }
+
     pEnd = nptr;
     pEnd = nptr;
   }
   }
 
 
-  while( isalnum(*nptr) && ((temp = Digit2Val(*nptr)) < base)) {
+  while ( isalnum (*nptr) && ((temp = Digit2Val (*nptr)) < base)) {
     Previous = Result;
     Previous = Result;
-    Result = MultS64x64 (Result, base) + (long long int)temp;
-    if( Result <= Previous) {   // Detect Overflow
-      if(Negative) {
+    Result   = MultS64x64 (Result, base) + (long long int)temp;
+    if ( Result <= Previous) {
+      // Detect Overflow
+      if (Negative) {
         Result = LLONG_MIN;
         Result = LLONG_MIN;
-      }
-      else {
+      } else {
         Result = LLONG_MAX;
         Result = LLONG_MAX;
       }
       }
+
       Negative = FALSE;
       Negative = FALSE;
-      errno = ERANGE;
+      errno    = ERANGE;
       break;
       break;
     }
     }
+
     pEnd = ++nptr;
     pEnd = ++nptr;
   }
   }
-  if(Negative) {
+
+  if (Negative) {
     Result = -Result;
     Result = -Result;
   }
   }
 
 
   // Save pointer to final sequence
   // Save pointer to final sequence
-  if(endptr != NULL) {
+  if (endptr != NULL) {
     *endptr = (char *)pEnd;
     *endptr = (char *)pEnd;
   }
   }
+
   return Result;
   return Result;
 }
 }
 
 
@@ -285,9 +328,13 @@ strtoll(const char * nptr, char ** endptr, int base)
             is stored in errno.
             is stored in errno.
 **/
 **/
 long
 long
-strtol(const char * nptr, char ** endptr, int base)
+strtol (
+  const char  *nptr,
+  char        **endptr,
+  int         base
+  )
 {
 {
-  const char *pEnd;
+  const char  *pEnd;
   long        Result = 0;
   long        Result = 0;
   long        Previous;
   long        Previous;
   int         temp;
   int         temp;
@@ -295,71 +342,86 @@ strtol(const char * nptr, char ** endptr, int base)
 
 
   pEnd = nptr;
   pEnd = nptr;
 
 
-  if((base < 0) || (base == 1) || (base > 36)) {
-    if(endptr != NULL) {
-    *endptr = NULL;
+  if ((base < 0) || (base == 1) || (base > 36)) {
+    if (endptr != NULL) {
+      *endptr = NULL;
     }
     }
+
     return 0;
     return 0;
   }
   }
+
   // Skip leading spaces.
   // Skip leading spaces.
-  while(isspace(*nptr))   ++nptr;
+  while (isspace (*nptr)) {
+    ++nptr;
+  }
 
 
   // Process Subject sequence: optional sign followed by digits.
   // Process Subject sequence: optional sign followed by digits.
-  if(*nptr == '+') {
+  if (*nptr == '+') {
     Negative = FALSE;
     Negative = FALSE;
     ++nptr;
     ++nptr;
-  }
-  else if(*nptr == '-') {
+  } else if (*nptr == '-') {
     Negative = TRUE;
     Negative = TRUE;
     ++nptr;
     ++nptr;
   }
   }
 
 
-  if(*nptr == '0') {  /* Might be Octal or Hex */
-    if(toupper(nptr[1]) == 'X') {   /* Looks like Hex */
-      if((base == 0) || (base == 16)) {
+  if (*nptr == '0') {
+    /* Might be Octal or Hex */
+    if (toupper (nptr[1]) == 'X') {
+      /* Looks like Hex */
+      if ((base == 0) || (base == 16)) {
         nptr += 2;  /* Skip the "0X"      */
         nptr += 2;  /* Skip the "0X"      */
-        base = 16;  /* In case base was 0 */
+        base  = 16; /* In case base was 0 */
       }
       }
-    }
-    else {    /* Looks like Octal */
-      if((base == 0) || (base == 8)) {
+    } else {
+      /* Looks like Octal */
+      if ((base == 0) || (base == 8)) {
         ++nptr;     /* Skip the leading "0" */
         ++nptr;     /* Skip the leading "0" */
         base = 8;   /* In case base was 0   */
         base = 8;   /* In case base was 0   */
       }
       }
     }
     }
   }
   }
-  if(base == 0) {   /* If still zero then must be decimal */
+
+  if (base == 0) {
+    /* If still zero then must be decimal */
     base = 10;
     base = 10;
   }
   }
-  if(*nptr  == '0') {
-    for( ; *nptr == '0'; ++nptr);  /* Skip any remaining leading zeros */
+
+  if (*nptr  == '0') {
+    for ( ; *nptr == '0'; ++nptr) {
+      /* Skip any remaining leading zeros */
+    }
+
     pEnd = nptr;
     pEnd = nptr;
   }
   }
 
 
-  while( isalnum(*nptr) && ((temp = Digit2Val(*nptr)) < base)) {
+  while ( isalnum (*nptr) && ((temp = Digit2Val (*nptr)) < base)) {
     Previous = Result;
     Previous = Result;
-    Result = (Result * base) + (long int)temp;
-    if( Result <= Previous) {   // Detect Overflow
-      if(Negative) {
+    Result   = (Result * base) + (long int)temp;
+    if ( Result <= Previous) {
+      // Detect Overflow
+      if (Negative) {
         Result = LONG_MIN;
         Result = LONG_MIN;
-      }
-      else {
+      } else {
         Result = LONG_MAX;
         Result = LONG_MAX;
       }
       }
+
       Negative = FALSE;
       Negative = FALSE;
-      errno = ERANGE;
+      errno    = ERANGE;
       break;
       break;
     }
     }
+
     pEnd = ++nptr;
     pEnd = ++nptr;
   }
   }
-  if(Negative) {
+
+  if (Negative) {
     Result = -Result;
     Result = -Result;
   }
   }
 
 
   // Save pointer to final sequence
   // Save pointer to final sequence
-  if(endptr != NULL) {
+  if (endptr != NULL) {
     *endptr = (char *)pEnd;
     *endptr = (char *)pEnd;
   }
   }
+
   return Result;
   return Result;
 }
 }
 
 
@@ -374,66 +436,85 @@ strtol(const char * nptr, char ** endptr, int base)
             returned and the value of the macro ERANGE is stored in errno.
             returned and the value of the macro ERANGE is stored in errno.
 **/
 **/
 unsigned long long
 unsigned long long
-strtoull(const char * nptr, char ** endptr, int base)
+strtoull (
+  const char  *nptr,
+  char        **endptr,
+  int         base
+  )
 {
 {
-  const char           *pEnd;
-  unsigned long long    Result = 0;
-  unsigned long long    Previous;
-  int                   temp;
+  const char          *pEnd;
+  unsigned long long  Result = 0;
+  unsigned long long  Previous;
+  int                 temp;
 
 
   pEnd = nptr;
   pEnd = nptr;
 
 
-  if((base < 0) || (base == 1) || (base > 36)) {
-    if(endptr != NULL) {
-    *endptr = NULL;
+  if ((base < 0) || (base == 1) || (base > 36)) {
+    if (endptr != NULL) {
+      *endptr = NULL;
     }
     }
+
     return 0;
     return 0;
   }
   }
+
   // Skip leading spaces.
   // Skip leading spaces.
-  while(isspace(*nptr))   ++nptr;
+  while (isspace (*nptr)) {
+    ++nptr;
+  }
 
 
   // Process Subject sequence: optional + sign followed by digits.
   // Process Subject sequence: optional + sign followed by digits.
-  if(*nptr == '+') {
+  if (*nptr == '+') {
     ++nptr;
     ++nptr;
   }
   }
 
 
-  if(*nptr == '0') {  /* Might be Octal or Hex */
-    if(toupper(nptr[1]) == 'X') {   /* Looks like Hex */
-      if((base == 0) || (base == 16)) {
+  if (*nptr == '0') {
+    /* Might be Octal or Hex */
+    if (toupper (nptr[1]) == 'X') {
+      /* Looks like Hex */
+      if ((base == 0) || (base == 16)) {
         nptr += 2;  /* Skip the "0X"      */
         nptr += 2;  /* Skip the "0X"      */
-        base = 16;  /* In case base was 0 */
+        base  = 16; /* In case base was 0 */
       }
       }
-    }
-    else {    /* Looks like Octal */
-      if((base == 0) || (base == 8)) {
+    } else {
+      /* Looks like Octal */
+      if ((base == 0) || (base == 8)) {
         ++nptr;     /* Skip the leading "0" */
         ++nptr;     /* Skip the leading "0" */
         base = 8;   /* In case base was 0   */
         base = 8;   /* In case base was 0   */
       }
       }
     }
     }
   }
   }
-  if(base == 0) {   /* If still zero then must be decimal */
+
+  if (base == 0) {
+    /* If still zero then must be decimal */
     base = 10;
     base = 10;
   }
   }
-  if(*nptr  == '0') {
-    for( ; *nptr == '0'; ++nptr);  /* Skip any remaining leading zeros */
+
+  if (*nptr  == '0') {
+    for ( ; *nptr == '0'; ++nptr) {
+      /* Skip any remaining leading zeros */
+    }
+
     pEnd = nptr;
     pEnd = nptr;
   }
   }
 
 
-  while( isalnum(*nptr) && ((temp = Digit2Val(*nptr)) < base)) {
+  while ( isalnum (*nptr) && ((temp = Digit2Val (*nptr)) < base)) {
     Previous = Result;
     Previous = Result;
-    Result = DivU64x32 (Result, base) + (unsigned long long)temp;
-    if( Result < Previous)  {   // If we overflowed
+    Result   = DivU64x32 (Result, base) + (unsigned long long)temp;
+    if ( Result < Previous) {
+      // If we overflowed
       Result = ULLONG_MAX;
       Result = ULLONG_MAX;
-      errno = ERANGE;
+      errno  = ERANGE;
       break;
       break;
     }
     }
+
     pEnd = ++nptr;
     pEnd = ++nptr;
   }
   }
 
 
   // Save pointer to final sequence
   // Save pointer to final sequence
-  if(endptr != NULL) {
+  if (endptr != NULL) {
     *endptr = (char *)pEnd;
     *endptr = (char *)pEnd;
   }
   }
+
   return Result;
   return Result;
 }
 }
 
 
@@ -462,27 +543,34 @@ strtoull(const char * nptr, char ** endptr, int base)
   @return  Return 0.
   @return  Return 0.
 **/
 **/
 double
 double
-strtod (const char * __restrict nptr, char ** __restrict endptr) {
-
-    DEBUG((DEBUG_INFO, "We don't supprot double type on edk2 yet!"));
-    ASSERT(FALSE);
-    return (double)0;
+strtod (
+  const char *__restrict  nptr,
+  char **__restrict       endptr
+  )
+{
+  DEBUG ((DEBUG_INFO, "We don't supprot double type on edk2 yet!"));
+  ASSERT (FALSE);
+  return (double)0;
 }
 }
 
 
 static UINT8  BitMask[] = {
 static UINT8  BitMask[] = {
   0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
   0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
-  };
+};
 
 
 #define WHICH8(c)     ((unsigned char)(c) >> 3)
 #define WHICH8(c)     ((unsigned char)(c) >> 3)
 #define WHICH_BIT(c)  (BitMask[((c) & 0x7)])
 #define WHICH_BIT(c)  (BitMask[((c) & 0x7)])
-#define BITMAP64      ((UINT64 *)bitmap)
+#define BITMAP64  ((UINT64 *)bitmap)
 
 
 static
 static
 void
 void
-BuildBitmap(unsigned char * bitmap, const char *s2, int n)
+BuildBitmap (
+  unsigned char  *bitmap,
+  const char     *s2,
+  int            n
+  )
 {
 {
-  unsigned char bit;
-  int           index;
+  unsigned char  bit;
+  int            index;
 
 
   // Initialize bitmap.  Bit 0 is always 1 which corresponds to '\0'
   // Initialize bitmap.  Bit 0 is always 1 which corresponds to '\0'
   for (BITMAP64[0] = index = 1; index < n; index++) {
   for (BITMAP64[0] = index = 1; index < n; index++) {
@@ -490,9 +578,9 @@ BuildBitmap(unsigned char * bitmap, const char *s2, int n)
   }
   }
 
 
   // Set bits in bitmap corresponding to the characters in s2
   // Set bits in bitmap corresponding to the characters in s2
-  for (; *s2 != '\0'; s2++) {
-    index = WHICH8(*s2);
-    bit = WHICH_BIT(*s2);
+  for ( ; *s2 != '\0'; s2++) {
+    index         = WHICH8 (*s2);
+    bit           = WHICH_BIT (*s2);
     bitmap[index] = bitmap[index] | bit;
     bitmap[index] = bitmap[index] | bit;
   }
   }
 }
 }
@@ -504,21 +592,25 @@ BuildBitmap(unsigned char * bitmap, const char *s2, int n)
               null pointer if no character from s2 occurs in s1.
               null pointer if no character from s2 occurs in s1.
 **/
 **/
 char *
 char *
-strpbrk(const char *s1, const char *s2)
+strpbrk (
+  const char  *s1,
+  const char  *s2
+  )
 {
 {
-  UINT8 bitmap[ (((UCHAR_MAX + 1) / CHAR_BIT) + (CHAR_BIT - 1)) & ~7U];
-  UINT8 bit;
-  int index;
+  UINT8  bitmap[(((UCHAR_MAX + 1) / CHAR_BIT) + (CHAR_BIT - 1)) & ~7U];
+  UINT8  bit;
+  int    index;
 
 
-  BuildBitmap( bitmap, s2, sizeof(bitmap) / sizeof(UINT64));
+  BuildBitmap (bitmap, s2, sizeof (bitmap) / sizeof (UINT64));
 
 
-  for( ; *s1 != '\0'; ++s1) {
-    index = WHICH8(*s1);
-    bit = WHICH_BIT(*s1);
-    if( (bitmap[index] & bit) != 0) {
+  for ( ; *s1 != '\0'; ++s1) {
+    index = WHICH8 (*s1);
+    bit   = WHICH_BIT (*s1);
+    if ((bitmap[index] & bit) != 0) {
       return (char *)s1;
       return (char *)s1;
     }
     }
   }
   }
+
   return NULL;
   return NULL;
 }
 }
 
 
@@ -535,7 +627,9 @@ strpbrk(const char *s1, const char *s2)
               a subsequent call to the strerror function.
               a subsequent call to the strerror function.
 **/
 **/
 char *
 char *
-strerror(int errnum)
+strerror (
+  int  errnum
+  )
 {
 {
   return errnum_message;
   return errnum_message;
 }
 }
@@ -544,20 +638,24 @@ strerror(int errnum)
   Allocate and zero-initialize array.
   Allocate and zero-initialize array.
 **/
 **/
 void *
 void *
-calloc(size_t Num, size_t Size)
+calloc (
+  size_t  Num,
+  size_t  Size
+  )
 {
 {
-  void       *RetVal;
-  size_t      NumSize;
+  void    *RetVal;
+  size_t  NumSize;
 
 
   NumSize = Num * Size;
   NumSize = Num * Size;
   RetVal  = NULL;
   RetVal  = NULL;
   if (NumSize != 0) {
   if (NumSize != 0) {
-  RetVal = malloc(NumSize);
-  if( RetVal != NULL) {
-    (VOID)ZeroMem( RetVal, NumSize);
-  }
+    RetVal = malloc (NumSize);
+    if ( RetVal != NULL) {
+      (VOID)ZeroMem (RetVal, NumSize);
+    }
   }
   }
-  DEBUG((DEBUG_POOL, "0x%p = calloc(%d, %d)\n", RetVal, Num, Size));
+
+  DEBUG ((DEBUG_POOL, "0x%p = calloc(%d, %d)\n", RetVal, Num, Size));
 
 
   return RetVal;
   return RetVal;
 }
 }
@@ -567,7 +665,7 @@ calloc(size_t Num, size_t Size)
 //  month number used as the index (1 -> 12) for regular and leap years.
 //  month number used as the index (1 -> 12) for regular and leap years.
 //  The value at index 13 is for the whole year.
 //  The value at index 13 is for the whole year.
 //
 //
-UINTN CumulativeDays[2][14] = {
+UINTN  CumulativeDays[2][14] = {
   {
   {
     0,
     0,
     0,
     0,
@@ -602,15 +700,18 @@ UINTN CumulativeDays[2][14] = {
   }
   }
 };
 };
 
 
-#define IsLeap(y)   (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
-#define SECSPERMIN  (60)
-#define SECSPERHOUR (60 * 60)
-#define SECSPERDAY  (24 * SECSPERHOUR)
+#define IsLeap(y)  (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
+#define SECSPERMIN   (60)
+#define SECSPERHOUR  (60 * 60)
+#define SECSPERDAY   (24 * SECSPERHOUR)
 
 
 /**
 /**
   Get the system time as seconds elapsed since midnight, January 1, 1970.
   Get the system time as seconds elapsed since midnight, January 1, 1970.
 **/
 **/
-time_t time (time_t *timer)
+time_t
+time (
+  time_t  *timer
+  )
 {
 {
   EFI_TIME  Time;
   EFI_TIME  Time;
   time_t    CalTime;
   time_t    CalTime;
@@ -626,7 +727,7 @@ time_t time (time_t *timer)
   // UTime should now be set to 00:00:00 on Jan 1 of the current year.
   // UTime should now be set to 00:00:00 on Jan 1 of the current year.
   //
   //
   for (Year = 1970, CalTime = 0; Year != Time.Year; Year++) {
   for (Year = 1970, CalTime = 0; Year != Time.Year; Year++) {
-    CalTime = CalTime + (time_t)(CumulativeDays[IsLeap(Year)][13] * SECSPERDAY);
+    CalTime = CalTime + (time_t)(CumulativeDays[IsLeap (Year)][13] * SECSPERDAY);
   }
   }
 
 
   //
   //
@@ -634,7 +735,7 @@ time_t time (time_t *timer)
   //
   //
   CalTime = CalTime +
   CalTime = CalTime +
             (time_t)((Time.TimeZone != EFI_UNSPECIFIED_TIMEZONE) ? (Time.TimeZone * 60) : 0) +
             (time_t)((Time.TimeZone != EFI_UNSPECIFIED_TIMEZONE) ? (Time.TimeZone * 60) : 0) +
-            (time_t)(CumulativeDays[IsLeap(Time.Year)][Time.Month] * SECSPERDAY) +
+            (time_t)(CumulativeDays[IsLeap (Time.Year)][Time.Month] * SECSPERDAY) +
             (time_t)(((Time.Day > 0) ? Time.Day - 1 : 0) * SECSPERDAY) +
             (time_t)(((Time.Day > 0) ? Time.Day - 1 : 0) * SECSPERDAY) +
             (time_t)(Time.Hour * SECSPERHOUR) +
             (time_t)(Time.Hour * SECSPERHOUR) +
             (time_t)(Time.Minute * 60) +
             (time_t)(Time.Minute * 60) +
@@ -650,9 +751,14 @@ time_t time (time_t *timer)
 /**
 /**
   Performs a quick sort
   Performs a quick sort
 **/
 **/
-void qsort (void *base, size_t num, size_t width, int (*compare)(const void *, const void *))
+void
+qsort (
+  void *base,
+  size_t num,
+  size_t width,
+  int ( *compare )(const void *, const void *)
+  )
 {
 {
-
   ASSERT (base    != NULL);
   ASSERT (base    != NULL);
   ASSERT (compare != NULL);
   ASSERT (compare != NULL);
 
 
@@ -666,54 +772,93 @@ void qsort (void *base, size_t num, size_t width, int (*compare)(const void *, c
   @return Returns the character currently pointed by the internal file position indicator of the specified stream
   @return Returns the character currently pointed by the internal file position indicator of the specified stream
 
 
 **/
 **/
-int fgetc(FILE * _File){
-   return EOF;
+int
+fgetc (
+  FILE  *_File
+  )
+{
+  return EOF;
 }
 }
+
 /**
 /**
   Open stream file, we don't support file operastion on edk2 JSON library.
   Open stream file, we don't support file operastion on edk2 JSON library.
 
 
   @return 0 Unsupported
   @return 0 Unsupported
 
 
 **/
 **/
-FILE *fopen (const char *filename, const char *mode) {
+FILE *
+fopen (
+  const char  *filename,
+  const char  *mode
+  )
+{
   return NULL;
   return NULL;
 }
 }
+
 /**
 /**
   Read stream from file, we don't support file operastion on edk2 JSON library.
   Read stream from file, we don't support file operastion on edk2 JSON library.
 
 
   @return 0 Unsupported
   @return 0 Unsupported
 
 
 **/
 **/
-size_t fread (void * ptr, size_t size, size_t count, FILE * stream) {
+size_t
+fread (
+  void    *ptr,
+  size_t  size,
+  size_t  count,
+  FILE    *stream
+  )
+{
   return 0;
   return 0;
 }
 }
+
 /**
 /**
   Write stream from file, we don't support file operastion on edk2 JSON library.
   Write stream from file, we don't support file operastion on edk2 JSON library.
 
 
   @return 0 Unsupported
   @return 0 Unsupported
 
 
 **/
 **/
-size_t fwrite (const void * ptr, size_t size, size_t count, FILE * stream) {
+size_t
+fwrite (
+  const void  *ptr,
+  size_t      size,
+  size_t      count,
+  FILE        *stream
+  )
+{
   return 0;
   return 0;
 }
 }
+
 /**
 /**
   Close file, we don't support file operastion on edk2 JSON library.
   Close file, we don't support file operastion on edk2 JSON library.
 
 
   @return 0 Unsupported
   @return 0 Unsupported
 
 
 **/
 **/
-int fclose (FILE * stream) {
+int
+fclose (
+  FILE  *stream
+  )
+{
   return EOF;
   return EOF;
 }
 }
+
 /**
 /**
   Write the formatted string to file, we don't support file operastion on edk2 JSON library.
   Write the formatted string to file, we don't support file operastion on edk2 JSON library.
 
 
   @return 0 Unsupported
   @return 0 Unsupported
 
 
 **/
 **/
-int fprintf (FILE * stream, const char * format, ...) {
+int
+fprintf (
+  FILE        *stream,
+  const char  *format,
+  ...
+  )
+{
   return -1;
   return -1;
 }
 }
+
 /**
 /**
   This function check if this is the formating string specifier.
   This function check if this is the formating string specifier.
 
 
@@ -730,12 +875,12 @@ int fprintf (FILE * stream, const char * format, ...) {
 **/
 **/
 BOOLEAN
 BOOLEAN
 CheckFormatingString (
 CheckFormatingString (
-  IN     CONST CHAR8 *FormatString,
-  IN OUT UINTN       *CurrentPosition,
-  IN     UINTN       StrLength
+  IN     CONST CHAR8  *FormatString,
+  IN OUT UINTN        *CurrentPosition,
+  IN     UINTN        StrLength
   )
   )
 {
 {
-  CHAR8 FormatStringParamater;
+  CHAR8  FormatStringParamater;
 
 
   while (*(FormatString + *CurrentPosition) != 's') {
   while (*(FormatString + *CurrentPosition) != 's') {
     //
     //
@@ -749,14 +894,17 @@ CheckFormatingString (
         (FormatStringParamater != '*') &&
         (FormatStringParamater != '*') &&
         (FormatStringParamater != '.') &&
         (FormatStringParamater != '.') &&
         !(((UINTN)FormatStringParamater >= (UINTN)'0') && ((UINTN)FormatStringParamater <= (UINTN)'9'))
         !(((UINTN)FormatStringParamater >= (UINTN)'0') && ((UINTN)FormatStringParamater <= (UINTN)'9'))
-        ) {
+        )
+    {
       return FALSE;
       return FALSE;
     }
     }
+
     (*CurrentPosition)++;
     (*CurrentPosition)++;
     if (*CurrentPosition >= StrLength) {
     if (*CurrentPosition >= StrLength) {
       return FALSE;
       return FALSE;
     }
     }
-  };
+  }
+
   return TRUE;
   return TRUE;
 }
 }
 
 
@@ -772,15 +920,15 @@ CheckFormatingString (
 **/
 **/
 CHAR8 *
 CHAR8 *
 ReplaceUnicodeToAsciiStrFormat (
 ReplaceUnicodeToAsciiStrFormat (
-  IN CONST CHAR8 *FormatString
-)
+  IN CONST CHAR8  *FormatString
+  )
 {
 {
-  UINTN FormatStrSize;
-  UINTN FormatStrIndex;
-  UINTN FormatStrSpecifier;
-  BOOLEAN PercentageMark;
-  CHAR8 *TempFormatBuffer;
-  BOOLEAN IsFormatString;
+  UINTN    FormatStrSize;
+  UINTN    FormatStrIndex;
+  UINTN    FormatStrSpecifier;
+  BOOLEAN  PercentageMark;
+  CHAR8    *TempFormatBuffer;
+  BOOLEAN  IsFormatString;
 
 
   //
   //
   // Error checking.
   // Error checking.
@@ -788,15 +936,18 @@ ReplaceUnicodeToAsciiStrFormat (
   if (FormatString == NULL) {
   if (FormatString == NULL) {
     return NULL;
     return NULL;
   }
   }
-  FormatStrSize = AsciiStrSize(FormatString);
+
+  FormatStrSize = AsciiStrSize (FormatString);
   if (FormatStrSize == 0) {
   if (FormatStrSize == 0) {
     return NULL;
     return NULL;
   }
   }
-  TempFormatBuffer = AllocatePool(FormatStrSize); // Allocate memory for the
-                                                  // new string.
-  if (TempFormatBuffer== NULL) {
+
+  TempFormatBuffer = AllocatePool (FormatStrSize); // Allocate memory for the
+                                                   // new string.
+  if (TempFormatBuffer == NULL) {
     return NULL;
     return NULL;
   }
   }
+
   //
   //
   // Clone *FormatString but replace "%s" wih "%a".
   // Clone *FormatString but replace "%s" wih "%a".
   // "%%" is not considered as the format tag.
   // "%%" is not considered as the format tag.
@@ -809,18 +960,21 @@ ReplaceUnicodeToAsciiStrFormat (
       // Previous character is "%".
       // Previous character is "%".
       //
       //
       PercentageMark = FALSE;
       PercentageMark = FALSE;
-      if (*(FormatString + FormatStrIndex) != '%') { // Check if this is double "%".
+      if (*(FormatString + FormatStrIndex) != '%') {
+        // Check if this is double "%".
         FormatStrSpecifier = FormatStrIndex;
         FormatStrSpecifier = FormatStrIndex;
         //
         //
         // Check if this is the formating string specifier.
         // Check if this is the formating string specifier.
         //
         //
         IsFormatString = CheckFormatingString (FormatString, &FormatStrSpecifier, FormatStrSize);
         IsFormatString = CheckFormatingString (FormatString, &FormatStrSpecifier, FormatStrSize);
         if ((FormatStrSpecifier - FormatStrIndex) != 0) {
         if ((FormatStrSpecifier - FormatStrIndex) != 0) {
-          CopyMem((VOID *)(TempFormatBuffer + FormatStrIndex),
-                  (VOID *)(FormatString + FormatStrIndex),
-                  FormatStrSpecifier - FormatStrIndex
-                  );
+          CopyMem (
+            (VOID *)(TempFormatBuffer + FormatStrIndex),
+            (VOID *)(FormatString + FormatStrIndex),
+            FormatStrSpecifier - FormatStrIndex
+            );
         }
         }
+
         FormatStrIndex = FormatStrSpecifier;
         FormatStrIndex = FormatStrSpecifier;
         if (IsFormatString == TRUE) {
         if (IsFormatString == TRUE) {
           //
           //
@@ -828,18 +982,22 @@ ReplaceUnicodeToAsciiStrFormat (
           // format on edk2 environment.
           // format on edk2 environment.
           //
           //
           *(TempFormatBuffer + FormatStrSpecifier) = 'a';
           *(TempFormatBuffer + FormatStrSpecifier) = 'a';
-          FormatStrIndex ++;
+          FormatStrIndex++;
         }
         }
+
         continue;
         continue;
       }
       }
+
       goto ContinueCheck;
       goto ContinueCheck;
     }
     }
+
     if (*(FormatString + FormatStrIndex) == '%') {
     if (*(FormatString + FormatStrIndex) == '%') {
       //
       //
       // This character is "%", set the flag.
       // This character is "%", set the flag.
       //
       //
       PercentageMark = TRUE;
       PercentageMark = TRUE;
     }
     }
+
 ContinueCheck:
 ContinueCheck:
     //
     //
     // Clone character to the new string and advance FormatStrIndex
     // Clone character to the new string and advance FormatStrIndex
@@ -847,7 +1005,8 @@ ContinueCheck:
     //
     //
     *(TempFormatBuffer + FormatStrIndex) = *(FormatString + FormatStrIndex);
     *(TempFormatBuffer + FormatStrIndex) = *(FormatString + FormatStrIndex);
     FormatStrIndex++;
     FormatStrIndex++;
-  };
+  }
+
   return TempFormatBuffer;
   return TempFormatBuffer;
 }
 }
 
 
@@ -870,14 +1029,14 @@ ContinueCheck:
 UINTN
 UINTN
 EFIAPI
 EFIAPI
 RedfishAsciiVSPrint (
 RedfishAsciiVSPrint (
-  OUT CHAR8         *StartOfBuffer,
-  IN  UINTN         BufferSize,
-  IN  CONST CHAR8   *FormatString,
-  IN  VA_LIST       Marker
+  OUT CHAR8        *StartOfBuffer,
+  IN  UINTN        BufferSize,
+  IN  CONST CHAR8  *FormatString,
+  IN  VA_LIST      Marker
   )
   )
 {
 {
-  CHAR8 *TempFormatBuffer;
-  UINTN LenStrProduced;
+  CHAR8  *TempFormatBuffer;
+  UINTN  LenStrProduced;
 
 
   //
   //
   // Looking for "%s" in the format string and replace it
   // Looking for "%s" in the format string and replace it
@@ -888,6 +1047,7 @@ RedfishAsciiVSPrint (
   if (TempFormatBuffer == NULL) {
   if (TempFormatBuffer == NULL) {
     return 0;
     return 0;
   }
   }
+
   LenStrProduced = AsciiVSPrint (StartOfBuffer, BufferSize, (CONST CHAR8 *)TempFormatBuffer, Marker);
   LenStrProduced = AsciiVSPrint (StartOfBuffer, BufferSize, (CONST CHAR8 *)TempFormatBuffer, Marker);
   FreePool (TempFormatBuffer);
   FreePool (TempFormatBuffer);
   return LenStrProduced;
   return LenStrProduced;
@@ -919,11 +1079,10 @@ RedfishAsciiSPrint (
   ...
   ...
   )
   )
 {
 {
-  VA_LIST Marker;
-  UINTN LenStrProduced;
+  VA_LIST  Marker;
+  UINTN    LenStrProduced;
 
 
-  VA_START(Marker, FormatString);
+  VA_START (Marker, FormatString);
   LenStrProduced = RedfishAsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
   LenStrProduced = RedfishAsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
   return LenStrProduced;
   return LenStrProduced;
 }
 }
-

+ 191 - 151
RedfishPkg/PrivateLibrary/RedfishLib/RedfishLib.c

@@ -27,7 +27,7 @@
 REDFISH_SERVICE
 REDFISH_SERVICE
 EFIAPI
 EFIAPI
 RedfishCreateService (
 RedfishCreateService (
-  IN  REDFISH_CONFIG_SERVICE_INFORMATION   *RedfishConfigServiceInfo
+  IN  REDFISH_CONFIG_SERVICE_INFORMATION  *RedfishConfigServiceInfo
   )
   )
 {
 {
   REDFISH_SERVICE            RedfishService;
   REDFISH_SERVICE            RedfishService;
@@ -69,7 +69,8 @@ ON_EXIT:
   if (UserId != NULL) {
   if (UserId != NULL) {
     FreePool (UserId);
     FreePool (UserId);
   }
   }
-  if (Password!= NULL) {
+
+  if (Password != NULL) {
     FreePool (Password);
     FreePool (Password);
   }
   }
 
 
@@ -85,7 +86,7 @@ ON_EXIT:
 VOID
 VOID
 EFIAPI
 EFIAPI
 RedfishCleanupService (
 RedfishCleanupService (
-  IN REDFISH_SERVICE   RedfishService
+  IN REDFISH_SERVICE  RedfishService
   )
   )
 {
 {
   if (RedfishService == NULL) {
   if (RedfishService == NULL) {
@@ -94,6 +95,7 @@ RedfishCleanupService (
 
 
   cleanupServiceEnumerator (RedfishService);
   cleanupServiceEnumerator (RedfishService);
 }
 }
+
 /**
 /**
   Create REDFISH_PAYLOAD instance in local with JSON represented resource value and
   Create REDFISH_PAYLOAD instance in local with JSON represented resource value and
   the Redfish Service.
   the Redfish Service.
@@ -112,11 +114,11 @@ RedfishCleanupService (
 REDFISH_PAYLOAD
 REDFISH_PAYLOAD
 EFIAPI
 EFIAPI
 RedfishCreatePayload (
 RedfishCreatePayload (
-  IN EDKII_JSON_VALUE           Value,
-  IN REDFISH_SERVICE            RedfishService
+  IN EDKII_JSON_VALUE  Value,
+  IN REDFISH_SERVICE   RedfishService
   )
   )
 {
 {
-  EDKII_JSON_VALUE    CopyValue;
+  EDKII_JSON_VALUE  CopyValue;
 
 
   CopyValue = JsonValueClone (Value);
   CopyValue = JsonValueClone (Value);
   return createRedfishPayload (CopyValue, RedfishService);
   return createRedfishPayload (CopyValue, RedfishService);
@@ -131,14 +133,14 @@ RedfishCreatePayload (
 VOID
 VOID
 EFIAPI
 EFIAPI
 RedfishCleanupPayload (
 RedfishCleanupPayload (
-  IN REDFISH_PAYLOAD          Payload
+  IN REDFISH_PAYLOAD  Payload
   )
   )
 {
 {
   if (Payload == NULL) {
   if (Payload == NULL) {
     return;
     return;
   }
   }
 
 
-  cleanupPayload ((redfishPayload *) Payload);
+  cleanupPayload ((redfishPayload *)Payload);
 }
 }
 
 
 /**
 /**
@@ -155,14 +157,14 @@ RedfishCleanupPayload (
 EDKII_JSON_VALUE
 EDKII_JSON_VALUE
 EFIAPI
 EFIAPI
 RedfishJsonInPayload (
 RedfishJsonInPayload (
-  IN REDFISH_PAYLOAD          Payload
+  IN REDFISH_PAYLOAD  Payload
   )
   )
 {
 {
   if (Payload == NULL) {
   if (Payload == NULL) {
     return NULL;
     return NULL;
   }
   }
 
 
-  return ((redfishPayload*)Payload)->json;
+  return ((redfishPayload *)Payload)->json;
 }
 }
 
 
 /**
 /**
@@ -187,15 +189,15 @@ RedfishJsonInPayload (
 CHAR8 *
 CHAR8 *
 EFIAPI
 EFIAPI
 RedfishBuildPathWithSystemUuid (
 RedfishBuildPathWithSystemUuid (
-  IN CONST CHAR8    *RedPath,
-  IN BOOLEAN        FromSmbios,
-  IN CHAR8          *IdString OPTIONAL
+  IN CONST CHAR8  *RedPath,
+  IN BOOLEAN      FromSmbios,
+  IN CHAR8        *IdString OPTIONAL
   )
   )
 {
 {
-  UINTN          BufSize;
-  CHAR8*         RetRedPath;
-  EFI_GUID       SystemUuid;
-  EFI_STATUS     Status;
+  UINTN       BufSize;
+  CHAR8       *RetRedPath;
+  EFI_GUID    SystemUuid;
+  EFI_STATUS  Status;
 
 
   if (RedPath == NULL) {
   if (RedPath == NULL) {
     return NULL;
     return NULL;
@@ -205,10 +207,11 @@ RedfishBuildPathWithSystemUuid (
   // Find system UUID from SMBIOS table.
   // Find system UUID from SMBIOS table.
   //
   //
   if (FromSmbios) {
   if (FromSmbios) {
-    Status = NetLibGetSystemGuid(&SystemUuid);
+    Status = NetLibGetSystemGuid (&SystemUuid);
     if (EFI_ERROR (Status)) {
     if (EFI_ERROR (Status)) {
       return NULL;
       return NULL;
     }
     }
+
     // AsciiStrLen ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") = 36
     // AsciiStrLen ("xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") = 36
     BufSize = AsciiStrSize (RedPath) + AsciiStrLen ("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
     BufSize = AsciiStrSize (RedPath) + AsciiStrLen ("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
   } else {
   } else {
@@ -219,13 +222,16 @@ RedfishBuildPathWithSystemUuid (
   if (RetRedPath == NULL) {
   if (RetRedPath == NULL) {
     return NULL;
     return NULL;
   }
   }
+
   if (FromSmbios) {
   if (FromSmbios) {
     AsciiSPrint (RetRedPath, BufSize, RedPath, &SystemUuid);
     AsciiSPrint (RetRedPath, BufSize, RedPath, &SystemUuid);
   } else {
   } else {
     AsciiSPrint (RetRedPath, BufSize, RedPath, IdString);
     AsciiSPrint (RetRedPath, BufSize, RedPath, IdString);
   }
   }
+
   return RetRedPath;
   return RetRedPath;
 }
 }
+
 /**
 /**
   Get a redfish response addressed by a RedPath string, including HTTP StatusCode, Headers
   Get a redfish response addressed by a RedPath string, including HTTP StatusCode, Headers
   and Payload which record any HTTP response messages.
   and Payload which record any HTTP response messages.
@@ -252,24 +258,24 @@ RedfishBuildPathWithSystemUuid (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishGetByService (
 RedfishGetByService (
-  IN     REDFISH_SERVICE      RedfishService,
-  IN     CONST CHAR8          *RedPath,
-  OUT    REDFISH_RESPONSE     *RedResponse
+  IN     REDFISH_SERVICE   RedfishService,
+  IN     CONST CHAR8       *RedPath,
+  OUT    REDFISH_RESPONSE  *RedResponse
   )
   )
 {
 {
-  if (RedfishService == NULL || RedPath == NULL || RedResponse == NULL) {
+  if ((RedfishService == NULL) || (RedPath == NULL) || (RedResponse == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
   ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
   ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
 
 
-  RedResponse->Payload = (REDFISH_PAYLOAD) getPayloadByPath (RedfishService, RedPath, &(RedResponse->StatusCode));
+  RedResponse->Payload = (REDFISH_PAYLOAD)getPayloadByPath (RedfishService, RedPath, &(RedResponse->StatusCode));
 
 
   //
   //
   // 1. If the returned Payload is NULL, indicates any error happen.
   // 1. If the returned Payload is NULL, indicates any error happen.
   // 2. If the returned StatusCode is NULL, indicates any error happen.
   // 2. If the returned StatusCode is NULL, indicates any error happen.
   //
   //
-  if (RedResponse->Payload == NULL || RedResponse->StatusCode == NULL) {
+  if ((RedResponse->Payload == NULL) || (RedResponse->StatusCode == NULL)) {
     return EFI_DEVICE_ERROR;
     return EFI_DEVICE_ERROR;
   }
   }
 
 
@@ -278,13 +284,15 @@ RedfishGetByService (
   //    NOTE: If there is any error message returned from server, it will be returned in
   //    NOTE: If there is any error message returned from server, it will be returned in
   //          Payload within RedResponse.
   //          Payload within RedResponse.
   //
   //
-  if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \
-      *(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) {
+  if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
+      (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
+  {
     return EFI_DEVICE_ERROR;
     return EFI_DEVICE_ERROR;
   }
   }
 
 
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }
+
 /**
 /**
   Get a redfish response addressed by URI, including HTTP StatusCode, Headers
   Get a redfish response addressed by URI, including HTTP StatusCode, Headers
   and Payload which record any HTTP response messages.
   and Payload which record any HTTP response messages.
@@ -310,27 +318,27 @@ RedfishGetByService (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishGetByUri (
 RedfishGetByUri (
-  IN     REDFISH_SERVICE      RedfishService,
-  IN     CONST CHAR8          *Uri,
-  OUT    REDFISH_RESPONSE     *RedResponse
+  IN     REDFISH_SERVICE   RedfishService,
+  IN     CONST CHAR8       *Uri,
+  OUT    REDFISH_RESPONSE  *RedResponse
   )
   )
 {
 {
-  EDKII_JSON_VALUE JsonValue;
+  EDKII_JSON_VALUE  JsonValue;
 
 
-  if (RedfishService == NULL || Uri == NULL || RedResponse == NULL) {
+  if ((RedfishService == NULL) || (Uri == NULL) || (RedResponse == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
   ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
   ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
 
 
-  JsonValue = getUriFromService (RedfishService, Uri, &RedResponse->StatusCode);
-  RedResponse->Payload = createRedfishPayload(JsonValue, RedfishService);
+  JsonValue            = getUriFromService (RedfishService, Uri, &RedResponse->StatusCode);
+  RedResponse->Payload = createRedfishPayload (JsonValue, RedfishService);
 
 
   //
   //
   // 1. If the returned Payload is NULL, indicates any error happen.
   // 1. If the returned Payload is NULL, indicates any error happen.
   // 2. If the returned StatusCode is NULL, indicates any error happen.
   // 2. If the returned StatusCode is NULL, indicates any error happen.
   //
   //
-  if (RedResponse->Payload == NULL || RedResponse->StatusCode == NULL) {
+  if ((RedResponse->Payload == NULL) || (RedResponse->StatusCode == NULL)) {
     return EFI_DEVICE_ERROR;
     return EFI_DEVICE_ERROR;
   }
   }
 
 
@@ -339,12 +347,15 @@ RedfishGetByUri (
   //    NOTE: If there is any error message returned from server, it will be returned in
   //    NOTE: If there is any error message returned from server, it will be returned in
   //          Payload within RedResponse.
   //          Payload within RedResponse.
   //
   //
-  if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \
-      *(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) {
+  if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
+      (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
+  {
     return EFI_DEVICE_ERROR;
     return EFI_DEVICE_ERROR;
   }
   }
+
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }
+
 /**
 /**
   Get a redfish response addressed by the input Payload and relative RedPath string,
   Get a redfish response addressed by the input Payload and relative RedPath string,
   including HTTP StatusCode, Headers and Payload which record any HTTP response messages.
   including HTTP StatusCode, Headers and Payload which record any HTTP response messages.
@@ -374,18 +385,18 @@ RedfishGetByUri (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishGetByPayload (
 RedfishGetByPayload (
-  IN     REDFISH_PAYLOAD          Payload,
-  IN     CONST CHAR8              *RedPath,
-  OUT    REDFISH_RESPONSE         *RedResponse
+  IN     REDFISH_PAYLOAD   Payload,
+  IN     CONST CHAR8       *RedPath,
+  OUT    REDFISH_RESPONSE  *RedResponse
   )
   )
 {
 {
-  if (Payload == NULL || RedPath == NULL || RedResponse == NULL) {
+  if ((Payload == NULL) || (RedPath == NULL) || (RedResponse == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
   ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
   ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
 
 
-  RedResponse->Payload = (REDFISH_PAYLOAD) getPayloadForPathString (Payload, RedPath, &(RedResponse->StatusCode));
+  RedResponse->Payload = (REDFISH_PAYLOAD)getPayloadForPathString (Payload, RedPath, &(RedResponse->StatusCode));
 
 
   //
   //
   // 1. If the returned Payload is NULL, indicates any error happen.
   // 1. If the returned Payload is NULL, indicates any error happen.
@@ -400,15 +411,17 @@ RedfishGetByPayload (
   //    NOTE: If there is any error message returned from server, it will be returned in
   //    NOTE: If there is any error message returned from server, it will be returned in
   //          Payload within RedResponse.
   //          Payload within RedResponse.
   //
   //
-  if (RedResponse->StatusCode != NULL && \
-      (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \
-       *(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT
-      )) {
+  if ((RedResponse->StatusCode != NULL) && \
+      ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
+       (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)
+      ))
+  {
     return EFI_DEVICE_ERROR;
     return EFI_DEVICE_ERROR;
   }
   }
 
 
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }
+
 /**
 /**
   Use HTTP PATCH to perform updates on pre-existing Redfish resource.
   Use HTTP PATCH to perform updates on pre-existing Redfish resource.
 
 
@@ -442,30 +455,30 @@ RedfishGetByPayload (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishPatchToUri (
 RedfishPatchToUri (
-  IN     REDFISH_SERVICE            RedfishService,
-  IN     CONST CHAR8                *Uri,
-  IN     CONST CHAR8                *Content,
-  OUT    REDFISH_RESPONSE           *RedResponse
+  IN     REDFISH_SERVICE   RedfishService,
+  IN     CONST CHAR8       *Uri,
+  IN     CONST CHAR8       *Content,
+  OUT    REDFISH_RESPONSE  *RedResponse
   )
   )
 {
 {
-  EFI_STATUS               Status;
-  EDKII_JSON_VALUE         JsonValue;
+  EFI_STATUS        Status;
+  EDKII_JSON_VALUE  JsonValue;
 
 
   Status    = EFI_SUCCESS;
   Status    = EFI_SUCCESS;
   JsonValue = NULL;
   JsonValue = NULL;
 
 
-  if (RedfishService == NULL || Uri == NULL || Content == NULL || RedResponse == NULL) {
+  if ((RedfishService == NULL) || (Uri == NULL) || (Content == NULL) || (RedResponse == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
   ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
   ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
 
 
-  JsonValue = (EDKII_JSON_VALUE) patchUriFromService (
-                                   RedfishService,
-                                   Uri,
-                                   Content,
-                                   &(RedResponse->StatusCode)
-                                   );
+  JsonValue = (EDKII_JSON_VALUE)patchUriFromService (
+                                  RedfishService,
+                                  Uri,
+                                  Content,
+                                  &(RedResponse->StatusCode)
+                                  );
 
 
   //
   //
   // 1. If the returned StatusCode is NULL, indicates any error happen.
   // 1. If the returned StatusCode is NULL, indicates any error happen.
@@ -480,8 +493,9 @@ RedfishPatchToUri (
   //    NOTE: If there is any error message returned from server, it will be returned in
   //    NOTE: If there is any error message returned from server, it will be returned in
   //          Payload within RedResponse.
   //          Payload within RedResponse.
   //
   //
-  if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \
-      *(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) {
+  if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
+      (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
+  {
     Status = EFI_DEVICE_ERROR;
     Status = EFI_DEVICE_ERROR;
   }
   }
 
 
@@ -499,6 +513,7 @@ ON_EXIT:
 
 
   return Status;
   return Status;
 }
 }
+
 /**
 /**
   Use HTTP PATCH to perform updates on target payload. Patch to odata.id in Payload directly.
   Use HTTP PATCH to perform updates on target payload. Patch to odata.id in Payload directly.
 
 
@@ -530,22 +545,22 @@ ON_EXIT:
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishPatchToPayload (
 RedfishPatchToPayload (
-  IN     REDFISH_PAYLOAD          Target,
-  IN     REDFISH_PAYLOAD          Payload,
-  OUT    REDFISH_RESPONSE         *RedResponse
+  IN     REDFISH_PAYLOAD   Target,
+  IN     REDFISH_PAYLOAD   Payload,
+  OUT    REDFISH_RESPONSE  *RedResponse
   )
   )
 {
 {
-  if (Target == NULL || Payload == NULL || RedResponse == NULL) {
+  if ((Target == NULL) || (Payload == NULL) || (RedResponse == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
   ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
   ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
 
 
-  RedResponse->Payload = (REDFISH_PAYLOAD) patchPayload (
-                                             Target,
-                                             Payload,
-                                             &(RedResponse->StatusCode)
-                                             );
+  RedResponse->Payload = (REDFISH_PAYLOAD)patchPayload (
+                                            Target,
+                                            Payload,
+                                            &(RedResponse->StatusCode)
+                                            );
 
 
   //
   //
   // 1. If the returned StatusCode is NULL, indicates any error happen.
   // 1. If the returned StatusCode is NULL, indicates any error happen.
@@ -559,13 +574,15 @@ RedfishPatchToPayload (
   //    NOTE: If there is any error message returned from server, it will be returned in
   //    NOTE: If there is any error message returned from server, it will be returned in
   //          Payload within RedResponse.
   //          Payload within RedResponse.
   //
   //
-  if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \
-      *(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) {
+  if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
+      (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
+  {
     return EFI_DEVICE_ERROR;
     return EFI_DEVICE_ERROR;
   }
   }
 
 
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }
+
 /**
 /**
   Use HTTP POST to create a new resource in target payload.
   Use HTTP POST to create a new resource in target payload.
 
 
@@ -596,22 +613,22 @@ RedfishPatchToPayload (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishPostToPayload (
 RedfishPostToPayload (
-  IN     REDFISH_PAYLOAD          Target,
-  IN     REDFISH_PAYLOAD          Payload,
-  OUT    REDFISH_RESPONSE         *RedResponse
+  IN     REDFISH_PAYLOAD   Target,
+  IN     REDFISH_PAYLOAD   Payload,
+  OUT    REDFISH_RESPONSE  *RedResponse
   )
   )
 {
 {
-  if (Target == NULL || Payload == NULL || RedResponse == NULL) {
+  if ((Target == NULL) || (Payload == NULL) || (RedResponse == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
   ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
   ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
 
 
-  RedResponse->Payload = (REDFISH_PAYLOAD) postPayload (
-                                             Target,
-                                             Payload,
-                                             &(RedResponse->StatusCode)
-                                             );
+  RedResponse->Payload = (REDFISH_PAYLOAD)postPayload (
+                                            Target,
+                                            Payload,
+                                            &(RedResponse->StatusCode)
+                                            );
 
 
   //
   //
   // 1. If the returned StatusCode is NULL, indicates any error happen.
   // 1. If the returned StatusCode is NULL, indicates any error happen.
@@ -625,13 +642,15 @@ RedfishPostToPayload (
   //    NOTE: If there is any error message returned from server, it will be returned in
   //    NOTE: If there is any error message returned from server, it will be returned in
   //          Payload within RedResponse.
   //          Payload within RedResponse.
   //
   //
-  if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \
-      *(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) {
+  if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
+      (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
+  {
     return EFI_DEVICE_ERROR;
     return EFI_DEVICE_ERROR;
   }
   }
 
 
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }
+
 /**
 /**
   Use HTTP DELETE to remove a resource.
   Use HTTP DELETE to remove a resource.
 
 
@@ -662,28 +681,28 @@ RedfishPostToPayload (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishDeleteByUri (
 RedfishDeleteByUri (
-  IN     REDFISH_SERVICE            RedfishService,
-  IN     CONST CHAR8                *Uri,
-  OUT    REDFISH_RESPONSE           *RedResponse
+  IN     REDFISH_SERVICE   RedfishService,
+  IN     CONST CHAR8       *Uri,
+  OUT    REDFISH_RESPONSE  *RedResponse
   )
   )
 {
 {
-  EFI_STATUS               Status;
-  EDKII_JSON_VALUE         JsonValue;
+  EFI_STATUS        Status;
+  EDKII_JSON_VALUE  JsonValue;
 
 
   Status    = EFI_SUCCESS;
   Status    = EFI_SUCCESS;
   JsonValue = NULL;
   JsonValue = NULL;
 
 
-  if (RedfishService == NULL || Uri == NULL || RedResponse == NULL) {
+  if ((RedfishService == NULL) || (Uri == NULL) || (RedResponse == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
   ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
   ZeroMem (RedResponse, sizeof (REDFISH_RESPONSE));
 
 
-  JsonValue = (EDKII_JSON_VALUE) deleteUriFromService (
-                                   RedfishService,
-                                   Uri,
-                                   &(RedResponse->StatusCode)
-                                   );
+  JsonValue = (EDKII_JSON_VALUE)deleteUriFromService (
+                                  RedfishService,
+                                  Uri,
+                                  &(RedResponse->StatusCode)
+                                  );
 
 
   //
   //
   // 1. If the returned StatusCode is NULL, indicates any error happen.
   // 1. If the returned StatusCode is NULL, indicates any error happen.
@@ -698,8 +717,9 @@ RedfishDeleteByUri (
   //    NOTE: If there is any error message returned from server, it will be returned in
   //    NOTE: If there is any error message returned from server, it will be returned in
   //          Payload within RedResponse.
   //          Payload within RedResponse.
   //
   //
-  if (*(RedResponse->StatusCode) < HTTP_STATUS_200_OK || \
-      *(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT) {
+  if ((*(RedResponse->StatusCode) < HTTP_STATUS_200_OK) || \
+      (*(RedResponse->StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT))
+  {
     Status = EFI_DEVICE_ERROR;
     Status = EFI_DEVICE_ERROR;
   }
   }
 
 
@@ -717,6 +737,7 @@ ON_EXIT:
 
 
   return Status;
   return Status;
 }
 }
+
 /**
 /**
   Dump text in fractions.
   Dump text in fractions.
 
 
@@ -725,37 +746,40 @@ ON_EXIT:
 **/
 **/
 VOID
 VOID
 RedfishDumpJsonStringFractions (
 RedfishDumpJsonStringFractions (
-  IN CHAR8 *String
+  IN CHAR8  *String
   )
   )
 {
 {
-  CHAR8 *NextFraction;
-  UINTN StringFractionSize;
-  UINTN StrLen;
-  UINTN Count;
-  CHAR8 BackupChar;
+  CHAR8  *NextFraction;
+  UINTN  StringFractionSize;
+  UINTN  StrLen;
+  UINTN  Count;
+  CHAR8  BackupChar;
 
 
   StringFractionSize = 200;
   StringFractionSize = 200;
   if (String == NULL) {
   if (String == NULL) {
-    return ;
+    return;
   }
   }
 
 
-  DEBUG((DEBUG_INFO, "JSON text:\n"));
+  DEBUG ((DEBUG_INFO, "JSON text:\n"));
   NextFraction = String;
   NextFraction = String;
-  StrLen = AsciiStrLen (String);
+  StrLen       = AsciiStrLen (String);
   if (StrLen == 0) {
   if (StrLen == 0) {
     return;
     return;
   }
   }
+
   for (Count = 0; Count < (StrLen / StringFractionSize); Count++) {
   for (Count = 0; Count < (StrLen / StringFractionSize); Count++) {
-    BackupChar = *(NextFraction + StringFractionSize);
+    BackupChar                           = *(NextFraction + StringFractionSize);
     *(NextFraction + StringFractionSize) = 0;
     *(NextFraction + StringFractionSize) = 0;
-    DEBUG((DEBUG_INFO, "%a", NextFraction));
+    DEBUG ((DEBUG_INFO, "%a", NextFraction));
     *(NextFraction + StringFractionSize) = BackupChar;
     *(NextFraction + StringFractionSize) = BackupChar;
-    NextFraction += StringFractionSize;
+    NextFraction                        += StringFractionSize;
   }
   }
+
   if ((StrLen % StringFractionSize) != 0) {
   if ((StrLen % StringFractionSize) != 0) {
-    DEBUG((DEBUG_INFO, "%a\n\n", NextFraction));
+    DEBUG ((DEBUG_INFO, "%a\n\n", NextFraction));
   }
   }
 }
 }
+
 /**
 /**
   Dump text in JSON value.
   Dump text in JSON value.
 
 
@@ -767,15 +791,17 @@ RedfishDumpJson (
   IN EDKII_JSON_VALUE  JsonValue
   IN EDKII_JSON_VALUE  JsonValue
   )
   )
 {
 {
-  CHAR8 *String;
+  CHAR8  *String;
 
 
   String = JsonDumpString (JsonValue, 0);
   String = JsonDumpString (JsonValue, 0);
   if (String == NULL) {
   if (String == NULL) {
     return;
     return;
   }
   }
+
   RedfishDumpJsonStringFractions (String);
   RedfishDumpJsonStringFractions (String);
-  FreePool(String);
+  FreePool (String);
 }
 }
+
 /**
 /**
   Extract the JSON text content from REDFISH_PAYLOAD and dump to debug console.
   Extract the JSON text content from REDFISH_PAYLOAD and dump to debug console.
 
 
@@ -784,14 +810,14 @@ RedfishDumpJson (
 **/
 **/
 VOID
 VOID
 RedfishDumpPayload (
 RedfishDumpPayload (
-  IN REDFISH_PAYLOAD       Payload
+  IN REDFISH_PAYLOAD  Payload
   )
   )
 {
 {
-  EDKII_JSON_VALUE JsonValue;
-  CHAR8 *String;
+  EDKII_JSON_VALUE  JsonValue;
+  CHAR8             *String;
 
 
   JsonValue = NULL;
   JsonValue = NULL;
-  String = NULL;
+  String    = NULL;
 
 
   if (Payload == NULL) {
   if (Payload == NULL) {
     return;
     return;
@@ -808,8 +834,9 @@ RedfishDumpPayload (
   }
   }
 
 
   RedfishDumpJsonStringFractions (String);
   RedfishDumpJsonStringFractions (String);
-  FreePool(String);
+  FreePool (String);
 }
 }
+
 /**
 /**
   This function will cleanup the HTTP header and Redfish payload resources.
   This function will cleanup the HTTP header and Redfish payload resources.
 
 
@@ -832,8 +859,8 @@ RedfishFreeResponse (
     StatusCode = NULL;
     StatusCode = NULL;
   }
   }
 
 
-  if (HeaderCount != 0 && Headers != NULL) {
-    HttpFreeHeaderFields(Headers, HeaderCount);
+  if ((HeaderCount != 0) && (Headers != NULL)) {
+    HttpFreeHeaderFields (Headers, HeaderCount);
     Headers = NULL;
     Headers = NULL;
   }
   }
 
 
@@ -842,6 +869,7 @@ RedfishFreeResponse (
     Payload = NULL;
     Payload = NULL;
   }
   }
 }
 }
+
 /**
 /**
   Check if the "@odata.type" in Payload is valid or not.
   Check if the "@odata.type" in Payload is valid or not.
 
 
@@ -855,17 +883,17 @@ RedfishFreeResponse (
 **/
 **/
 BOOLEAN
 BOOLEAN
 RedfishIsValidOdataType (
 RedfishIsValidOdataType (
-  IN REDFISH_PAYLOAD              Payload,
-  IN CONST CHAR8                  *OdataTypeName,
-  IN REDFISH_ODATA_TYPE_MAPPING   *OdataTypeMappingList,
-  IN UINTN                        OdataTypeMappingListSize
+  IN REDFISH_PAYLOAD             Payload,
+  IN CONST CHAR8                 *OdataTypeName,
+  IN REDFISH_ODATA_TYPE_MAPPING  *OdataTypeMappingList,
+  IN UINTN                       OdataTypeMappingListSize
   )
   )
 {
 {
-  UINTN               Index;
-  EDKII_JSON_VALUE    OdataType;
-  EDKII_JSON_VALUE    JsonValue;
+  UINTN             Index;
+  EDKII_JSON_VALUE  OdataType;
+  EDKII_JSON_VALUE  JsonValue;
 
 
-  if (Payload == NULL || OdataTypeName == NULL) {
+  if ((Payload == NULL) || (OdataTypeName == NULL)) {
     return FALSE;
     return FALSE;
   }
   }
 
 
@@ -875,19 +903,22 @@ RedfishIsValidOdataType (
   }
   }
 
 
   OdataType = JsonObjectGetValue (JsonValueGetObject (JsonValue), "@odata.type");
   OdataType = JsonObjectGetValue (JsonValueGetObject (JsonValue), "@odata.type");
-  if (!JsonValueIsString (OdataType) || JsonValueGetAsciiString (OdataType) == NULL) {
+  if (!JsonValueIsString (OdataType) || (JsonValueGetAsciiString (OdataType) == NULL)) {
     return FALSE;
     return FALSE;
   }
   }
 
 
-  for (Index = 0; Index < OdataTypeMappingListSize; Index ++) {
-    if (AsciiStrCmp (OdataTypeMappingList[Index].OdataTypeName, OdataTypeName) == 0 &&
-        AsciiStrCmp (OdataTypeMappingList[Index].OdataType, JsonValueGetAsciiString (OdataType)) == 0) {
+  for (Index = 0; Index < OdataTypeMappingListSize; Index++) {
+    if ((AsciiStrCmp (OdataTypeMappingList[Index].OdataTypeName, OdataTypeName) == 0) &&
+        (AsciiStrCmp (OdataTypeMappingList[Index].OdataType, JsonValueGetAsciiString (OdataType)) == 0))
+    {
       return TRUE;
       return TRUE;
     }
     }
   }
   }
+
   DEBUG ((DEBUG_INFO, "%a: This Odata type is not in the list.\n", __FUNCTION__));
   DEBUG ((DEBUG_INFO, "%a: This Odata type is not in the list.\n", __FUNCTION__));
   return FALSE;
   return FALSE;
 }
 }
+
 /**
 /**
   Check if the payload is collection
   Check if the payload is collection
 
 
@@ -898,11 +929,12 @@ RedfishIsValidOdataType (
 **/
 **/
 BOOLEAN
 BOOLEAN
 RedfishIsPayloadCollection (
 RedfishIsPayloadCollection (
-  IN REDFISH_PAYLOAD Payload
-)
+  IN REDFISH_PAYLOAD  Payload
+  )
 {
 {
   return isPayloadCollection (Payload);
   return isPayloadCollection (Payload);
 }
 }
+
 /**
 /**
   Get collection size.
   Get collection size.
 
 
@@ -913,21 +945,23 @@ RedfishIsPayloadCollection (
   @return EFI_INVALID_PARAMETER    The payload is not a collection.
   @return EFI_INVALID_PARAMETER    The payload is not a collection.
 **/
 **/
 EFI_STATUS
 EFI_STATUS
-RedfishGetCollectionSize(
-  IN REDFISH_PAYLOAD Payload,
-  IN UINTN *CollectionSize
+RedfishGetCollectionSize (
+  IN REDFISH_PAYLOAD  Payload,
+  IN UINTN            *CollectionSize
   )
   )
 {
 {
-  if (Payload == NULL || CollectionSize == NULL) {
+  if ((Payload == NULL) || (CollectionSize == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
-  if (!RedfishIsPayloadCollection(Payload)) {
+
+  if (!RedfishIsPayloadCollection (Payload)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
-  *CollectionSize = (UINTN)getCollectionSize(Payload);
+  *CollectionSize = (UINTN)getCollectionSize (Payload);
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }
+
 /**
 /**
   Get Redfish payload of collection member
   Get Redfish payload of collection member
 
 
@@ -939,20 +973,23 @@ RedfishGetCollectionSize(
 **/
 **/
 REDFISH_PAYLOAD
 REDFISH_PAYLOAD
 RedfishGetPayloadByIndex (
 RedfishGetPayloadByIndex (
-  IN REDFISH_PAYLOAD Payload,
-  IN UINTN  Index
-)
+  IN REDFISH_PAYLOAD  Payload,
+  IN UINTN            Index
+  )
 {
 {
-  REDFISH_RESPONSE RedfishResponse;
-  REDFISH_PAYLOAD PayloadReturn;
+  REDFISH_RESPONSE  RedfishResponse;
+  REDFISH_PAYLOAD   PayloadReturn;
 
 
   PayloadReturn = (VOID *)getPayloadByIndex (Payload, Index, &RedfishResponse.StatusCode);
   PayloadReturn = (VOID *)getPayloadByIndex (Payload, Index, &RedfishResponse.StatusCode);
-  if(PayloadReturn == NULL ||
-     (*(RedfishResponse.StatusCode) < HTTP_STATUS_200_OK && *(RedfishResponse.StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)){
+  if ((PayloadReturn == NULL) ||
+      ((*(RedfishResponse.StatusCode) < HTTP_STATUS_200_OK) && (*(RedfishResponse.StatusCode) > HTTP_STATUS_206_PARTIAL_CONTENT)))
+  {
     return NULL;
     return NULL;
   }
   }
+
   return PayloadReturn;
   return PayloadReturn;
 }
 }
+
 /**
 /**
   Check and return Redfish resource of the given Redpath.
   Check and return Redfish resource of the given Redpath.
 
 
@@ -964,30 +1001,33 @@ RedfishGetPayloadByIndex (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishCheckIfRedpathExist (
 RedfishCheckIfRedpathExist (
-  IN REDFISH_SERVICE RedfishService,
-  IN CHAR8 *Redpath,
-  IN REDFISH_RESPONSE *Response OPTIONAL
+  IN REDFISH_SERVICE   RedfishService,
+  IN CHAR8             *Redpath,
+  IN REDFISH_RESPONSE  *Response OPTIONAL
   )
   )
 {
 {
-  EFI_STATUS Status;
-  REDFISH_RESPONSE TempResponse;
+  EFI_STATUS        Status;
+  REDFISH_RESPONSE  TempResponse;
 
 
   if (Redpath == NULL) {
   if (Redpath == NULL) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
+
   Status = RedfishGetByService (RedfishService, Redpath, &TempResponse);
   Status = RedfishGetByService (RedfishService, Redpath, &TempResponse);
   if (EFI_ERROR (Status)) {
   if (EFI_ERROR (Status)) {
     return Status;
     return Status;
   }
   }
+
   if (Response == NULL) {
   if (Response == NULL) {
-    RedfishFreeResponse(
+    RedfishFreeResponse (
       TempResponse.StatusCode,
       TempResponse.StatusCode,
       TempResponse.HeaderCount,
       TempResponse.HeaderCount,
       TempResponse.Headers,
       TempResponse.Headers,
       TempResponse.Payload
       TempResponse.Payload
-    );
+      );
   } else {
   } else {
     CopyMem ((VOID *)Response, (VOID *)&TempResponse, sizeof (REDFISH_RESPONSE));
     CopyMem ((VOID *)Response, (VOID *)&TempResponse, sizeof (REDFISH_RESPONSE));
   }
   }
+
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }

+ 38 - 33
RedfishPkg/PrivateLibrary/RedfishLib/RedfishMisc.c

@@ -10,7 +10,7 @@
 
 
 #include "RedfishMisc.h"
 #include "RedfishMisc.h"
 
 
-EDKII_REDFISH_CREDENTIAL_PROTOCOL    *mCredentialProtocol = NULL;
+EDKII_REDFISH_CREDENTIAL_PROTOCOL  *mCredentialProtocol = NULL;
 
 
 /**
 /**
   This function returns the string of Redfish service version.
   This function returns the string of Redfish service version.
@@ -23,25 +23,28 @@ EDKII_REDFISH_CREDENTIAL_PROTOCOL    *mCredentialProtocol = NULL;
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishGetServiceVersion (
 RedfishGetServiceVersion (
-  IN  REDFISH_SERVICE   RedfishService,
-  OUT CHAR8 **ServiceVersionStr
+  IN  REDFISH_SERVICE  RedfishService,
+  OUT CHAR8            **ServiceVersionStr
   )
   )
 {
 {
-  redfishService *Redfish;
-  CHAR8 **KeysArray;
-  UINTN KeysNum;
+  redfishService  *Redfish;
+  CHAR8           **KeysArray;
+  UINTN           KeysNum;
 
 
-  if (RedfishService == NULL || ServiceVersionStr == NULL) {
+  if ((RedfishService == NULL) || (ServiceVersionStr == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
+
   Redfish = (redfishService *)RedfishService;
   Redfish = (redfishService *)RedfishService;
   if (Redfish->versions == NULL) {
   if (Redfish->versions == NULL) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
+
   KeysArray = JsonObjectGetKeys (Redfish->versions, &KeysNum);
   KeysArray = JsonObjectGetKeys (Redfish->versions, &KeysNum);
-  if (KeysNum == 0 || KeysArray  == NULL) {
+  if ((KeysNum == 0) || (KeysArray  == NULL)) {
     return EFI_NOT_FOUND;
     return EFI_NOT_FOUND;
   }
   }
+
   *ServiceVersionStr = *KeysArray;
   *ServiceVersionStr = *KeysArray;
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }
@@ -65,18 +68,17 @@ RedfishGetServiceVersion (
 **/
 **/
 REDFISH_SERVICE
 REDFISH_SERVICE
 RedfishCreateLibredfishService (
 RedfishCreateLibredfishService (
-  IN  REDFISH_CONFIG_SERVICE_INFORMATION   *RedfishConfigServiceInfo,
-  IN  EDKII_REDFISH_AUTH_METHOD     AuthMethod,
-  IN  CHAR8                         *UserId,
-  IN  CHAR8                         *Password
+  IN  REDFISH_CONFIG_SERVICE_INFORMATION  *RedfishConfigServiceInfo,
+  IN  EDKII_REDFISH_AUTH_METHOD           AuthMethod,
+  IN  CHAR8                               *UserId,
+  IN  CHAR8                               *Password
   )
   )
 {
 {
+  UINTN                     Flags;
+  enumeratorAuthentication  Auth;
+  redfishService            *Redfish;
 
 
-  UINTN                    Flags;
-  enumeratorAuthentication Auth;
-  redfishService*          Redfish;
-
-  Redfish   = NULL;
+  Redfish = NULL;
 
 
   ZeroMem (&Auth, sizeof (Auth));
   ZeroMem (&Auth, sizeof (Auth));
   if (AuthMethod == AuthMethodHttpBasic) {
   if (AuthMethod == AuthMethodHttpBasic) {
@@ -84,25 +86,26 @@ RedfishCreateLibredfishService (
   } else if (AuthMethod == AuthMethodRedfishSession) {
   } else if (AuthMethod == AuthMethodRedfishSession) {
     Auth.authType = REDFISH_AUTH_SESSION;
     Auth.authType = REDFISH_AUTH_SESSION;
   }
   }
+
   Auth.authCodes.userPass.username = UserId;
   Auth.authCodes.userPass.username = UserId;
   Auth.authCodes.userPass.password = Password;
   Auth.authCodes.userPass.password = Password;
 
 
   Flags = REDFISH_FLAG_SERVICE_NO_VERSION_DOC;
   Flags = REDFISH_FLAG_SERVICE_NO_VERSION_DOC;
 
 
   if (AuthMethod != AuthMethodNone) {
   if (AuthMethod != AuthMethodNone) {
-    Redfish = createServiceEnumerator(RedfishConfigServiceInfo, NULL, &Auth, (unsigned int ) Flags);
+    Redfish = createServiceEnumerator (RedfishConfigServiceInfo, NULL, &Auth, (unsigned int)Flags);
   } else {
   } else {
-    Redfish = createServiceEnumerator(RedfishConfigServiceInfo, NULL, NULL, (unsigned int) Flags);
+    Redfish = createServiceEnumerator (RedfishConfigServiceInfo, NULL, NULL, (unsigned int)Flags);
   }
   }
 
 
   //
   //
   // Zero the Password after use.
   // Zero the Password after use.
   //
   //
   if (Password != NULL) {
   if (Password != NULL) {
-    ZeroMem (Password, AsciiStrLen(Password));
+    ZeroMem (Password, AsciiStrLen (Password));
   }
   }
 
 
-  return (REDFISH_SERVICE) Redfish;
+  return (REDFISH_SERVICE)Redfish;
 }
 }
 
 
 /**
 /**
@@ -130,14 +133,14 @@ RedfishCreateLibredfishService (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishGetAuthInfo (
 RedfishGetAuthInfo (
-  OUT  EDKII_REDFISH_AUTH_METHOD          *AuthMethod,
-  OUT  CHAR8                              **UserId,
-  OUT  CHAR8                              **Password
+  OUT  EDKII_REDFISH_AUTH_METHOD  *AuthMethod,
+  OUT  CHAR8                      **UserId,
+  OUT  CHAR8                      **Password
   )
   )
 {
 {
-  EFI_STATUS                         Status;
+  EFI_STATUS  Status;
 
 
-  if (AuthMethod == NULL || UserId == NULL || Password == NULL) {
+  if ((AuthMethod == NULL) || (UserId == NULL) || (Password == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
@@ -161,6 +164,7 @@ RedfishGetAuthInfo (
 
 
   return Status;
   return Status;
 }
 }
+
 /**
 /**
   This function returns the string of Redfish service version.
   This function returns the string of Redfish service version.
 
 
@@ -175,15 +179,15 @@ RedfishGetAuthInfo (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishBuildRedpathUseId (
 RedfishBuildRedpathUseId (
-  IN  CHAR8 *ServiceVerisonStr,
-  IN  CHAR8 *Url,
-  IN  CHAR8 *Id,
-  OUT CHAR8 **Redpath
+  IN  CHAR8  *ServiceVerisonStr,
+  IN  CHAR8  *Url,
+  IN  CHAR8  *Id,
+  OUT CHAR8  **Redpath
   )
   )
 {
 {
-  UINTN RedpathSize;
+  UINTN  RedpathSize;
 
 
-  if (Redpath == NULL || ServiceVerisonStr == NULL || Url == NULL || Id == NULL) {
+  if ((Redpath == NULL) || (ServiceVerisonStr == NULL) || (Url == NULL) || (Id == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
@@ -192,10 +196,11 @@ RedfishBuildRedpathUseId (
                 AsciiStrLen (Url) +
                 AsciiStrLen (Url) +
                 AsciiStrLen ("[Id=]") +
                 AsciiStrLen ("[Id=]") +
                 AsciiStrLen (Id) + 1;
                 AsciiStrLen (Id) + 1;
-  *Redpath = AllocatePool(RedpathSize);
+  *Redpath = AllocatePool (RedpathSize);
   if (*Redpath == NULL) {
   if (*Redpath == NULL) {
     return EFI_OUT_OF_RESOURCES;
     return EFI_OUT_OF_RESOURCES;
   }
   }
+
   AsciiSPrint (*Redpath, RedpathSize, "/%a%a[Id=%a]", ServiceVerisonStr, Url, Id);
   AsciiSPrint (*Redpath, RedpathSize, "/%a%a[Id=%a]", ServiceVerisonStr, Url, Id);
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }

+ 8 - 8
RedfishPkg/PrivateLibrary/RedfishLib/RedfishMisc.h

@@ -22,7 +22,7 @@
 #include <Protocol/EdkIIRedfishCredential.h>
 #include <Protocol/EdkIIRedfishCredential.h>
 #include <redfish.h>
 #include <redfish.h>
 
 
-#define ARRAY_SIZE(Array) (sizeof (Array) / sizeof ((Array)[0]))
+#define ARRAY_SIZE(Array)  (sizeof (Array) / sizeof ((Array)[0]))
 
 
 /**
 /**
   Creates a REDFISH_SERVICE which can be later used to access the Redfish resources.
   Creates a REDFISH_SERVICE which can be later used to access the Redfish resources.
@@ -43,10 +43,10 @@
 **/
 **/
 REDFISH_SERVICE
 REDFISH_SERVICE
 RedfishCreateLibredfishService (
 RedfishCreateLibredfishService (
-  IN REDFISH_CONFIG_SERVICE_INFORMATION   *RedfishConfigServiceInfo,
-  IN EDKII_REDFISH_AUTH_METHOD       AuthMethod,
-  IN CHAR8                           *UserId,
-  IN CHAR8                           *Password
+  IN REDFISH_CONFIG_SERVICE_INFORMATION  *RedfishConfigServiceInfo,
+  IN EDKII_REDFISH_AUTH_METHOD           AuthMethod,
+  IN CHAR8                               *UserId,
+  IN CHAR8                               *Password
   );
   );
 
 
 /**
 /**
@@ -74,9 +74,9 @@ RedfishCreateLibredfishService (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishGetAuthInfo (
 RedfishGetAuthInfo (
-  OUT  EDKII_REDFISH_AUTH_METHOD          *AuthMethod,
-  OUT  CHAR8                              **UserId,
-  OUT  CHAR8                              **Password
+  OUT  EDKII_REDFISH_AUTH_METHOD  *AuthMethod,
+  OUT  CHAR8                      **UserId,
+  OUT  CHAR8                      **Password
   );
   );
 
 
 #endif
 #endif

+ 1 - 0
RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfish.h

@@ -14,6 +14,7 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 
 **/
 **/
+
 #ifndef LIBREDFISH_REDFISH_H_
 #ifndef LIBREDFISH_REDFISH_H_
 #define LIBREDFISH_REDFISH_H_
 #define LIBREDFISH_REDFISH_H_
 
 

+ 79 - 12
RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfishPayload.h

@@ -14,6 +14,7 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 
 **/
 **/
+
 #ifndef LIBREDFISH_REDFISH_PAYLOAD_H_
 #ifndef LIBREDFISH_REDFISH_PAYLOAD_H_
 #define LIBREDFISH_REDFISH_PAYLOAD_H_
 #define LIBREDFISH_REDFISH_PAYLOAD_H_
 
 
@@ -23,17 +24,83 @@
 #include <redfishService.h>
 #include <redfishService.h>
 #include <redpath.h>
 #include <redpath.h>
 
 
-redfishPayload* createRedfishPayload(json_t* value, redfishService* service);
-redfishPayload* getPayloadByNodeName(redfishPayload* payload, const char* nodeName, EFI_HTTP_STATUS_CODE** StatusCode);
-redfishPayload* getPayloadByIndex(redfishPayload* payload, size_t index, EFI_HTTP_STATUS_CODE** StatusCode);
-redfishPayload* getPayloadForPath(redfishPayload* payload, redPathNode* redpath, EFI_HTTP_STATUS_CODE** StatusCode);
-redfishPayload* getPayloadForPathString(redfishPayload* payload, const char* string, EFI_HTTP_STATUS_CODE** StatusCode);
-redfishPayload* patchPayload(redfishPayload* target, redfishPayload* payload, EFI_HTTP_STATUS_CODE** StatusCode);
-redfishPayload* postContentToPayload(redfishPayload* target, const char* data, size_t dataSize, const char* contentType, EFI_HTTP_STATUS_CODE** StatusCode);
-redfishPayload* postPayload(redfishPayload* target, redfishPayload* payload, EFI_HTTP_STATUS_CODE** StatusCode);
-void            cleanupPayload(redfishPayload* payload);
-bool            isPayloadCollection (redfishPayload *Payload);
-size_t          getCollectionSize(redfishPayload* payload);
-redfishPayload* getPayloadByIndex (redfishPayload* payload, size_t index, EFI_HTTP_STATUS_CODE** StatusCode);
+redfishPayload *
+createRedfishPayload (
+  json_t          *value,
+  redfishService  *service
+  );
+
+redfishPayload *
+getPayloadByNodeName (
+  redfishPayload        *payload,
+  const char            *nodeName,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
+
+redfishPayload *
+getPayloadByIndex (
+  redfishPayload        *payload,
+  size_t                index,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
+
+redfishPayload *
+getPayloadForPath (
+  redfishPayload        *payload,
+  redPathNode           *redpath,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
+
+redfishPayload *
+getPayloadForPathString (
+  redfishPayload        *payload,
+  const char            *string,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
+
+redfishPayload *
+patchPayload (
+  redfishPayload        *target,
+  redfishPayload        *payload,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
+
+redfishPayload *
+postContentToPayload (
+  redfishPayload        *target,
+  const char            *data,
+  size_t                dataSize,
+  const char            *contentType,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
+
+redfishPayload *
+postPayload (
+  redfishPayload        *target,
+  redfishPayload        *payload,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
+
+void
+cleanupPayload (
+  redfishPayload  *payload
+  );
+
+bool
+isPayloadCollection (
+  redfishPayload  *Payload
+  );
+
+size_t
+getCollectionSize (
+  redfishPayload  *payload
+  );
+
+redfishPayload *
+getPayloadByIndex (
+  redfishPayload        *payload,
+  size_t                index,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
 
 
 #endif
 #endif

+ 90 - 40
RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redfishService.h

@@ -38,64 +38,114 @@
 #include <jansson.h>
 #include <jansson.h>
 
 
 typedef struct {
 typedef struct {
-    char* host;
-    json_t* versions;
-    unsigned int flags;
-    char* sessionToken;
-    char* basicAuthStr;
-    //
-    // point to the <HOST> part in above "host" field, which will be put into
-    // the "Host" header of HTTP request message.
-    //
-    char* HostHeaderValue;
-    EFI_REST_EX_PROTOCOL *RestEx;
+  char                    *host;
+  json_t                  *versions;
+  unsigned int            flags;
+  char                    *sessionToken;
+  char                    *basicAuthStr;
+  //
+  // point to the <HOST> part in above "host" field, which will be put into
+  // the "Host" header of HTTP request message.
+  //
+  char                    *HostHeaderValue;
+  EFI_REST_EX_PROTOCOL    *RestEx;
 } redfishService;
 } redfishService;
 
 
 typedef struct {
 typedef struct {
-    json_t* json;
-    redfishService* service;
+  json_t            *json;
+  redfishService    *service;
 } redfishPayload;
 } redfishPayload;
 
 
-#define REDFISH_AUTH_BASIC        0
-#define REDFISH_AUTH_BEARER_TOKEN 1
-#define REDFISH_AUTH_SESSION      2
+#define REDFISH_AUTH_BASIC         0
+#define REDFISH_AUTH_BEARER_TOKEN  1
+#define REDFISH_AUTH_SESSION       2
 
 
-#define REDFISH_HTTP_RESPONSE_TIMEOUT   5000      /// 5 seconds in uints of millisecond.
+#define REDFISH_HTTP_RESPONSE_TIMEOUT  5000       /// 5 seconds in uints of millisecond.
 
 
 ///
 ///
 /// Library class public defines
 /// Library class public defines
 ///
 ///
-#define HTTP_FLAG                  L"http://"
-#define HTTPS_FLAG                 L"https://"
+#define HTTP_FLAG   L"http://"
+#define HTTPS_FLAG  L"https://"
 
 
 ///
 ///
 /// The redfish first URL should be "/redfish/v1/", while we use "/redfish/v1" here without "/"
 /// The redfish first URL should be "/redfish/v1/", while we use "/redfish/v1" here without "/"
 /// in the end is to avoid the 301 Perment redirect response from Redfish profile simulator.
 /// in the end is to avoid the 301 Perment redirect response from Redfish profile simulator.
 ///
 ///
-#define REDFISH_FIRST_URL          L"/redfish/v1"
+#define REDFISH_FIRST_URL  L"/redfish/v1"
 
 
 typedef struct {
 typedef struct {
-        unsigned int authType;
-        union {
-            struct {
-                char* username;
-                char* password;
-            } userPass;
-            struct {
-                char* token;
-            } authToken;
-        } authCodes;
+  unsigned int    authType;
+  union {
+    struct {
+      char    *username;
+      char    *password;
+    } userPass;
+    struct {
+      char    *token;
+    } authToken;
+  } authCodes;
 } enumeratorAuthentication;
 } enumeratorAuthentication;
 
 
-//Values for flags
-#define REDFISH_FLAG_SERVICE_NO_VERSION_DOC 0x00000001 //The Redfish Service lacks the version document (in violation of the Redfish spec)
-redfishService* createServiceEnumerator(REDFISH_CONFIG_SERVICE_INFORMATION *RedfishConfigServiceInfo, const char* rootUri, enumeratorAuthentication* auth, unsigned int flags);
-json_t* getUriFromService(redfishService* service, const char* uri, EFI_HTTP_STATUS_CODE** StatusCode);
-json_t* patchUriFromService(redfishService* service, const char* uri, const char* content, EFI_HTTP_STATUS_CODE** StatusCode);
-json_t* postUriFromService(redfishService* service, const char* uri, const char* content, size_t contentLength, const char* contentType, EFI_HTTP_STATUS_CODE** StatusCode);
-json_t* deleteUriFromService(redfishService* service, const char* uri, EFI_HTTP_STATUS_CODE** StatusCode);
-redfishPayload* getRedfishServiceRoot(redfishService* service, const char* version, EFI_HTTP_STATUS_CODE** StatusCode);
-redfishPayload* getPayloadByPath(redfishService* service, const char* path, EFI_HTTP_STATUS_CODE** StatusCode);
-void cleanupServiceEnumerator(redfishService* service);
+// Values for flags
+#define REDFISH_FLAG_SERVICE_NO_VERSION_DOC  0x00000001// The Redfish Service lacks the version document (in violation of the Redfish spec)
+redfishService *
+createServiceEnumerator (
+  REDFISH_CONFIG_SERVICE_INFORMATION  *RedfishConfigServiceInfo,
+  const char                          *rootUri,
+  enumeratorAuthentication            *auth,
+  unsigned int                        flags
+  );
+
+json_t *
+getUriFromService (
+  redfishService        *service,
+  const char            *uri,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
+
+json_t *
+patchUriFromService (
+  redfishService        *service,
+  const char            *uri,
+  const char            *content,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
+
+json_t *
+postUriFromService (
+  redfishService        *service,
+  const char            *uri,
+  const char            *content,
+  size_t                contentLength,
+  const char            *contentType,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
+
+json_t *
+deleteUriFromService (
+  redfishService        *service,
+  const char            *uri,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
+
+redfishPayload *
+getRedfishServiceRoot (
+  redfishService        *service,
+  const char            *version,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
+
+redfishPayload *
+getPayloadByPath (
+  redfishService        *service,
+  const char            *path,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
+
+void
+cleanupServiceEnumerator (
+  redfishService  *service
+  );
 
 
 #endif
 #endif

+ 20 - 13
RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/include/redpath.h

@@ -14,6 +14,7 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 
 **/
 **/
+
 #ifndef LIBREDFISH_REDPATH_H_
 #ifndef LIBREDFISH_REDPATH_H_
 #define LIBREDFISH_REDPATH_H_
 #define LIBREDFISH_REDPATH_H_
 
 
@@ -21,22 +22,28 @@
 
 
 #include <jansson.h>
 #include <jansson.h>
 
 
-typedef struct _redPathNode
-{
-    bool isRoot;
-    bool isIndex;
+typedef struct _redPathNode {
+  bool                   isRoot;
+  bool                   isIndex;
 
 
-    char* version;
-    char* nodeName;
-    size_t index;
-    char* op;
-    char* propName;
-    char* value;
+  char                   *version;
+  char                   *nodeName;
+  size_t                 index;
+  char                   *op;
+  char                   *propName;
+  char                   *value;
 
 
-    struct _redPathNode* next;
+  struct _redPathNode    *next;
 } redPathNode;
 } redPathNode;
 
 
-redPathNode* parseRedPath(const char* path);
-void cleanupRedPath(redPathNode* node);
+redPathNode *
+parseRedPath (
+  const char  *path
+  );
+
+void
+cleanupRedPath (
+  redPathNode  *node
+  );
 
 
 #endif
 #endif

+ 666 - 586
RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/payload.c

@@ -16,717 +16,797 @@
 **/
 **/
 #include <redfishPayload.h>
 #include <redfishPayload.h>
 
 
-static redfishPayload* getOpResult(redfishPayload* payload, const char* propName, const char* op, const char* value, EFI_HTTP_STATUS_CODE** StatusCode);
-static redfishPayload* collectionEvalOp(redfishPayload* payload, const char* propName, const char* op, const char* value, EFI_HTTP_STATUS_CODE** StatusCode);
-static redfishPayload* arrayEvalOp(redfishPayload* payload, const char* propName, const char* op, const char* value, EFI_HTTP_STATUS_CODE** StatusCode);
-static redfishPayload* createCollection(redfishService* service, size_t count, redfishPayload** payloads);
-static json_t*         json_object_get_by_index(json_t* json, size_t index);
-
-bool isPayloadCollection(redfishPayload* payload)
+static redfishPayload *
+getOpResult (
+  redfishPayload        *payload,
+  const char            *propName,
+  const char            *op,
+  const char            *value,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
+
+static redfishPayload *
+collectionEvalOp (
+  redfishPayload        *payload,
+  const char            *propName,
+  const char            *op,
+  const char            *value,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
+
+static redfishPayload *
+arrayEvalOp (
+  redfishPayload        *payload,
+  const char            *propName,
+  const char            *op,
+  const char            *value,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  );
+
+static redfishPayload *
+createCollection (
+  redfishService  *service,
+  size_t          count,
+  redfishPayload  **payloads
+  );
+
+static json_t *
+json_object_get_by_index (
+  json_t  *json,
+  size_t  index
+  );
+
+bool
+isPayloadCollection (
+  redfishPayload  *payload
+  )
 {
 {
-    json_t* members;
-    json_t* count;
+  json_t  *members;
+  json_t  *count;
 
 
-    if(!payload || !json_is_object(payload->json))
-    {
-        return false;
-    }
-    members = json_object_get(payload->json, "Members");
-    count = json_object_get(payload->json, "Members@odata.count");
-    return ((members != NULL) && (count != NULL));
+  if (!payload || !json_is_object (payload->json)) {
+    return false;
+  }
+
+  members = json_object_get (payload->json, "Members");
+  count   = json_object_get (payload->json, "Members@odata.count");
+  return ((members != NULL) && (count != NULL));
 }
 }
 
 
-size_t getCollectionSize(redfishPayload* payload)
+size_t
+getCollectionSize (
+  redfishPayload  *payload
+  )
 {
 {
-    json_t* members;
-    json_t* count;
+  json_t  *members;
+  json_t  *count;
 
 
-    if(!payload || !json_is_object(payload->json))
-    {
-        return 0;
-    }
-    members = json_object_get(payload->json, "Members");
-    count = json_object_get(payload->json, "Members@odata.count");
-    if(!members || !count)
-    {
-        return 0;
-    }
-    return (size_t)json_integer_value(count);
+  if (!payload || !json_is_object (payload->json)) {
+    return 0;
+  }
+
+  members = json_object_get (payload->json, "Members");
+  count   = json_object_get (payload->json, "Members@odata.count");
+  if (!members || !count) {
+    return 0;
+  }
+
+  return (size_t)json_integer_value (count);
 }
 }
 
 
-bool isPayloadArray(redfishPayload* payload)
+bool
+isPayloadArray (
+  redfishPayload  *payload
+  )
 {
 {
-    if(!payload || !json_is_array(payload->json))
-    {
-        return false;
-    }
-    return true;
+  if (!payload || !json_is_array (payload->json)) {
+    return false;
+  }
+
+  return true;
 }
 }
 
 
-char* payloadToString(redfishPayload* payload, bool prettyPrint)
+char *
+payloadToString (
+  redfishPayload  *payload,
+  bool            prettyPrint
+  )
 {
 {
-    size_t flags = 0;
-    if(!payload)
-    {
-        return NULL;
-    }
-    if(prettyPrint)
-    {
-        flags = JSON_INDENT(2);
-    }
-    return json_dumps(payload->json, flags);
+  size_t  flags = 0;
+
+  if (!payload) {
+    return NULL;
+  }
+
+  if (prettyPrint) {
+    flags = JSON_INDENT (2);
+  }
+
+  return json_dumps (payload->json, flags);
 }
 }
 
 
-redfishPayload* createRedfishPayload(json_t* value, redfishService* service)
+redfishPayload *
+createRedfishPayload (
+  json_t          *value,
+  redfishService  *service
+  )
 {
 {
-    redfishPayload* payload;
-    payload = (redfishPayload*)malloc(sizeof(redfishPayload));
-    if(payload != NULL)
-    {
-        payload->json = value;
-        payload->service = service;
-    }
-    return payload;
+  redfishPayload  *payload;
+
+  payload = (redfishPayload *)malloc (sizeof (redfishPayload));
+  if (payload != NULL) {
+    payload->json    = value;
+    payload->service = service;
+  }
+
+  return payload;
 }
 }
 
 
-redfishPayload* getPayloadByNodeName(redfishPayload* payload, const char* nodeName, EFI_HTTP_STATUS_CODE** StatusCode)
+redfishPayload *
+getPayloadByNodeName (
+  redfishPayload        *payload,
+  const char            *nodeName,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  )
 {
 {
-    json_t* value;
-    json_t* odataId;
-    const char* uri;
+  json_t      *value;
+  json_t      *odataId;
+  const char  *uri;
 
 
-    if(!payload || !nodeName || StatusCode == NULL)
-    {
-        return NULL;
-    }
+  if (!payload || !nodeName || (StatusCode == NULL)) {
+    return NULL;
+  }
 
 
-    *StatusCode = NULL;
+  *StatusCode = NULL;
 
 
-    value = json_object_get(payload->json, nodeName);
-    if(value == NULL)
-    {
+  value = json_object_get (payload->json, nodeName);
+  if (value == NULL) {
+    return NULL;
+  }
+
+  json_incref (value);
+  if (json_object_size (value) == 1) {
+    odataId = json_object_get (value, "@odata.id");
+    if (odataId != NULL) {
+      json_incref (odataId);
+      uri = json_string_value (odataId);
+      json_decref (value);
+      value = getUriFromService (payload->service, uri, StatusCode);
+      json_decref (odataId);
+      if ((value == NULL) || (*StatusCode == NULL)) {
         return NULL;
         return NULL;
-    }
-    json_incref(value);
-    if(json_object_size(value) == 1)
-    {
-        odataId = json_object_get(value, "@odata.id");
-        if(odataId != NULL)
-        {
-            json_incref(odataId);
-            uri = json_string_value(odataId);
-            json_decref(value);
-            value = getUriFromService(payload->service, uri, StatusCode);
-            json_decref(odataId);
-            if(value == NULL || *StatusCode == NULL)
-            {
-              return NULL;
-            }
-        }
-    }
-    if (*StatusCode == NULL || (**StatusCode >= HTTP_STATUS_200_OK && **StatusCode <= HTTP_STATUS_206_PARTIAL_CONTENT)) {
-      if(json_is_string(value))
-      {
-          odataId = json_object();
-          json_object_set(odataId, nodeName, value);
-          json_decref(value);
-          value = odataId;
       }
       }
     }
     }
+  }
+
+  if ((*StatusCode == NULL) || ((**StatusCode >= HTTP_STATUS_200_OK) && (**StatusCode <= HTTP_STATUS_206_PARTIAL_CONTENT))) {
+    if (json_is_string (value)) {
+      odataId = json_object ();
+      json_object_set (odataId, nodeName, value);
+      json_decref (value);
+      value = odataId;
+    }
+  }
 
 
-    return createRedfishPayload(value, payload->service);
+  return createRedfishPayload (value, payload->service);
 }
 }
 
 
-redfishPayload* getPayloadByIndex(redfishPayload* payload, size_t index, EFI_HTTP_STATUS_CODE** StatusCode)
+redfishPayload *
+getPayloadByIndex (
+  redfishPayload        *payload,
+  size_t                index,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  )
 {
 {
-    json_t* value = NULL;
-    json_t* odataId;
-    const char* uri;
-    BOOLEAN FromServerFlag = FALSE;
+  json_t      *value = NULL;
+  json_t      *odataId;
+  const char  *uri;
+  BOOLEAN     FromServerFlag = FALSE;
 
 
-    if(!payload || StatusCode == NULL)
-    {
-        return NULL;
-    }
+  if (!payload || (StatusCode == NULL)) {
+    return NULL;
+  }
 
 
-    *StatusCode = NULL;
+  *StatusCode = NULL;
 
 
-    if(isPayloadCollection(payload))
+  if (isPayloadCollection (payload)) {
+    redfishPayload  *members = getPayloadByNodeName (payload, "Members", StatusCode);
+    if (((*StatusCode == NULL) && (members == NULL)) ||
+        ((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
     {
     {
-        redfishPayload* members = getPayloadByNodeName(payload, "Members", StatusCode);
-        if ((*StatusCode == NULL && members == NULL) ||
-            (*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
-          return members;
-        }
+      return members;
+    }
 
 
-        if (*StatusCode != NULL) {
-          //
-          // The Payload (members) are retrived from server.
-          //
-          FreePool (*StatusCode);
-          *StatusCode = NULL;
-          FromServerFlag = TRUE;
-        }
+    if (*StatusCode != NULL) {
+      //
+      // The Payload (members) are retrived from server.
+      //
+      FreePool (*StatusCode);
+      *StatusCode    = NULL;
+      FromServerFlag = TRUE;
+    }
+
+    redfishPayload  *ret = getPayloadByIndex (members, index, StatusCode);
+    if ((*StatusCode == NULL) && (ret != NULL) && FromServerFlag) {
+      //
+      // In such a case, the Redfish resource is parsed from the input payload (members) directly.
+      // Since the members are retrived from server, we still return HTTP_STATUS_200_OK.
+      //
+      *StatusCode = AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE));
+      if (*StatusCode == NULL) {
+        ret = NULL;
+      } else {
+        **StatusCode = HTTP_STATUS_200_OK;
+      }
+    }
 
 
-        redfishPayload* ret = getPayloadByIndex(members, index, StatusCode);
-        if (*StatusCode == NULL && ret != NULL && FromServerFlag) {
-          //
-          // In such a case, the Redfish resource is parsed from the input payload (members) directly.
-          // Since the members are retrived from server, we still return HTTP_STATUS_200_OK.
-          //
-          *StatusCode = AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE));
-          if (*StatusCode == NULL) {
-            ret = NULL;
-          } else {
-            **StatusCode = HTTP_STATUS_200_OK;
-          }
-        }
+    cleanupPayload (members);
+    return ret;
+  }
 
 
-        cleanupPayload(members);
-        return ret;
-    }
+  if (json_is_array (payload->json)) {
+    //
+    // The valid range for index is from 0 to the return value of json_array_size() minus 1
+    //
+    value = json_array_get (payload->json, index);
+  } else if (json_is_object (payload->json)) {
+    value = json_object_get_by_index (payload->json, index);
+  }
 
 
-    if(json_is_array(payload->json))
-    {
-        //
-        // The valid range for index is from 0 to the return value of json_array_size() minus 1
-        //
-        value = json_array_get(payload->json, index);
-    }
-    else if(json_is_object(payload->json))
-    {
-        value = json_object_get_by_index(payload->json, index);
-    }
+  if (value == NULL) {
+    return NULL;
+  }
 
 
-    if(value == NULL)
-    {
+  json_incref (value);
+  if (json_object_size (value) == 1) {
+    odataId = json_object_get (value, "@odata.id");
+    if (odataId != NULL) {
+      uri = json_string_value (odataId);
+      json_decref (value);
+      value = getUriFromService (payload->service, uri, StatusCode);
+      if (value == NULL) {
         return NULL;
         return NULL;
+      }
     }
     }
+  }
 
 
-    json_incref(value);
-    if(json_object_size(value) == 1)
-    {
-        odataId = json_object_get(value, "@odata.id");
-        if(odataId != NULL)
-        {
-            uri = json_string_value(odataId);
-            json_decref(value);
-            value = getUriFromService(payload->service, uri, StatusCode);
-            if(value == NULL)
-            {
-                return NULL;
-            }
-        }
-    }
-    return createRedfishPayload(value, payload->service);
+  return createRedfishPayload (value, payload->service);
 }
 }
 
 
-redfishPayload* getPayloadForPath(redfishPayload* payload, redPathNode* redpath, EFI_HTTP_STATUS_CODE** StatusCode)
+redfishPayload *
+getPayloadForPath (
+  redfishPayload        *payload,
+  redPathNode           *redpath,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  )
 {
 {
-    redfishPayload* ret = NULL;
-    redfishPayload* tmp;
+  redfishPayload  *ret = NULL;
+  redfishPayload  *tmp;
 
 
-    if(!payload || !redpath || StatusCode == NULL)
-    {
-        return NULL;
-    }
-
-    *StatusCode = NULL;
-    BOOLEAN FromServerFlag = FALSE;
+  if (!payload || !redpath || (StatusCode == NULL)) {
+    return NULL;
+  }
 
 
-    if(redpath->nodeName)
-    {
-        ret = getPayloadByNodeName(payload, redpath->nodeName, StatusCode);
-        if ((*StatusCode == NULL && ret == NULL) ||
-            (*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
-            //
-            // Any error happen, return directly.
-            //
-          return ret;
-        }
-    }
-    else if(redpath->isIndex)
-    {
-        ASSERT (redpath->index >= 1);
-        ret = getPayloadByIndex(payload, redpath->index - 1, StatusCode);
-        if ((*StatusCode == NULL && ret == NULL) ||
-            (*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
-            //
-            // Any error happen, return directly.
-            //
-          return ret;
-        }
-    }
-    else if(redpath->op)
-    {
-        ret = getOpResult(payload, redpath->propName, redpath->op, redpath->value, StatusCode);
-        if ((*StatusCode == NULL && ret == NULL) ||
-            (*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
-            //
-            // Any error happen, return directly.
-            //
-          return ret;
-        }
-    }
-    else
-    {
-        return NULL;
-    }
+  *StatusCode = NULL;
+  BOOLEAN  FromServerFlag = FALSE;
+
+  if (redpath->nodeName) {
+    ret = getPayloadByNodeName (payload, redpath->nodeName, StatusCode);
+    if (((*StatusCode == NULL) && (ret == NULL)) ||
+        ((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
+    {
+      //
+      // Any error happen, return directly.
+      //
+      return ret;
+    }
+  } else if (redpath->isIndex) {
+    ASSERT (redpath->index >= 1);
+    ret = getPayloadByIndex (payload, redpath->index - 1, StatusCode);
+    if (((*StatusCode == NULL) && (ret == NULL)) ||
+        ((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
+    {
+      //
+      // Any error happen, return directly.
+      //
+      return ret;
+    }
+  } else if (redpath->op) {
+    ret = getOpResult (payload, redpath->propName, redpath->op, redpath->value, StatusCode);
+    if (((*StatusCode == NULL) && (ret == NULL)) ||
+        ((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
+    {
+      //
+      // Any error happen, return directly.
+      //
+      return ret;
+    }
+  } else {
+    return NULL;
+  }
 
 
-    if(redpath->next == NULL || ret == NULL)
-    {
-        return ret;
+  if ((redpath->next == NULL) || (ret == NULL)) {
+    return ret;
+  } else {
+    if (*StatusCode != NULL) {
+      FreePool (*StatusCode);
+      *StatusCode    = NULL;
+      FromServerFlag = TRUE;
+    }
+
+    tmp = getPayloadForPath (ret, redpath->next, StatusCode);
+    if ((*StatusCode == NULL) && (tmp != NULL) && FromServerFlag) {
+      //
+      // In such a case, the Redfish resource is parsed from the input payload (ret) directly.
+      // Since the ret are retrived from server, we still return HTTP_STATUS_200_OK.
+      //
+      *StatusCode = AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE));
+      if (*StatusCode == NULL) {
+        tmp = NULL;
+      } else {
+        **StatusCode = HTTP_STATUS_200_OK;
+      }
     }
     }
-    else
-    {
-        if (*StatusCode != NULL) {
-          FreePool (*StatusCode);
-          *StatusCode = NULL;
-          FromServerFlag = TRUE;
-        }
 
 
-        tmp = getPayloadForPath(ret, redpath->next, StatusCode);
-        if (*StatusCode == NULL && tmp != NULL && FromServerFlag) {
-          //
-          // In such a case, the Redfish resource is parsed from the input payload (ret) directly.
-          // Since the ret are retrived from server, we still return HTTP_STATUS_200_OK.
-          //
-          *StatusCode = AllocateZeroPool (sizeof (EFI_HTTP_STATUS_CODE));
-          if (*StatusCode == NULL) {
-            tmp = NULL;
-          } else {
-            **StatusCode = HTTP_STATUS_200_OK;
-          }
-        }
-
-        cleanupPayload(ret);
-        return tmp;
-    }
+    cleanupPayload (ret);
+    return tmp;
+  }
 }
 }
 
 
-redfishPayload* getPayloadForPathString(redfishPayload* payload, const char* string, EFI_HTTP_STATUS_CODE** StatusCode)
+redfishPayload *
+getPayloadForPathString (
+  redfishPayload        *payload,
+  const char            *string,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  )
 {
 {
-    redPathNode* redpath;
-    redfishPayload* ret;
+  redPathNode     *redpath;
+  redfishPayload  *ret;
 
 
-    if(!string || StatusCode == NULL)
-    {
-        return NULL;
-    }
+  if (!string || (StatusCode == NULL)) {
+    return NULL;
+  }
 
 
-    *StatusCode = NULL;
+  *StatusCode = NULL;
 
 
-    redpath = parseRedPath(string);
-    if(redpath == NULL)
-    {
-        return NULL;
-    }
-    ret = getPayloadForPath(payload, redpath, StatusCode);
-    cleanupRedPath(redpath);
-    return ret;
+  redpath = parseRedPath (string);
+  if (redpath == NULL) {
+    return NULL;
+  }
+
+  ret = getPayloadForPath (payload, redpath, StatusCode);
+  cleanupRedPath (redpath);
+  return ret;
 }
 }
 
 
-redfishPayload* patchPayload(redfishPayload* target, redfishPayload* payload, EFI_HTTP_STATUS_CODE** StatusCode)
+redfishPayload *
+patchPayload (
+  redfishPayload        *target,
+  redfishPayload        *payload,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  )
 {
 {
-  json_t* json;
-  char* content;
-  char* uri;
+  json_t  *json;
+  char    *content;
+  char    *uri;
 
 
-  if(!target || !payload || StatusCode == NULL)
-  {
+  if (!target || !payload || (StatusCode == NULL)) {
     return NULL;
     return NULL;
   }
   }
 
 
   *StatusCode = NULL;
   *StatusCode = NULL;
 
 
-  json = json_object_get(target->json, "@odata.id");
-  if(json == NULL)
-  {
+  json = json_object_get (target->json, "@odata.id");
+  if (json == NULL) {
     return NULL;
     return NULL;
   }
   }
-  uri = strdup(json_string_value(json));
 
 
-  content = json_dumps(payload->json, 0);
-  json_decref(json);
+  uri = strdup (json_string_value (json));
 
 
-  json = patchUriFromService(target->service, uri, content, StatusCode);
-  free(uri);
-  free(content);
-  if(json == NULL)
-  {
+  content = json_dumps (payload->json, 0);
+  json_decref (json);
+
+  json = patchUriFromService (target->service, uri, content, StatusCode);
+  free (uri);
+  free (content);
+  if (json == NULL) {
     return NULL;
     return NULL;
   }
   }
 
 
-  return createRedfishPayload(json, target->service);
+  return createRedfishPayload (json, target->service);
 }
 }
 
 
-redfishPayload* postContentToPayload(redfishPayload* target, const char* data, size_t dataSize, const char* contentType, EFI_HTTP_STATUS_CODE** StatusCode)
+redfishPayload *
+postContentToPayload (
+  redfishPayload        *target,
+  const char            *data,
+  size_t                dataSize,
+  const char            *contentType,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  )
 {
 {
-    json_t* json;
-    char* uri;
+  json_t  *json;
+  char    *uri;
 
 
-    if(!target || !data || StatusCode == NULL)
-    {
-        return NULL;
-    }
+  if (!target || !data || (StatusCode == NULL)) {
+    return NULL;
+  }
 
 
-    *StatusCode = NULL;
+  *StatusCode = NULL;
 
 
-    json = json_object_get(target->json, "@odata.id");
-    if(json == NULL)
-    {
-        json = json_object_get(target->json, "target");
-        if(json == NULL)
-        {
-            return NULL;
-        }
-    }
-    uri = strdup(json_string_value(json));
-    json = postUriFromService(target->service, uri, data, dataSize, contentType, StatusCode);
-    free(uri);
-    if(json == NULL)
-    {
-        return NULL;
+  json = json_object_get (target->json, "@odata.id");
+  if (json == NULL) {
+    json = json_object_get (target->json, "target");
+    if (json == NULL) {
+      return NULL;
     }
     }
+  }
+
+  uri  = strdup (json_string_value (json));
+  json = postUriFromService (target->service, uri, data, dataSize, contentType, StatusCode);
+  free (uri);
+  if (json == NULL) {
+    return NULL;
+  }
 
 
-    return createRedfishPayload(json, target->service);
+  return createRedfishPayload (json, target->service);
 }
 }
 
 
-redfishPayload* postPayload(redfishPayload* target, redfishPayload* payload, EFI_HTTP_STATUS_CODE** StatusCode)
+redfishPayload *
+postPayload (
+  redfishPayload        *target,
+  redfishPayload        *payload,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  )
 {
 {
-    char* content;
-    redfishPayload* ret;
+  char            *content;
+  redfishPayload  *ret;
 
 
-    if(!target || !payload || StatusCode == NULL)
-    {
-        return NULL;
-    }
+  if (!target || !payload || (StatusCode == NULL)) {
+    return NULL;
+  }
 
 
-    *StatusCode = NULL;
+  *StatusCode = NULL;
 
 
-    if(!json_is_object(payload->json))
-    {
-        return NULL;
-    }
-    content = payloadToString(payload, false);
-    ret = postContentToPayload(target, content, strlen(content), NULL, StatusCode);
-    free(content);
-    return ret;
-}
+  if (!json_is_object (payload->json)) {
+    return NULL;
+  }
 
 
-void cleanupPayload(redfishPayload* payload)
-{
-    if(!payload)
-    {
-        return;
-    }
-    json_decref(payload->json);
-    //Don't free payload->service, let the caller handle cleaning up the service
-    free(payload);
+  content = payloadToString (payload, false);
+  ret     = postContentToPayload (target, content, strlen (content), NULL, StatusCode);
+  free (content);
+  return ret;
 }
 }
 
 
-static redfishPayload* getOpResult(redfishPayload* payload, const char* propName, const char* op, const char* value, EFI_HTTP_STATUS_CODE** StatusCode)
+void
+cleanupPayload (
+  redfishPayload  *payload
+  )
 {
 {
-    const char* propStr;
-    json_t* stringProp;
-    bool ret = false;
-    redfishPayload* prop;
-    long long intVal, intPropVal;
-    json_type jsonType;
-
-    if(isPayloadCollection(payload))
-    {
-        return collectionEvalOp(payload, propName, op, value, StatusCode);
-    }
-    if(isPayloadArray(payload))
-    {
-        return arrayEvalOp(payload, propName, op, value, StatusCode);
-    }
+  if (!payload) {
+    return;
+  }
 
 
-    prop = getPayloadByNodeName(payload, propName, StatusCode);
-    if ((*StatusCode == NULL && prop == NULL) ||
-        (*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
-      return prop;
-    }
-    stringProp = prop->json;
-    jsonType = prop->json->type;
-    switch(jsonType)
-    {
-        case JSON_OBJECT:
-            stringProp = json_object_get(prop->json, propName);
-        case JSON_STRING:
-            if(strcmp(op, "=") == 0)
-            {
-                propStr = json_string_value(stringProp);
-                if(propStr == NULL)
-                {
-                    cleanupPayload(prop);
-                    return NULL;
-                }
-                ret = (strcmp(propStr, value) == 0);
-            } else if(strcmp(op, "~") == 0)
-            {
-                propStr = json_string_value(stringProp);
-                if(propStr == NULL)
-                {
-                    cleanupPayload(prop);
-                    return NULL;
-                }
-                ret = (strcasecmp(propStr, value) == 0);
-            }
-            break;
-        case JSON_TRUE:
-            if(strcmp(op, "=") == 0)
-            {
-                ret = (strcmp(value, "true") == 0);
-            }
-            break;
-        case JSON_FALSE:
-            if(strcmp(op, "=") == 0)
-            {
-                ret = (strcmp(value, "false") == 0);
-            }
-            break;
-        case JSON_INTEGER:
-            intPropVal = json_integer_value(prop->json);
-            intVal = strtoll(value, NULL, 0);
-            if(strcmp(op, "=") == 0)
-            {
-                ret = (intPropVal == intVal);
-            }
-            else if(strcmp(op, "<") == 0)
-            {
-                ret = (intPropVal < intVal);
-            }
-            else if(strcmp(op, ">") == 0)
-            {
-                ret = (intPropVal > intVal);
-            }
-            else if(strcmp(op, "<=") == 0)
-            {
-                ret = (intPropVal <= intVal);
-            }
-            else if(strcmp(op, ">=") == 0)
-            {
-                ret = (intPropVal >= intVal);
-            }
-            break;
-        default:
-            break;
-    }
-    cleanupPayload(prop);
-    if(ret)
-    {
-        return payload;
-    }
-    else
-    {
-        return NULL;
-    }
+  json_decref (payload->json);
+  // Don't free payload->service, let the caller handle cleaning up the service
+  free (payload);
 }
 }
 
 
-static redfishPayload* collectionEvalOp(redfishPayload* payload, const char* propName, const char* op, const char* value, EFI_HTTP_STATUS_CODE** StatusCode)
+static redfishPayload *
+getOpResult (
+  redfishPayload        *payload,
+  const char            *propName,
+  const char            *op,
+  const char            *value,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  )
 {
 {
-    redfishPayload* ret;
-    redfishPayload* tmp;
-    redfishPayload* members;
-    redfishPayload** valid;
-    size_t validMax;
-    size_t validCount = 0;
-    size_t i;
-
-    validMax = getCollectionSize(payload);
-    if(validMax == 0)
-    {
-        return NULL;
-    }
+  const char      *propStr;
+  json_t          *stringProp;
+  bool            ret = false;
+  redfishPayload  *prop;
+  long long       intVal, intPropVal;
+  json_type       jsonType;
+
+  if (isPayloadCollection (payload)) {
+    return collectionEvalOp (payload, propName, op, value, StatusCode);
+  }
 
 
-    valid = (redfishPayload**)calloc(validMax, sizeof(redfishPayload*));
-    if(valid == NULL)
-    {
-        return NULL;
-    }
-    /*Technically getPayloadByIndex would do this, but this optimizes things*/
-    members = getPayloadByNodeName(payload, "Members", StatusCode);
-    if ((*StatusCode == NULL && members == NULL) ||
-        (*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
-      return members;
-    }
+  if (isPayloadArray (payload)) {
+    return arrayEvalOp (payload, propName, op, value, StatusCode);
+  }
 
 
-    for(i = 0; i < validMax; i++)
-    {
-        if (*StatusCode != NULL) {
-          FreePool (*StatusCode);
-          *StatusCode = NULL;
-        }
+  prop = getPayloadByNodeName (payload, propName, StatusCode);
+  if (((*StatusCode == NULL) && (prop == NULL)) ||
+      ((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
+  {
+    return prop;
+  }
 
 
-        tmp = getPayloadByIndex(members, i, StatusCode);
-        if ((*StatusCode == NULL && tmp == NULL) ||
-            (*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
-          return tmp;
+  stringProp = prop->json;
+  jsonType   = prop->json->type;
+  switch (jsonType) {
+    case JSON_OBJECT:
+      stringProp = json_object_get (prop->json, propName);
+    case JSON_STRING:
+      if (strcmp (op, "=") == 0) {
+        propStr = json_string_value (stringProp);
+        if (propStr == NULL) {
+          cleanupPayload (prop);
+          return NULL;
         }
         }
 
 
-        if (*StatusCode != NULL) {
-          FreePool (*StatusCode);
-          *StatusCode = NULL;
+        ret = (strcmp (propStr, value) == 0);
+      } else if (strcmp (op, "~") == 0) {
+        propStr = json_string_value (stringProp);
+        if (propStr == NULL) {
+          cleanupPayload (prop);
+          return NULL;
         }
         }
 
 
-        valid[validCount] = getOpResult(tmp, propName, op, value, StatusCode);
-        /*
-        if ((*StatusCode == NULL && valid[validCount] == NULL) ||
-            (*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
-          return valid[validCount];
-        }
-        */
-        if(valid[validCount] != NULL)
-        {
-            validCount++;
-        }
-        else
-        {
-            cleanupPayload(tmp);
-        }
-    }
-    cleanupPayload(members);
-    if(validCount == 0)
-    {
-        free(valid);
-        return NULL;
-    }
-    if(validCount == 1)
-    {
-        ret = valid[0];
-        free(valid);
-        return ret;
-    }
-    else
-    {
-        ret = createCollection(payload->service, validCount, valid);
-        free(valid);
-        return ret;
-    }
+        ret = (strcasecmp (propStr, value) == 0);
+      }
+
+      break;
+    case JSON_TRUE:
+      if (strcmp (op, "=") == 0) {
+        ret = (strcmp (value, "true") == 0);
+      }
+
+      break;
+    case JSON_FALSE:
+      if (strcmp (op, "=") == 0) {
+        ret = (strcmp (value, "false") == 0);
+      }
+
+      break;
+    case JSON_INTEGER:
+      intPropVal = json_integer_value (prop->json);
+      intVal     = strtoll (value, NULL, 0);
+      if (strcmp (op, "=") == 0) {
+        ret = (intPropVal == intVal);
+      } else if (strcmp (op, "<") == 0) {
+        ret = (intPropVal < intVal);
+      } else if (strcmp (op, ">") == 0) {
+        ret = (intPropVal > intVal);
+      } else if (strcmp (op, "<=") == 0) {
+        ret = (intPropVal <= intVal);
+      } else if (strcmp (op, ">=") == 0) {
+        ret = (intPropVal >= intVal);
+      }
+
+      break;
+    default:
+      break;
+  }
+
+  cleanupPayload (prop);
+  if (ret) {
+    return payload;
+  } else {
+    return NULL;
+  }
 }
 }
 
 
-static redfishPayload* arrayEvalOp(redfishPayload* payload, const char* propName, const char* op, const char* value, EFI_HTTP_STATUS_CODE** StatusCode)
+static redfishPayload *
+collectionEvalOp (
+  redfishPayload        *payload,
+  const char            *propName,
+  const char            *op,
+  const char            *value,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  )
 {
 {
-    redfishPayload* ret;
-    redfishPayload* tmp;
-    redfishPayload** valid;
-    size_t validMax;
-    size_t validCount = 0;
-    size_t i;
-
-    validMax = json_array_size(payload->json);
-    if(validMax == 0)
-    {
-        return NULL;
+  redfishPayload  *ret;
+  redfishPayload  *tmp;
+  redfishPayload  *members;
+  redfishPayload  **valid;
+  size_t          validMax;
+  size_t          validCount = 0;
+  size_t          i;
+
+  validMax = getCollectionSize (payload);
+  if (validMax == 0) {
+    return NULL;
+  }
+
+  valid = (redfishPayload **)calloc (validMax, sizeof (redfishPayload *));
+  if (valid == NULL) {
+    return NULL;
+  }
+
+  /*Technically getPayloadByIndex would do this, but this optimizes things*/
+  members = getPayloadByNodeName (payload, "Members", StatusCode);
+  if (((*StatusCode == NULL) && (members == NULL)) ||
+      ((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
+  {
+    return members;
+  }
+
+  for (i = 0; i < validMax; i++) {
+    if (*StatusCode != NULL) {
+      FreePool (*StatusCode);
+      *StatusCode = NULL;
     }
     }
 
 
-    valid = (redfishPayload**)calloc(validMax, sizeof(redfishPayload*));
-    if(valid == NULL)
+    tmp = getPayloadByIndex (members, i, StatusCode);
+    if (((*StatusCode == NULL) && (tmp == NULL)) ||
+        ((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
     {
     {
-        return NULL;
+      return tmp;
     }
     }
-    for(i = 0; i < validMax; i++)
-    {
-        if (*StatusCode != NULL) {
-          FreePool (*StatusCode);
-          *StatusCode = NULL;
-        }
 
 
-        tmp = getPayloadByIndex(payload, i, StatusCode);
-        if ((*StatusCode == NULL && tmp == NULL) ||
-            (*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
-          return tmp;
-        }
-
-        if (*StatusCode != NULL) {
-          FreePool (*StatusCode);
-          *StatusCode = NULL;
-        }
+    if (*StatusCode != NULL) {
+      FreePool (*StatusCode);
+      *StatusCode = NULL;
+    }
 
 
-        valid[validCount] = getOpResult(tmp, propName, op, value, StatusCode);
-        /*
-        if ((*StatusCode == NULL && valid[validCount] == NULL) ||
-            (*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
-          return valid[validCount];
-        }
-        */
+    valid[validCount] = getOpResult (tmp, propName, op, value, StatusCode);
 
 
-        if(valid[validCount] != NULL)
-        {
-            validCount++;
-        }
-        else
-        {
-            cleanupPayload(tmp);
-        }
-    }
-    if(validCount == 0)
-    {
-        free(valid);
-        return NULL;
-    }
-    if(validCount == 1)
-    {
-        ret = valid[0];
-        free(valid);
-        return ret;
+    /*
+    if ((*StatusCode == NULL && valid[validCount] == NULL) ||
+        (*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
+      return valid[validCount];
     }
     }
-    else
-    {
-        ret = createCollection(payload->service, validCount, valid);
-        free(valid);
-        return ret;
+    */
+    if (valid[validCount] != NULL) {
+      validCount++;
+    } else {
+      cleanupPayload (tmp);
     }
     }
+  }
+
+  cleanupPayload (members);
+  if (validCount == 0) {
+    free (valid);
+    return NULL;
+  }
+
+  if (validCount == 1) {
+    ret = valid[0];
+    free (valid);
+    return ret;
+  } else {
+    ret = createCollection (payload->service, validCount, valid);
+    free (valid);
+    return ret;
+  }
 }
 }
 
 
-static redfishPayload* createCollection(redfishService* service, size_t count, redfishPayload** payloads)
+static redfishPayload *
+arrayEvalOp (
+  redfishPayload        *payload,
+  const char            *propName,
+  const char            *op,
+  const char            *value,
+  EFI_HTTP_STATUS_CODE  **StatusCode
+  )
 {
 {
-    redfishPayload* ret;
-    json_t* collectionJson = json_object();
-    json_t* jcount = json_integer((json_int_t)count);
-    json_t* members = json_array();
-    size_t i;
+  redfishPayload  *ret;
+  redfishPayload  *tmp;
+  redfishPayload  **valid;
+  size_t          validMax;
+  size_t          validCount = 0;
+  size_t          i;
+
+  validMax = json_array_size (payload->json);
+  if (validMax == 0) {
+    return NULL;
+  }
 
 
-    if(!collectionJson)
-    {
-        return NULL;
+  valid = (redfishPayload **)calloc (validMax, sizeof (redfishPayload *));
+  if (valid == NULL) {
+    return NULL;
+  }
+
+  for (i = 0; i < validMax; i++) {
+    if (*StatusCode != NULL) {
+      FreePool (*StatusCode);
+      *StatusCode = NULL;
     }
     }
-    if(!members)
+
+    tmp = getPayloadByIndex (payload, i, StatusCode);
+    if (((*StatusCode == NULL) && (tmp == NULL)) ||
+        ((*StatusCode != NULL) && ((**StatusCode < HTTP_STATUS_200_OK) || (**StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))))
     {
     {
-        json_decref(collectionJson);
-        return NULL;
+      return tmp;
     }
     }
-    json_object_set(collectionJson, "Members@odata.count", jcount);
-    json_decref(jcount);
-    for(i = 0; i < count; i++)
-    {
-        json_array_append(members, payloads[i]->json);
-        cleanupPayload(payloads[i]);
+
+    if (*StatusCode != NULL) {
+      FreePool (*StatusCode);
+      *StatusCode = NULL;
+    }
+
+    valid[validCount] = getOpResult (tmp, propName, op, value, StatusCode);
+
+    /*
+    if ((*StatusCode == NULL && valid[validCount] == NULL) ||
+        (*StatusCode != NULL && (**StatusCode < HTTP_STATUS_200_OK || **StatusCode > HTTP_STATUS_206_PARTIAL_CONTENT))) {
+      return valid[validCount];
     }
     }
-    json_object_set(collectionJson, "Members", members);
-    json_decref(members);
+    */
+
+    if (valid[validCount] != NULL) {
+      validCount++;
+    } else {
+      cleanupPayload (tmp);
+    }
+  }
+
+  if (validCount == 0) {
+    free (valid);
+    return NULL;
+  }
 
 
-    ret = createRedfishPayload(collectionJson, service);
+  if (validCount == 1) {
+    ret = valid[0];
+    free (valid);
+    return ret;
+  } else {
+    ret = createCollection (payload->service, validCount, valid);
+    free (valid);
     return ret;
     return ret;
+  }
 }
 }
 
 
-static json_t* json_object_get_by_index(json_t* json, size_t index)
+static redfishPayload *
+createCollection (
+  redfishService  *service,
+  size_t          count,
+  redfishPayload  **payloads
+  )
 {
 {
-    void* iter;
-    size_t i;
+  redfishPayload  *ret;
+  json_t          *collectionJson = json_object ();
+  json_t          *jcount         = json_integer ((json_int_t)count);
+  json_t          *members        = json_array ();
+  size_t          i;
 
 
-    iter = json_object_iter(json);
-    for(i = 0; i < index; i++)
-    {
-        iter = json_object_iter_next(json, iter);
-        if(iter == NULL) break;
-    }
-    if(iter == NULL)
-    {
-        return NULL;
+  if (!collectionJson) {
+    return NULL;
+  }
+
+  if (!members) {
+    json_decref (collectionJson);
+    return NULL;
+  }
+
+  json_object_set (collectionJson, "Members@odata.count", jcount);
+  json_decref (jcount);
+  for (i = 0; i < count; i++) {
+    json_array_append (members, payloads[i]->json);
+    cleanupPayload (payloads[i]);
+  }
+
+  json_object_set (collectionJson, "Members", members);
+  json_decref (members);
+
+  ret = createRedfishPayload (collectionJson, service);
+  return ret;
+}
+
+static json_t *
+json_object_get_by_index (
+  json_t  *json,
+  size_t  index
+  )
+{
+  void    *iter;
+  size_t  i;
+
+  iter = json_object_iter (json);
+  for (i = 0; i < index; i++) {
+    iter = json_object_iter_next (json, iter);
+    if (iter == NULL) {
+      break;
     }
     }
-    return json_object_iter_value(iter);
+  }
+
+  if (iter == NULL) {
+    return NULL;
+  }
+
+  return json_object_iter_value (iter);
 }
 }
+
 /* vim: set tabstop=4 shiftwidth=4 expandtab: */
 /* vim: set tabstop=4 shiftwidth=4 expandtab: */

+ 188 - 156
RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/redpath.c

@@ -16,177 +16,209 @@
 **/
 **/
 #include <redpath.h>
 #include <redpath.h>
 
 
-static char* getVersion(const char* path, char** end);
-static void parseNode(const char* path, redPathNode* node, redPathNode** end);
+static char *
+getVersion (
+  const char  *path,
+  char        **end
+  );
+
+static void
+parseNode (
+  const char   *path,
+  redPathNode  *node,
+  redPathNode  **end
+  );
+
+static char *
+getStringTill (
+  const char  *string,
+  const char  *terminator,
+  char        **retEnd
+  );
+
+redPathNode *
+parseRedPath (
+  const char  *path
+  )
+{
+  redPathNode  *node;
+  redPathNode  *endNode;
+  char         *curPath;
+  char         *end;
+
+  if (!path || (strlen (path) == 0)) {
+    return NULL;
+  }
+
+  node = (redPathNode *)calloc (1, sizeof (redPathNode));
+  if (!node) {
+    return NULL;
+  }
+
+  if (path[0] == '/') {
+    node->isRoot = true;
+    if (path[1] == 'v') {
+      node->version = getVersion (path+1, &curPath);
+      if (curPath == NULL) {
+        return node;
+      }
 
 
-static char* getStringTill(const char* string, const char* terminator, char** retEnd);
+      if (curPath[0] == '/') {
+        curPath++;
+      }
 
 
-redPathNode* parseRedPath(const char* path)
-{
-    redPathNode* node;
-    redPathNode* endNode;
-    char* curPath;
-    char* end;
-
-    if(!path || strlen(path) == 0)
-    {
-        return NULL;
+      node->next = parseRedPath (curPath);
+    } else {
+      node->next = parseRedPath (path+1);
     }
     }
 
 
-    node = (redPathNode*)calloc(1, sizeof(redPathNode));
-    if(!node)
-    {
-        return NULL;
-    }
-    if(path[0] == '/')
-    {
-        node->isRoot = true;
-        if(path[1] == 'v')
-        {
-            node->version = getVersion(path+1, &curPath);
-            if(curPath == NULL)
-            {
-                return node;
-            }
-            if(curPath[0] == '/')
-            {
-                curPath++;
-            }
-            node->next = parseRedPath(curPath);
-        }
-        else
-        {
-           node->next = parseRedPath(path+1);
-        }
-        return node;
-    }
-    node->isRoot = false;
-    curPath = getStringTill(path, "/", &end);
-    endNode = node;
-    parseNode(curPath, node, &endNode);
-    free(curPath);
-    if(end != NULL)
-    {
-        endNode->next = parseRedPath(end+1);
-    }
     return node;
     return node;
+  }
+
+  node->isRoot = false;
+  curPath      = getStringTill (path, "/", &end);
+  endNode      = node;
+  parseNode (curPath, node, &endNode);
+  free (curPath);
+  if (end != NULL) {
+    endNode->next = parseRedPath (end+1);
+  }
+
+  return node;
 }
 }
 
 
-void cleanupRedPath(redPathNode* node)
+void
+cleanupRedPath (
+  redPathNode  *node
+  )
 {
 {
-    if(!node)
-    {
-        return;
-    }
-    cleanupRedPath(node->next);
-    node->next = NULL;
-    if(node->version)
-    {
-        free(node->version);
-    }
-    if(node->nodeName)
-    {
-        free(node->nodeName);
-    }
-    if(node->op)
-    {
-        free(node->op);
-    }
-    if(node->propName)
-    {
-        free(node->propName);
-    }
-    if(node->value)
-    {
-        free(node->value);
-    }
-    free(node);
+  if (!node) {
+    return;
+  }
+
+  cleanupRedPath (node->next);
+  node->next = NULL;
+  if (node->version) {
+    free (node->version);
+  }
+
+  if (node->nodeName) {
+    free (node->nodeName);
+  }
+
+  if (node->op) {
+    free (node->op);
+  }
+
+  if (node->propName) {
+    free (node->propName);
+  }
+
+  if (node->value) {
+    free (node->value);
+  }
+
+  free (node);
 }
 }
 
 
-static char* getVersion(const char* path, char** end)
+static char *
+getVersion (
+  const char  *path,
+  char        **end
+  )
 {
 {
-    return getStringTill(path, "/", end);
+  return getStringTill (path, "/", end);
 }
 }
 
 
-static void parseNode(const char* path, redPathNode* node, redPathNode** end)
+static void
+parseNode (
+  const char   *path,
+  redPathNode  *node,
+  redPathNode  **end
+  )
 {
 {
-    char* indexStart;
-    char* index;
-    char* indexEnd;
-    char* nodeName = getStringTill(path, "[", &indexStart);
-    size_t tmpIndex;
-    char* opChars;
-
-    node->nodeName = nodeName;
-    if(indexStart == NULL)
-    {
-        *end = node;
-        return;
-    }
-    node->next = (redPathNode*)calloc(1, sizeof(redPathNode));
-    if(!node->next)
-    {
-        return;
-    }
-    //Skip past [
-    indexStart++;
-    *end = node->next;
-    index = getStringTill(indexStart, "]", NULL);
-    tmpIndex = (size_t)strtoull(index, &indexEnd, 0);
-    if(indexEnd != index)
-    {
-        free(index);
-        node->next->index = tmpIndex;
-        node->next->isIndex = true;
-        return;
-    }
-    opChars = strpbrk(index, "<>=~");
-    if(opChars == NULL)
-    {
-        //TODO handle last() and position()
-        node->next->op = strdup("exists");
-        node->next->propName = index;
-        return;
-    }
-    node->next->propName = (char*)malloc((opChars - index)+1);
-    memcpy(node->next->propName, index, (opChars - index));
-    node->next->propName[(opChars - index)] = 0;
-
-    tmpIndex = 1;
-    while(1)
-    {
-        if(opChars[tmpIndex] == '=' || opChars[tmpIndex] == '<' || opChars[tmpIndex] == '>' || opChars[tmpIndex] == '~')
-        {
-            tmpIndex++;
-            continue;
-        }
-        break;
-    }
-
-    node->next->op = (char*)malloc(tmpIndex+1);
-    memcpy(node->next->op, opChars, tmpIndex);
-    node->next->op[tmpIndex] = 0;
-
-    node->next->value = strdup(opChars+tmpIndex);
-    free(index);
+  char    *indexStart;
+  char    *index;
+  char    *indexEnd;
+  char    *nodeName = getStringTill (path, "[", &indexStart);
+  size_t  tmpIndex;
+  char    *opChars;
+
+  node->nodeName = nodeName;
+  if (indexStart == NULL) {
+    *end = node;
+    return;
+  }
+
+  node->next = (redPathNode *)calloc (1, sizeof (redPathNode));
+  if (!node->next) {
+    return;
+  }
+
+  // Skip past [
+  indexStart++;
+  *end     = node->next;
+  index    = getStringTill (indexStart, "]", NULL);
+  tmpIndex = (size_t)strtoull (index, &indexEnd, 0);
+  if (indexEnd != index) {
+    free (index);
+    node->next->index   = tmpIndex;
+    node->next->isIndex = true;
+    return;
+  }
+
+  opChars = strpbrk (index, "<>=~");
+  if (opChars == NULL) {
+    // TODO handle last() and position()
+    node->next->op       = strdup ("exists");
+    node->next->propName = index;
+    return;
+  }
+
+  node->next->propName = (char *)malloc ((opChars - index)+1);
+  memcpy (node->next->propName, index, (opChars - index));
+  node->next->propName[(opChars - index)] = 0;
+
+  tmpIndex = 1;
+  while (1) {
+    if ((opChars[tmpIndex] == '=') || (opChars[tmpIndex] == '<') || (opChars[tmpIndex] == '>') || (opChars[tmpIndex] == '~')) {
+      tmpIndex++;
+      continue;
+    }
+
+    break;
+  }
+
+  node->next->op = (char *)malloc (tmpIndex+1);
+  memcpy (node->next->op, opChars, tmpIndex);
+  node->next->op[tmpIndex] = 0;
+
+  node->next->value = strdup (opChars+tmpIndex);
+  free (index);
 }
 }
 
 
-static char* getStringTill(const char* string, const char* terminator, char** retEnd)
+static char *
+getStringTill (
+  const char  *string,
+  const char  *terminator,
+  char        **retEnd
+  )
 {
 {
-    char* ret;
-    char* end;
-    end = strstr((char*)string, terminator);
-    if(retEnd)
-    {
-        *retEnd = end;
-    }
-    if(end == NULL)
-    {
-        //No terminator
-        return strdup(string);
-    }
-    ret = (char*)malloc((end-string)+1);
-    memcpy(ret, string, (end-string));
-    ret[(end-string)] = 0;
-    return ret;
+  char  *ret;
+  char  *end;
+
+  end = strstr ((char *)string, terminator);
+  if (retEnd) {
+    *retEnd = end;
+  }
+
+  if (end == NULL) {
+    // No terminator
+    return strdup (string);
+  }
+
+  ret = (char *)malloc ((end-string)+1);
+  memcpy (ret, string, (end-string));
+  ret[(end-string)] = 0;
+  return ret;
 }
 }

File diff suppressed because it is too large
+ 410 - 311
RedfishPkg/PrivateLibrary/RedfishLib/edk2libredfish/src/service.c


+ 48 - 40
RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerCommon.c

@@ -9,12 +9,12 @@
 
 
 #include "RedfishConfigHandlerCommon.h"
 #include "RedfishConfigHandlerCommon.h"
 
 
-REDFISH_CONFIG_DRIVER_DATA      gRedfishConfigData; // Only one Redfish service supproted
+REDFISH_CONFIG_DRIVER_DATA  gRedfishConfigData;     // Only one Redfish service supproted
                                                     // on platform for the BIOS
                                                     // on platform for the BIOS
                                                     // Redfish configuration.
                                                     // Redfish configuration.
-EFI_EVENT  gEndOfDxeEvent = NULL;
-EFI_EVENT  gExitBootServiceEvent = NULL;
-EDKII_REDFISH_CREDENTIAL_PROTOCOL *gCredential = NULL;
+EFI_EVENT                          gEndOfDxeEvent        = NULL;
+EFI_EVENT                          gExitBootServiceEvent = NULL;
+EDKII_REDFISH_CREDENTIAL_PROTOCOL  *gCredential          = NULL;
 
 
 /**
 /**
   Callback function executed when the EndOfDxe event group is signaled.
   Callback function executed when the EndOfDxe event group is signaled.
@@ -30,10 +30,10 @@ RedfishConfigOnEndOfDxe (
   OUT VOID       *Context
   OUT VOID       *Context
   )
   )
 {
 {
-  EFI_STATUS                          Status;
+  EFI_STATUS  Status;
 
 
   Status = gCredential->StopService (gCredential, ServiceStopTypeSecureBootDisabled);
   Status = gCredential->StopService (gCredential, ServiceStopTypeSecureBootDisabled);
-  if (EFI_ERROR(Status) && Status != EFI_UNSUPPORTED) {
+  if (EFI_ERROR (Status) && (Status != EFI_UNSUPPORTED)) {
     DEBUG ((DEBUG_ERROR, "Redfish credential protocol faied to stop service on EndOfDxe: %r", Status));
     DEBUG ((DEBUG_ERROR, "Redfish credential protocol faied to stop service on EndOfDxe: %r", Status));
   }
   }
 
 
@@ -58,10 +58,10 @@ RedfishConfigOnExitBootService (
   OUT VOID       *Context
   OUT VOID       *Context
   )
   )
 {
 {
-  EFI_STATUS                          Status;
+  EFI_STATUS  Status;
 
 
   Status = gCredential->StopService (gCredential, ServiceStopTypeExitBootService);
   Status = gCredential->StopService (gCredential, ServiceStopTypeExitBootService);
-  if (EFI_ERROR(Status) && Status != EFI_UNSUPPORTED) {
+  if (EFI_ERROR (Status) && (Status != EFI_UNSUPPORTED)) {
     DEBUG ((DEBUG_ERROR, "Redfish credential protocol faied to stop service on ExitBootService: %r", Status));
     DEBUG ((DEBUG_ERROR, "Redfish credential protocol faied to stop service on ExitBootService: %r", Status));
   }
   }
 }
 }
@@ -113,16 +113,18 @@ RedfishConfigCommonInit (
   IN EFI_SYSTEM_TABLE  *SystemTable
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
   )
 {
 {
-  EFI_STATUS Status;
+  EFI_STATUS  Status;
+
   //
   //
   // Locate Redfish Credential Protocol to get credential for
   // Locate Redfish Credential Protocol to get credential for
   // accessing to Redfish service.
   // accessing to Redfish service.
   //
   //
-  Status = gBS->LocateProtocol (&gEdkIIRedfishCredentialProtocolGuid, NULL, (VOID **) &gCredential);
+  Status = gBS->LocateProtocol (&gEdkIIRedfishCredentialProtocolGuid, NULL, (VOID **)&gCredential);
   if (EFI_ERROR (Status)) {
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_INFO, "%a: No Redfish Credential Protocol is installed on system.", __FUNCTION__));
     DEBUG ((DEBUG_INFO, "%a: No Redfish Credential Protocol is installed on system.", __FUNCTION__));
     return Status;
     return Status;
   }
   }
+
   //
   //
   // Create EndOfDxe Event.
   // Create EndOfDxe Event.
   //
   //
@@ -138,6 +140,7 @@ RedfishConfigCommonInit (
     DEBUG ((DEBUG_ERROR, "%a: Fail to register End Of DXE event.", __FUNCTION__));
     DEBUG ((DEBUG_ERROR, "%a: Fail to register End Of DXE event.", __FUNCTION__));
     return Status;
     return Status;
   }
   }
+
   //
   //
   // Create Exit Boot Service event.
   // Create Exit Boot Service event.
   //
   //
@@ -155,8 +158,10 @@ RedfishConfigCommonInit (
     DEBUG ((DEBUG_ERROR, "%a: Fail to register Exit Boot Service event.", __FUNCTION__));
     DEBUG ((DEBUG_ERROR, "%a: Fail to register Exit Boot Service event.", __FUNCTION__));
     return Status;
     return Status;
   }
   }
+
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }
+
 /**
 /**
   This is the common code to stop EDK2 Redfish feature driver.
   This is the common code to stop EDK2 Redfish feature driver.
 
 
@@ -167,13 +172,13 @@ RedfishConfigCommonInit (
 EFI_STATUS
 EFI_STATUS
 RedfishConfigCommonStop (
 RedfishConfigCommonStop (
   VOID
   VOID
-)
+  )
 {
 {
-  EFI_STATUS   Status;
-  EFI_HANDLE  *HandleBuffer;
-  UINTN        NumberOfHandles;
-  UINTN        Index;
-  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *ConfigHandler;
+  EFI_STATUS                             Status;
+  EFI_HANDLE                             *HandleBuffer;
+  UINTN                                  NumberOfHandles;
+  UINTN                                  Index;
+  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  *ConfigHandler;
 
 
   Status = gBS->LocateHandleBuffer (
   Status = gBS->LocateHandleBuffer (
                   ByProtocol,
                   ByProtocol,
@@ -182,27 +187,29 @@ RedfishConfigCommonStop (
                   &NumberOfHandles,
                   &NumberOfHandles,
                   &HandleBuffer
                   &HandleBuffer
                   );
                   );
-  if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) {
+  if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
     return Status;
     return Status;
   }
   }
 
 
   Status = EFI_SUCCESS;
   Status = EFI_SUCCESS;
   for (Index = 0; Index < NumberOfHandles; Index++) {
   for (Index = 0; Index < NumberOfHandles; Index++) {
     Status = gBS->HandleProtocol (
     Status = gBS->HandleProtocol (
-                     HandleBuffer[Index],
-                     &gEdkIIRedfishConfigHandlerProtocolGuid,
-                     (VOID**) &ConfigHandler
-                     );
+                    HandleBuffer[Index],
+                    &gEdkIIRedfishConfigHandlerProtocolGuid,
+                    (VOID **)&ConfigHandler
+                    );
     ASSERT_EFI_ERROR (Status);
     ASSERT_EFI_ERROR (Status);
 
 
     Status = ConfigHandler->Stop (ConfigHandler);
     Status = ConfigHandler->Stop (ConfigHandler);
-    if (EFI_ERROR (Status) && Status != EFI_UNSUPPORTED) {
+    if (EFI_ERROR (Status) && (Status != EFI_UNSUPPORTED)) {
       DEBUG ((DEBUG_ERROR, "ERROR: Failed to stop Redfish config handler %p.\n", ConfigHandler));
       DEBUG ((DEBUG_ERROR, "ERROR: Failed to stop Redfish config handler %p.\n", ConfigHandler));
       break;
       break;
     }
     }
   }
   }
+
   return Status;
   return Status;
 }
 }
+
 /**
 /**
   Callback function executed when a Redfish Config Handler Protocol is installed
   Callback function executed when a Redfish Config Handler Protocol is installed
   by EDK2 Redfish Feature Drivers.
   by EDK2 Redfish Feature Drivers.
@@ -213,12 +220,12 @@ RedfishConfigHandlerInitialization (
   VOID
   VOID
   )
   )
 {
 {
-  EFI_STATUS                            Status;
-  EFI_HANDLE                            *HandleBuffer;
-  UINTN                                 NumberOfHandles;
-  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL *ConfigHandler;
-  UINTN                                 Index;
-  UINT32                                Id;
+  EFI_STATUS                             Status;
+  EFI_HANDLE                             *HandleBuffer;
+  UINTN                                  NumberOfHandles;
+  EDKII_REDFISH_CONFIG_HANDLER_PROTOCOL  *ConfigHandler;
+  UINTN                                  Index;
+  UINT32                                 Id;
 
 
   Status = gBS->LocateHandleBuffer (
   Status = gBS->LocateHandleBuffer (
                   ByProtocol,
                   ByProtocol,
@@ -233,33 +240,34 @@ RedfishConfigHandlerInitialization (
 
 
   for (Index = 0; Index < NumberOfHandles; Index++) {
   for (Index = 0; Index < NumberOfHandles; Index++) {
     Status = gBS->HandleProtocol (
     Status = gBS->HandleProtocol (
-                    HandleBuffer [Index],
+                    HandleBuffer[Index],
                     &gEfiCallerIdGuid,
                     &gEfiCallerIdGuid,
-                    (VOID **) &Id
+                    (VOID **)&Id
                     );
                     );
     if (!EFI_ERROR (Status)) {
     if (!EFI_ERROR (Status)) {
       continue;
       continue;
     }
     }
 
 
     Status = gBS->HandleProtocol (
     Status = gBS->HandleProtocol (
-                     HandleBuffer [Index],
-                     &gEdkIIRedfishConfigHandlerProtocolGuid,
-                     (VOID**) &ConfigHandler
-                     );
+                    HandleBuffer[Index],
+                    &gEdkIIRedfishConfigHandlerProtocolGuid,
+                    (VOID **)&ConfigHandler
+                    );
     ASSERT_EFI_ERROR (Status);
     ASSERT_EFI_ERROR (Status);
     Status = ConfigHandler->Init (ConfigHandler, &gRedfishConfigData.RedfishServiceInfo);
     Status = ConfigHandler->Init (ConfigHandler, &gRedfishConfigData.RedfishServiceInfo);
-    if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
+    if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
       DEBUG ((DEBUG_ERROR, "ERROR: Failed to init Redfish config handler %p.\n", ConfigHandler));
       DEBUG ((DEBUG_ERROR, "ERROR: Failed to init Redfish config handler %p.\n", ConfigHandler));
     }
     }
+
     //
     //
     // Install caller ID to indicate Redfish Configure Handler is initialized.
     // Install caller ID to indicate Redfish Configure Handler is initialized.
     //
     //
     Status = gBS->InstallProtocolInterface (
     Status = gBS->InstallProtocolInterface (
-                  &HandleBuffer [Index],
-                  &gEfiCallerIdGuid,
-                  EFI_NATIVE_INTERFACE,
-                  (VOID *)&gRedfishConfigData.CallerId
-                  );
+                    &HandleBuffer[Index],
+                    &gEfiCallerIdGuid,
+                    EFI_NATIVE_INTERFACE,
+                    (VOID *)&gRedfishConfigData.CallerId
+                    );
     ASSERT_EFI_ERROR (Status);
     ASSERT_EFI_ERROR (Status);
   }
   }
 }
 }

+ 6 - 6
RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerCommon.h

@@ -40,11 +40,11 @@
 ///  Internal structure used by Redfish Config DXE driver.
 ///  Internal structure used by Redfish Config DXE driver.
 ///
 ///
 typedef struct {
 typedef struct {
-  UINT32        CallerId;  ///< Caller ID used to indicate Redfish Config Handler
-                           ///< has been initiated
-  EFI_HANDLE    Image;     ///< Image handle of Redfish Config Driver
-  EFI_EVENT     Event;     ///< Event for the notification of EFI_REDFISH_CONFIG_HANDLER_PROTOCOL
-  REDFISH_CONFIG_SERVICE_INFORMATION RedfishServiceInfo; /// Redfish Service information discovered
+  UINT32                                CallerId;           ///< Caller ID used to indicate Redfish Config Handler
+                                                            ///< has been initiated
+  EFI_HANDLE                            Image;              ///< Image handle of Redfish Config Driver
+  EFI_EVENT                             Event;              ///< Event for the notification of EFI_REDFISH_CONFIG_HANDLER_PROTOCOL
+  REDFISH_CONFIG_SERVICE_INFORMATION    RedfishServiceInfo; /// Redfish Service information discovered
 } REDFISH_CONFIG_DRIVER_DATA;
 } REDFISH_CONFIG_DRIVER_DATA;
 
 
 /**
 /**
@@ -86,7 +86,7 @@ RedfishConfigCommonInit (
 EFI_STATUS
 EFI_STATUS
 RedfishConfigCommonStop (
 RedfishConfigCommonStop (
   VOID
   VOID
-);
+  );
 
 
 /**
 /**
   Callback function executed when a Redfish Config Handler Protocol is installed
   Callback function executed when a Redfish Config Handler Protocol is installed

+ 94 - 80
RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.c

@@ -17,22 +17,22 @@ EFI_EVENT  gEfiRedfishDiscoverProtocolEvent = NULL;
 //
 //
 // Variables for using RFI Redfish Discover Protocol
 // Variables for using RFI Redfish Discover Protocol
 //
 //
-VOID                             *gEfiRedfishDiscoverRegistration;
-EFI_HANDLE                       gEfiRedfishDiscoverControllerHandle = NULL;
-EFI_REDFISH_DISCOVER_PROTOCOL    *gEfiRedfishDiscoverProtocol = NULL;
-BOOLEAN                          gRedfishDiscoverActivated = FALSE;
-BOOLEAN                          gRedfishServiceDiscovered = FALSE;
+VOID                           *gEfiRedfishDiscoverRegistration;
+EFI_HANDLE                     gEfiRedfishDiscoverControllerHandle = NULL;
+EFI_REDFISH_DISCOVER_PROTOCOL  *gEfiRedfishDiscoverProtocol        = NULL;
+BOOLEAN                        gRedfishDiscoverActivated           = FALSE;
+BOOLEAN                        gRedfishServiceDiscovered           = FALSE;
 //
 //
 // Network interfaces discovered by EFI Redfish Discover Protocol.
 // Network interfaces discovered by EFI Redfish Discover Protocol.
 //
 //
 UINTN                                   gNumberOfNetworkInterfaces;
 UINTN                                   gNumberOfNetworkInterfaces;
 EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  *gNetworkInterfaceInstances = NULL;
 EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  *gNetworkInterfaceInstances = NULL;
-EFI_REDFISH_DISCOVERED_TOKEN            *gRedfishDiscoveredToken = NULL;
+EFI_REDFISH_DISCOVERED_TOKEN            *gRedfishDiscoveredToken    = NULL;
 
 
 ///
 ///
 /// Driver Binding Protocol instance
 /// Driver Binding Protocol instance
 ///
 ///
-EFI_DRIVER_BINDING_PROTOCOL gRedfishConfigDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL  gRedfishConfigDriverBinding = {
   RedfishConfigDriverBindingSupported,
   RedfishConfigDriverBindingSupported,
   RedfishConfigDriverBindingStart,
   RedfishConfigDriverBindingStart,
   RedfishConfigDriverBindingStop,
   RedfishConfigDriverBindingStop,
@@ -48,7 +48,7 @@ EFI_DRIVER_BINDING_PROTOCOL gRedfishConfigDriverBinding = {
 VOID
 VOID
 RedfishConfigStopRedfishDiscovery (
 RedfishConfigStopRedfishDiscovery (
   VOID
   VOID
-)
+  )
 {
 {
   if (gRedfishDiscoverActivated) {
   if (gRedfishDiscoverActivated) {
     //
     //
@@ -57,6 +57,7 @@ RedfishConfigStopRedfishDiscovery (
     if (gEfiRedfishDiscoverProtocolEvent != NULL) {
     if (gEfiRedfishDiscoverProtocolEvent != NULL) {
       gBS->CloseEvent (gEfiRedfishDiscoverProtocolEvent);
       gBS->CloseEvent (gEfiRedfishDiscoverProtocolEvent);
     }
     }
+
     //
     //
     // Stop Redfish service discovery.
     // Stop Redfish service discovery.
     //
     //
@@ -65,9 +66,9 @@ RedfishConfigStopRedfishDiscovery (
                                    gNetworkInterfaceInstances
                                    gNetworkInterfaceInstances
                                    );
                                    );
     gEfiRedfishDiscoverControllerHandle = NULL;
     gEfiRedfishDiscoverControllerHandle = NULL;
-    gEfiRedfishDiscoverProtocol = NULL;
-    gRedfishDiscoverActivated = FALSE;
-    gRedfishServiceDiscovered = FALSE;
+    gEfiRedfishDiscoverProtocol         = NULL;
+    gRedfishDiscoverActivated           = FALSE;
+    gRedfishServiceDiscovered           = FALSE;
   }
   }
 }
 }
 
 
@@ -138,9 +139,9 @@ RedfishConfigDriverBindingSupported (
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
   )
   )
 {
 {
-  EFI_REST_EX_PROTOCOL             *RestEx;
-  EFI_STATUS                       Status;
-  EFI_HANDLE                       ChildHandle;
+  EFI_REST_EX_PROTOCOL  *RestEx;
+  EFI_STATUS            Status;
+  EFI_HANDLE            ChildHandle;
 
 
   ChildHandle = NULL;
   ChildHandle = NULL;
 
 
@@ -161,10 +162,10 @@ RedfishConfigDriverBindingSupported (
   //
   //
   // Test if REST EX protocol is ready.
   // Test if REST EX protocol is ready.
   //
   //
-  Status = gBS->OpenProtocol(
+  Status = gBS->OpenProtocol (
                   ChildHandle,
                   ChildHandle,
                   &gEfiRestExProtocolGuid,
                   &gEfiRestExProtocolGuid,
-                  (VOID**) &RestEx,
+                  (VOID **)&RestEx,
                   This->DriverBindingHandle,
                   This->DriverBindingHandle,
                   ControllerHandle,
                   ControllerHandle,
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -172,6 +173,7 @@ RedfishConfigDriverBindingSupported (
   if (EFI_ERROR (Status)) {
   if (EFI_ERROR (Status)) {
     Status = EFI_UNSUPPORTED;
     Status = EFI_UNSUPPORTED;
   }
   }
+
   NetLibDestroyServiceChild (
   NetLibDestroyServiceChild (
     ControllerHandle,
     ControllerHandle,
     This->ImageHandle,
     This->ImageHandle,
@@ -222,19 +224,19 @@ RedfishConfigDriverBindingStart (
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
   )
   )
 {
 {
-  VOID *ConfigHandlerRegistration;
+  VOID  *ConfigHandlerRegistration;
 
 
   if (gRedfishConfigData.Event != NULL) {
   if (gRedfishConfigData.Event != NULL) {
     return EFI_ALREADY_STARTED;
     return EFI_ALREADY_STARTED;
   }
   }
 
 
   gRedfishConfigData.Event = EfiCreateProtocolNotifyEvent (
   gRedfishConfigData.Event = EfiCreateProtocolNotifyEvent (
-                                &gEdkIIRedfishConfigHandlerProtocolGuid,
-                                TPL_CALLBACK,
-                                RedfishConfigHandlerInstalledCallback,
-                                (VOID *)&gRedfishConfigData,
-                                &ConfigHandlerRegistration
-                                );
+                               &gEdkIIRedfishConfigHandlerProtocolGuid,
+                               TPL_CALLBACK,
+                               RedfishConfigHandlerInstalledCallback,
+                               (VOID *)&gRedfishConfigData,
+                               &ConfigHandlerRegistration
+                               );
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }
 
 
@@ -278,6 +280,7 @@ RedfishConfigDriverBindingStop (
   if (ControllerHandle == gEfiRedfishDiscoverControllerHandle) {
   if (ControllerHandle == gEfiRedfishDiscoverControllerHandle) {
     RedfishConfigStopRedfishDiscovery ();
     RedfishConfigStopRedfishDiscovery ();
   }
   }
+
   gBS->CloseProtocol (
   gBS->CloseProtocol (
          ControllerHandle,
          ControllerHandle,
          &gEfiRedfishDiscoverProtocolGuid,
          &gEfiRedfishDiscoverProtocolGuid,
@@ -294,6 +297,7 @@ RedfishConfigDriverBindingStop (
     gBS->CloseEvent (gRedfishConfigData.Event);
     gBS->CloseEvent (gRedfishConfigData.Event);
     gRedfishConfigData.Event = NULL;
     gRedfishConfigData.Event = NULL;
   }
   }
+
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }
 
 
@@ -311,8 +315,8 @@ RedfishServiceDiscoveredCallback (
   OUT VOID       *Context
   OUT VOID       *Context
   )
   )
 {
 {
-  EFI_REDFISH_DISCOVERED_TOKEN *RedfishDiscoveredToken;
-  EFI_REDFISH_DISCOVERED_INSTANCE *RedfishInstance;
+  EFI_REDFISH_DISCOVERED_TOKEN     *RedfishDiscoveredToken;
+  EFI_REDFISH_DISCOVERED_INSTANCE  *RedfishInstance;
 
 
   if (gRedfishServiceDiscovered) {
   if (gRedfishServiceDiscovered) {
     //
     //
@@ -322,7 +326,7 @@ RedfishServiceDiscoveredCallback (
   }
   }
 
 
   RedfishDiscoveredToken = (EFI_REDFISH_DISCOVERED_TOKEN *)Context;
   RedfishDiscoveredToken = (EFI_REDFISH_DISCOVERED_TOKEN *)Context;
-  RedfishInstance = RedfishDiscoveredToken->DiscoverList.RedfishInstances;
+  RedfishInstance        = RedfishDiscoveredToken->DiscoverList.RedfishInstances;
   //
   //
   // Only pick up the first found Redfish service.
   // Only pick up the first found Redfish service.
   //
   //
@@ -336,7 +340,7 @@ RedfishServiceDiscoveredCallback (
     gRedfishConfigData.RedfishServiceInfo.RedfishServiceProduct      = RedfishInstance->Information.Product;
     gRedfishConfigData.RedfishServiceInfo.RedfishServiceProduct      = RedfishInstance->Information.Product;
     gRedfishConfigData.RedfishServiceInfo.RedfishServiceProductVer   = RedfishInstance->Information.ProductVer;
     gRedfishConfigData.RedfishServiceInfo.RedfishServiceProductVer   = RedfishInstance->Information.ProductVer;
     gRedfishConfigData.RedfishServiceInfo.RedfishServiceUseHttps     = RedfishInstance->Information.UseHttps;
     gRedfishConfigData.RedfishServiceInfo.RedfishServiceUseHttps     = RedfishInstance->Information.UseHttps;
-    gRedfishServiceDiscovered = TRUE;
+    gRedfishServiceDiscovered                                        = TRUE;
   }
   }
 
 
   //
   //
@@ -361,76 +365,79 @@ RedfishDiscoverProtocolInstalled (
   OUT VOID       *Context
   OUT VOID       *Context
   )
   )
 {
 {
-  EFI_STATUS Status;
-  UINTN BufferSize;
-  EFI_HANDLE HandleBuffer;
-  UINTN NetworkInterfaceIndex;
-  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE *ThisNetworkInterface;
-  EFI_REDFISH_DISCOVERED_TOKEN           *ThisRedfishDiscoveredToken;
+  EFI_STATUS                              Status;
+  UINTN                                   BufferSize;
+  EFI_HANDLE                              HandleBuffer;
+  UINTN                                   NetworkInterfaceIndex;
+  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE  *ThisNetworkInterface;
+  EFI_REDFISH_DISCOVERED_TOKEN            *ThisRedfishDiscoveredToken;
 
 
-  DEBUG((DEBUG_INFO, "%a: New network interface is installed on system by EFI Redfish discover driver.\n", __FUNCTION__));
+  DEBUG ((DEBUG_INFO, "%a: New network interface is installed on system by EFI Redfish discover driver.\n", __FUNCTION__));
 
 
   BufferSize = sizeof (EFI_HANDLE);
   BufferSize = sizeof (EFI_HANDLE);
-  Status = gBS->LocateHandle (
-                  ByRegisterNotify,
-                  NULL,
-                  gEfiRedfishDiscoverRegistration,
-                  &BufferSize,
-                  &HandleBuffer
-                );
+  Status     = gBS->LocateHandle (
+                      ByRegisterNotify,
+                      NULL,
+                      gEfiRedfishDiscoverRegistration,
+                      &BufferSize,
+                      &HandleBuffer
+                      );
   if (EFI_ERROR (Status)) {
   if (EFI_ERROR (Status)) {
-    DEBUG((DEBUG_ERROR, "%a: Can't locate handle with EFI_REDFISH_DISCOVER_PROTOCOL installed.\n", __FUNCTION__));
+    DEBUG ((DEBUG_ERROR, "%a: Can't locate handle with EFI_REDFISH_DISCOVER_PROTOCOL installed.\n", __FUNCTION__));
   }
   }
+
   gRedfishDiscoverActivated = TRUE;
   gRedfishDiscoverActivated = TRUE;
   if (gEfiRedfishDiscoverProtocol == NULL) {
   if (gEfiRedfishDiscoverProtocol == NULL) {
-     gEfiRedfishDiscoverControllerHandle = HandleBuffer;
+    gEfiRedfishDiscoverControllerHandle = HandleBuffer;
     //
     //
     // First time to open EFI_REDFISH_DISCOVER_PROTOCOL.
     // First time to open EFI_REDFISH_DISCOVER_PROTOCOL.
     //
     //
-    Status = gBS->OpenProtocol(
-                      gEfiRedfishDiscoverControllerHandle,
-                      &gEfiRedfishDiscoverProtocolGuid,
-                      (VOID **)&gEfiRedfishDiscoverProtocol,
-                      gRedfishConfigData.Image,
-                      gRedfishConfigData.Image,
-                      EFI_OPEN_PROTOCOL_BY_DRIVER
+    Status = gBS->OpenProtocol (
+                    gEfiRedfishDiscoverControllerHandle,
+                    &gEfiRedfishDiscoverProtocolGuid,
+                    (VOID **)&gEfiRedfishDiscoverProtocol,
+                    gRedfishConfigData.Image,
+                    gRedfishConfigData.Image,
+                    EFI_OPEN_PROTOCOL_BY_DRIVER
                     );
                     );
     if (EFI_ERROR (Status)) {
     if (EFI_ERROR (Status)) {
       gEfiRedfishDiscoverProtocol = NULL;
       gEfiRedfishDiscoverProtocol = NULL;
-      gRedfishDiscoverActivated = FALSE;
-      DEBUG((DEBUG_ERROR, "%a: Can't locate EFI_REDFISH_DISCOVER_PROTOCOL.\n", __FUNCTION__));
+      gRedfishDiscoverActivated   = FALSE;
+      DEBUG ((DEBUG_ERROR, "%a: Can't locate EFI_REDFISH_DISCOVER_PROTOCOL.\n", __FUNCTION__));
       return;
       return;
     }
     }
   }
   }
+
   //
   //
   // Check the new found network interface.
   // Check the new found network interface.
   //
   //
   if (gNetworkInterfaceInstances != NULL) {
   if (gNetworkInterfaceInstances != NULL) {
     FreePool (gNetworkInterfaceInstances);
     FreePool (gNetworkInterfaceInstances);
   }
   }
-  Status = gEfiRedfishDiscoverProtocol->GetNetworkInterfaceList(
+
+  Status = gEfiRedfishDiscoverProtocol->GetNetworkInterfaceList (
                                           gEfiRedfishDiscoverProtocol,
                                           gEfiRedfishDiscoverProtocol,
                                           gRedfishConfigData.Image,
                                           gRedfishConfigData.Image,
                                           &gNumberOfNetworkInterfaces,
                                           &gNumberOfNetworkInterfaces,
                                           &gNetworkInterfaceInstances
                                           &gNetworkInterfaceInstances
                                           );
                                           );
-  if (EFI_ERROR (Status) || gNumberOfNetworkInterfaces == 0) {
-    DEBUG((DEBUG_ERROR, "%a: No network interfaces found on the handle.\n", __FUNCTION__));
+  if (EFI_ERROR (Status) || (gNumberOfNetworkInterfaces == 0)) {
+    DEBUG ((DEBUG_ERROR, "%a: No network interfaces found on the handle.\n", __FUNCTION__));
     return;
     return;
   }
   }
 
 
   gRedfishDiscoveredToken = AllocateZeroPool (gNumberOfNetworkInterfaces * sizeof (EFI_REDFISH_DISCOVERED_TOKEN));
   gRedfishDiscoveredToken = AllocateZeroPool (gNumberOfNetworkInterfaces * sizeof (EFI_REDFISH_DISCOVERED_TOKEN));
   if (gRedfishDiscoveredToken == NULL) {
   if (gRedfishDiscoveredToken == NULL) {
-    DEBUG((DEBUG_ERROR, "%a: Not enough memory for EFI_REDFISH_DISCOVERED_TOKEN.\n", __FUNCTION__));
+    DEBUG ((DEBUG_ERROR, "%a: Not enough memory for EFI_REDFISH_DISCOVERED_TOKEN.\n", __FUNCTION__));
     return;
     return;
   }
   }
 
 
-  ThisNetworkInterface = gNetworkInterfaceInstances;
+  ThisNetworkInterface       = gNetworkInterfaceInstances;
   ThisRedfishDiscoveredToken = gRedfishDiscoveredToken;
   ThisRedfishDiscoveredToken = gRedfishDiscoveredToken;
   //
   //
   // Loop to discover Redfish service on each network interface.
   // Loop to discover Redfish service on each network interface.
   //
   //
-  for (NetworkInterfaceIndex = 0; NetworkInterfaceIndex < gNumberOfNetworkInterfaces; NetworkInterfaceIndex ++) {
+  for (NetworkInterfaceIndex = 0; NetworkInterfaceIndex < gNumberOfNetworkInterfaces; NetworkInterfaceIndex++) {
     //
     //
     // Initial this Redfish Discovered Token
     // Initial this Redfish Discovered Token
     //
     //
@@ -440,37 +447,40 @@ RedfishDiscoverProtocolInstalled (
                     RedfishServiceDiscoveredCallback,
                     RedfishServiceDiscoveredCallback,
                     (VOID *)ThisRedfishDiscoveredToken,
                     (VOID *)ThisRedfishDiscoveredToken,
                     &ThisRedfishDiscoveredToken->Event
                     &ThisRedfishDiscoveredToken->Event
-                  );
+                    );
     if (EFI_ERROR (Status)) {
     if (EFI_ERROR (Status)) {
-      DEBUG((DEBUG_ERROR, "%a: Failed to create event for Redfish discovered token.\n", __FUNCTION__));
+      DEBUG ((DEBUG_ERROR, "%a: Failed to create event for Redfish discovered token.\n", __FUNCTION__));
       goto ErrorReturn;
       goto ErrorReturn;
     }
     }
-    ThisRedfishDiscoveredToken->Signature = REDFISH_DISCOVER_TOKEN_SIGNATURE;
+
+    ThisRedfishDiscoveredToken->Signature                         = REDFISH_DISCOVER_TOKEN_SIGNATURE;
     ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound = 0;
     ThisRedfishDiscoveredToken->DiscoverList.NumberOfServiceFound = 0;
-    ThisRedfishDiscoveredToken->DiscoverList.RedfishInstances = NULL;
+    ThisRedfishDiscoveredToken->DiscoverList.RedfishInstances     = NULL;
     //
     //
     // Acquire for Redfish service which is reported by
     // Acquire for Redfish service which is reported by
     // Redfish Host Interface.
     // Redfish Host Interface.
     //
     //
-    Status = gEfiRedfishDiscoverProtocol->AcquireRedfishService(
-                                             gEfiRedfishDiscoverProtocol,
-                                             gRedfishConfigData.Image,
-                                             ThisNetworkInterface,
-                                             EFI_REDFISH_DISCOVER_HOST_INTERFACE,
-                                             ThisRedfishDiscoveredToken
-                                             );
-    ThisNetworkInterface ++;
-    ThisRedfishDiscoveredToken ++;
+    Status = gEfiRedfishDiscoverProtocol->AcquireRedfishService (
+                                            gEfiRedfishDiscoverProtocol,
+                                            gRedfishConfigData.Image,
+                                            ThisNetworkInterface,
+                                            EFI_REDFISH_DISCOVER_HOST_INTERFACE,
+                                            ThisRedfishDiscoveredToken
+                                            );
+    ThisNetworkInterface++;
+    ThisRedfishDiscoveredToken++;
   }
   }
+
   if (EFI_ERROR (Status)) {
   if (EFI_ERROR (Status)) {
-    DEBUG((DEBUG_ERROR, "%a: Acquire Redfish service fail.\n", __FUNCTION__));
+    DEBUG ((DEBUG_ERROR, "%a: Acquire Redfish service fail.\n", __FUNCTION__));
     goto ErrorReturn;
     goto ErrorReturn;
   }
   }
+
   return;
   return;
 
 
 ErrorReturn:
 ErrorReturn:
   if (gRedfishDiscoveredToken != NULL) {
   if (gRedfishDiscoveredToken != NULL) {
-    FreePool(gRedfishDiscoveredToken);
+    FreePool (gRedfishDiscoveredToken);
   }
   }
 }
 }
 
 
@@ -488,23 +498,26 @@ RedfishConfigHandlerDriverUnload (
   IN EFI_HANDLE  ImageHandle
   IN EFI_HANDLE  ImageHandle
   )
   )
 {
 {
-  EFI_REDFISH_DISCOVERED_TOKEN *ThisRedfishDiscoveredToken;
-  UINTN NumberOfNetworkInterfacesIndex;
+  EFI_REDFISH_DISCOVERED_TOKEN  *ThisRedfishDiscoveredToken;
+  UINTN                         NumberOfNetworkInterfacesIndex;
 
 
   RedfishConfigDriverCommonUnload (ImageHandle);
   RedfishConfigDriverCommonUnload (ImageHandle);
 
 
   RedfishConfigStopRedfishDiscovery ();
   RedfishConfigStopRedfishDiscovery ();
   if (gRedfishDiscoveredToken != NULL) {
   if (gRedfishDiscoveredToken != NULL) {
     ThisRedfishDiscoveredToken = gRedfishDiscoveredToken;
     ThisRedfishDiscoveredToken = gRedfishDiscoveredToken;
-    for (NumberOfNetworkInterfacesIndex = 0; NumberOfNetworkInterfacesIndex < gNumberOfNetworkInterfaces; NumberOfNetworkInterfacesIndex ++) {
+    for (NumberOfNetworkInterfacesIndex = 0; NumberOfNetworkInterfacesIndex < gNumberOfNetworkInterfaces; NumberOfNetworkInterfacesIndex++) {
       if (ThisRedfishDiscoveredToken->Event != NULL) {
       if (ThisRedfishDiscoveredToken->Event != NULL) {
         gBS->CloseEvent (ThisRedfishDiscoveredToken->Event);
         gBS->CloseEvent (ThisRedfishDiscoveredToken->Event);
       }
       }
+
       FreePool (ThisRedfishDiscoveredToken);
       FreePool (ThisRedfishDiscoveredToken);
-      ThisRedfishDiscoveredToken ++;
+      ThisRedfishDiscoveredToken++;
     }
     }
+
     gRedfishDiscoveredToken = NULL;
     gRedfishDiscoveredToken = NULL;
   }
   }
+
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }
 
 
@@ -526,7 +539,7 @@ RedfishConfigHandlerDriverEntryPoint (
   IN EFI_SYSTEM_TABLE  *SystemTable
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
   )
 {
 {
-  EFI_STATUS    Status;
+  EFI_STATUS  Status;
 
 
   ZeroMem ((VOID *)&gRedfishConfigData, sizeof (REDFISH_CONFIG_DRIVER_DATA));
   ZeroMem ((VOID *)&gRedfishConfigData, sizeof (REDFISH_CONFIG_DRIVER_DATA));
   gRedfishConfigData.Image = ImageHandle;
   gRedfishConfigData.Image = ImageHandle;
@@ -546,11 +559,12 @@ RedfishConfigHandlerDriverEntryPoint (
     DEBUG ((DEBUG_ERROR, "%a: Fail to create event for the installation of EFI_REDFISH_DISCOVER_PROTOCOL.", __FUNCTION__));
     DEBUG ((DEBUG_ERROR, "%a: Fail to create event for the installation of EFI_REDFISH_DISCOVER_PROTOCOL.", __FUNCTION__));
     return Status;
     return Status;
   }
   }
+
   Status = gBS->RegisterProtocolNotify (
   Status = gBS->RegisterProtocolNotify (
                   &gEfiRedfishDiscoverProtocolGuid,
                   &gEfiRedfishDiscoverProtocolGuid,
                   gEfiRedfishDiscoverProtocolEvent,
                   gEfiRedfishDiscoverProtocolEvent,
                   &gEfiRedfishDiscoverRegistration
                   &gEfiRedfishDiscoverRegistration
-                );
+                  );
   if (EFI_ERROR (Status)) {
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_ERROR, "%a: Fail to register event for the installation of EFI_REDFISH_DISCOVER_PROTOCOL.", __FUNCTION__));
     DEBUG ((DEBUG_ERROR, "%a: Fail to register event for the installation of EFI_REDFISH_DISCOVER_PROTOCOL.", __FUNCTION__));
     return Status;
     return Status;
@@ -582,6 +596,6 @@ RedfishConfigHandlerDriverEntryPoint (
     DEBUG ((DEBUG_ERROR, "%a: Fail to install EFI Binding Protocol of EFI Redfish Config driver.", __FUNCTION__));
     DEBUG ((DEBUG_ERROR, "%a: Fail to install EFI Binding Protocol of EFI Redfish Config driver.", __FUNCTION__));
     return Status;
     return Status;
   }
   }
+
   return Status;
   return Status;
 }
 }
-

+ 9 - 8
RedfishPkg/RedfishConfigHandler/RedfishConfigHandlerDriver.h

@@ -26,10 +26,10 @@
 //
 //
 extern EFI_DRIVER_BINDING_PROTOCOL  gRedfishConfigDriverBinding;
 extern EFI_DRIVER_BINDING_PROTOCOL  gRedfishConfigDriverBinding;
 
 
-extern REDFISH_CONFIG_DRIVER_DATA        gRedfishConfigData;
-extern EDKII_REDFISH_CREDENTIAL_PROTOCOL *gCredential;
-extern EFI_EVENT                         gEndOfDxeEvent;
-extern EFI_EVENT                         gExitBootServiceEvent;
+extern REDFISH_CONFIG_DRIVER_DATA         gRedfishConfigData;
+extern EDKII_REDFISH_CREDENTIAL_PROTOCOL  *gCredential;
+extern EFI_EVENT                          gEndOfDxeEvent;
+extern EFI_EVENT                          gExitBootServiceEvent;
 
 
 /**
 /**
   Tests to see if this driver supports a given controller. If a child device is provided,
   Tests to see if this driver supports a given controller. If a child device is provided,
@@ -151,9 +151,10 @@ RedfishConfigDriverBindingStart (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishConfigDriverBindingStop (
 RedfishConfigDriverBindingStop (
-  IN  EFI_DRIVER_BINDING_PROTOCOL *This,
-  IN  EFI_HANDLE                  ControllerHandle,
-  IN  UINTN                       NumberOfChildren,
-  IN  EFI_HANDLE                  *ChildHandleBuffer OPTIONAL
+  IN  EFI_DRIVER_BINDING_PROTOCOL  *This,
+  IN  EFI_HANDLE                   ControllerHandle,
+  IN  UINTN                        NumberOfChildren,
+  IN  EFI_HANDLE                   *ChildHandleBuffer OPTIONAL
   );
   );
+
 #endif
 #endif

+ 11 - 11
RedfishPkg/RedfishCredentialDxe/RedfishCredentialDxe.c

@@ -10,7 +10,7 @@
 
 
 #include <RedfishCredentialDxe.h>
 #include <RedfishCredentialDxe.h>
 
 
-EDKII_REDFISH_CREDENTIAL_PROTOCOL mRedfishCredentialProtocol = {
+EDKII_REDFISH_CREDENTIAL_PROTOCOL  mRedfishCredentialProtocol = {
   RedfishCredentialGetAuthInfo,
   RedfishCredentialGetAuthInfo,
   RedfishCredentialStopService
   RedfishCredentialStopService
 };
 };
@@ -79,17 +79,17 @@ RedfishCredentialEndOfDxeEventNotify (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishCredentialGetAuthInfo (
 RedfishCredentialGetAuthInfo (
-  IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL    *This,
-  OUT EDKII_REDFISH_AUTH_METHOD            *AuthMethod,
-  OUT CHAR8                                **UserId,
-  OUT CHAR8                                **Password
+  IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This,
+  OUT EDKII_REDFISH_AUTH_METHOD          *AuthMethod,
+  OUT CHAR8                              **UserId,
+  OUT CHAR8                              **Password
   )
   )
 {
 {
-  if (This == NULL || AuthMethod == NULL || UserId == NULL || Password == NULL) {
+  if ((This == NULL) || (AuthMethod == NULL) || (UserId == NULL) || (Password == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
-  return LibCredentialGetAuthInfo (This, AuthMethod, UserId,Password);
+  return LibCredentialGetAuthInfo (This, AuthMethod, UserId, Password);
 }
 }
 
 
 /**
 /**
@@ -112,8 +112,8 @@ RedfishCredentialGetAuthInfo (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishCredentialStopService (
 RedfishCredentialStopService (
-  IN     EDKII_REDFISH_CREDENTIAL_PROTOCOL    *This,
-  IN     EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
+  IN     EDKII_REDFISH_CREDENTIAL_PROTOCOL           *This,
+  IN     EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE  ServiceStopType
   )
   )
 {
 {
   if (This == NULL) {
   if (This == NULL) {
@@ -135,8 +135,8 @@ RedfishCredentialStopService (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishCredentialDxeDriverEntryPoint (
 RedfishCredentialDxeDriverEntryPoint (
-  IN EFI_HANDLE         ImageHandle,
-  IN EFI_SYSTEM_TABLE   *SystemTable
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
   )
   )
 {
 {
   EFI_STATUS  Status;
   EFI_STATUS  Status;

+ 8 - 6
RedfishPkg/RedfishCredentialDxe/RedfishCredentialDxe.h

@@ -6,6 +6,7 @@
   SPDX-License-Identifier: BSD-2-Clause-Patent
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 
 **/
 **/
+
 #ifndef EDKII_REDFISH_CREDENTIAL_DXE_H_
 #ifndef EDKII_REDFISH_CREDENTIAL_DXE_H_
 #define EDKII_REDFISH_CREDENTIAL_DXE_H_
 #define EDKII_REDFISH_CREDENTIAL_DXE_H_
 
 
@@ -45,10 +46,10 @@
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishCredentialGetAuthInfo (
 RedfishCredentialGetAuthInfo (
-  IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL    *This,
-  OUT EDKII_REDFISH_AUTH_METHOD            *AuthMethod,
-  OUT CHAR8                                **UserId,
-  OUT CHAR8                                **Password
+  IN  EDKII_REDFISH_CREDENTIAL_PROTOCOL  *This,
+  OUT EDKII_REDFISH_AUTH_METHOD          *AuthMethod,
+  OUT CHAR8                              **UserId,
+  OUT CHAR8                              **Password
   );
   );
 
 
 /**
 /**
@@ -69,7 +70,8 @@ RedfishCredentialGetAuthInfo (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishCredentialStopService (
 RedfishCredentialStopService (
-  IN     EDKII_REDFISH_CREDENTIAL_PROTOCOL    *This,
-  IN     EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE ServiceStopType
+  IN     EDKII_REDFISH_CREDENTIAL_PROTOCOL           *This,
+  IN     EDKII_REDFISH_CREDENTIAL_STOP_SERVICE_TYPE  ServiceStopType
   );
   );
+
 #endif
 #endif

+ 14 - 14
RedfishPkg/RedfishDiscoverDxe/ComponentName.c

@@ -13,6 +13,7 @@
 //
 //
 // EFI Component Name Functions
 // EFI Component Name Functions
 //
 //
+
 /**
 /**
   Retrieves a Unicode string that is the user-readable name of the EFI Driver.
   Retrieves a Unicode string that is the user-readable name of the EFI Driver.
 
 
@@ -87,13 +88,12 @@ EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishDiscoverComponentNameGetControllerName (
 RedfishDiscoverComponentNameGetControllerName (
   IN  EFI_COMPONENT_NAME_PROTOCOL  *This,
   IN  EFI_COMPONENT_NAME_PROTOCOL  *This,
-  IN  EFI_HANDLE                    ControllerHandle,
-  IN  EFI_HANDLE                    ChildHandle        OPTIONAL,
-  IN  CHAR8                         *Language,
-  OUT CHAR16                        **ControllerName
+  IN  EFI_HANDLE                   ControllerHandle,
+  IN  EFI_HANDLE                   ChildHandle        OPTIONAL,
+  IN  CHAR8                        *Language,
+  OUT CHAR16                       **ControllerName
   );
   );
 
 
-
 ///
 ///
 /// Component Name Protocol instance
 /// Component Name Protocol instance
 ///
 ///
@@ -109,8 +109,8 @@ EFI_COMPONENT_NAME_PROTOCOL  gRedfishDiscoverComponentName = {
 ///
 ///
 GLOBAL_REMOVE_IF_UNREFERENCED
 GLOBAL_REMOVE_IF_UNREFERENCED
 EFI_COMPONENT_NAME2_PROTOCOL  gRedfishDiscoverComponentName2 = {
 EFI_COMPONENT_NAME2_PROTOCOL  gRedfishDiscoverComponentName2 = {
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)     RedfishDiscoverComponentNameGetDriverName,
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) RedfishDiscoverComponentNameGetControllerName,
+  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)RedfishDiscoverComponentNameGetDriverName,
+  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)RedfishDiscoverComponentNameGetControllerName,
   "en"
   "en"
 };
 };
 
 
@@ -118,12 +118,12 @@ EFI_COMPONENT_NAME2_PROTOCOL  gRedfishDiscoverComponentName2 = {
 /// Table of driver names
 /// Table of driver names
 ///
 ///
 GLOBAL_REMOVE_IF_UNREFERENCED
 GLOBAL_REMOVE_IF_UNREFERENCED
-EFI_UNICODE_STRING_TABLE mRedfishDiscoverDriverNameTable[] = {
+EFI_UNICODE_STRING_TABLE  mRedfishDiscoverDriverNameTable[] = {
   { "eng;en", (CHAR16 *)L"Redfish Discover UEFI Driver" },
   { "eng;en", (CHAR16 *)L"Redfish Discover UEFI Driver" },
-  { NULL, NULL }
+  { NULL,     NULL                                      }
 };
 };
 
 
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gRedfishDiscoverControllerNameTable = NULL;
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE  *gRedfishDiscoverControllerNameTable = NULL;
 
 
 /**
 /**
   Retrieves a Unicode string that is the user-readable name of the EFI Driver.
   Retrieves a Unicode string that is the user-readable name of the EFI Driver.
@@ -208,10 +208,10 @@ EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishDiscoverComponentNameGetControllerName (
 RedfishDiscoverComponentNameGetControllerName (
   IN  EFI_COMPONENT_NAME_PROTOCOL  *This,
   IN  EFI_COMPONENT_NAME_PROTOCOL  *This,
-  IN  EFI_HANDLE                    ControllerHandle,
-  IN  EFI_HANDLE                    ChildHandle        OPTIONAL,
-  IN  CHAR8                         *Language,
-  OUT CHAR16                        **ControllerName
+  IN  EFI_HANDLE                   ControllerHandle,
+  IN  EFI_HANDLE                   ChildHandle        OPTIONAL,
+  IN  CHAR8                        *Language,
+  OUT CHAR16                       **ControllerName
   )
   )
 {
 {
   return EFI_UNSUPPORTED;
   return EFI_UNSUPPORTED;

File diff suppressed because it is too large
+ 332 - 265
RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverDxe.c


+ 67 - 67
RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h

@@ -33,11 +33,11 @@
 
 
 #include <IndustryStandard/RedfishHostInterface.h>
 #include <IndustryStandard/RedfishHostInterface.h>
 
 
-#define REDFISH_DISCOVER_VERSION  0x00010000
-#define EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL TPL_NOTIFY
+#define REDFISH_DISCOVER_VERSION                    0x00010000
+#define EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_TPL  TPL_NOTIFY
 
 
 //
 //
-//GUID definitions
+// GUID definitions
 //
 //
 
 
 #define EFI_REDFISH_DISCOVER_TCP4_INSTANCE_GUID \
 #define EFI_REDFISH_DISCOVER_TCP4_INSTANCE_GUID \
@@ -75,11 +75,11 @@ typedef enum {
 // the network interface.
 // the network interface.
 //
 //
 typedef struct {
 typedef struct {
-  EFI_GUID ProtocolGuid;                ///< Network protocol GUID.
-  EFI_GUID ProtocolServiceGuid;         ///< Network protocol service GUID.
-  UINT32   ProtocolDiscoverId;          ///< The identifier installed on network protocol handle.
-  EFI_HANDLE ProtocolControllerHandle;  ///< The controller handle on network protocol.
-  VOID *NetworkProtocolInterface;       ///< The protocol interface of network protocol.
+  EFI_GUID      ProtocolGuid;              ///< Network protocol GUID.
+  EFI_GUID      ProtocolServiceGuid;       ///< Network protocol service GUID.
+  UINT32        ProtocolDiscoverId;        ///< The identifier installed on network protocol handle.
+  EFI_HANDLE    ProtocolControllerHandle;  ///< The controller handle on network protocol.
+  VOID          *NetworkProtocolInterface; ///< The protocol interface of network protocol.
 } REDFISH_DISCOVER_NETWORK_INTERFACE_PROTOCOL;
 } REDFISH_DISCOVER_NETWORK_INTERFACE_PROTOCOL;
 
 
 //
 //
@@ -87,39 +87,39 @@ typedef struct {
 // interface properties.
 // interface properties.
 //
 //
 typedef struct {
 typedef struct {
-  LIST_ENTRY      Entry;                        ///< Link list entry.
-  EFI_HANDLE      OpenDriverAgentHandle;        ///< The agent to open network protocol.
-  EFI_HANDLE      OpenDriverControllerHandle;   ///< The controller handle to open network protocol.
-  UINTN           HwAddressSize;                ///< The size of network interface hardware address.
-  EFI_MAC_ADDRESS MacAddress;                   ///< MAC address of network interface.
-  CHAR16          *StrMacAddr;                  ///< String to MAC address of network interface.
-  BOOLEAN         GotSubnetInfo;                ///< Indicates sub net information is retrieved.
-  EFI_IP_ADDRESS  SubnetAddr;                   ///< Subnet ID.
-  EFI_IP_ADDRESS  SubnetMask;                   ///< Subnet mask (IPv4 only)
-  UINT8           SubnetPrefixLength;           ///< Subnet prefix.
-  UINT16          VlanId;                       ///< VLAN ID
-  UINT32          SubnetAddrInfoIPv6Number;     ///< IPv6 address info number.
-  EFI_IP6_ADDRESS_INFO *SubnetAddrInfoIPv6;     ///< IPv6 address info.
+  LIST_ENTRY                                     Entry;                      ///< Link list entry.
+  EFI_HANDLE                                     OpenDriverAgentHandle;      ///< The agent to open network protocol.
+  EFI_HANDLE                                     OpenDriverControllerHandle; ///< The controller handle to open network protocol.
+  UINTN                                          HwAddressSize;              ///< The size of network interface hardware address.
+  EFI_MAC_ADDRESS                                MacAddress;                 ///< MAC address of network interface.
+  CHAR16                                         *StrMacAddr;                ///< String to MAC address of network interface.
+  BOOLEAN                                        GotSubnetInfo;              ///< Indicates sub net information is retrieved.
+  EFI_IP_ADDRESS                                 SubnetAddr;                 ///< Subnet ID.
+  EFI_IP_ADDRESS                                 SubnetMask;                 ///< Subnet mask (IPv4 only)
+  UINT8                                          SubnetPrefixLength;         ///< Subnet prefix.
+  UINT16                                         VlanId;                     ///< VLAN ID
+  UINT32                                         SubnetAddrInfoIPv6Number;   ///< IPv6 address info number.
+  EFI_IP6_ADDRESS_INFO                           *SubnetAddrInfoIPv6;        ///< IPv6 address info.
   //
   //
   // Network interface protocol and REST EX infor.
   // Network interface protocol and REST EX infor.
   //
   //
-  UINT32          NetworkProtocolType;          ///< Network protocol type. Refer to
-                                                ///< NETWORK_INTERFACE_PROTOCOL_TYPE.
-  REDFISH_DISCOVER_NETWORK_INTERFACE_PROTOCOL NetworkInterfaceProtocolInfo; ///< Network interface protocol information.
-  EFI_HANDLE      RestExHandle;                 ///< REST EX handle associated with this network interface.
+  UINT32                                         NetworkProtocolType;          ///< Network protocol type. Refer to
+                                                                               ///< NETWORK_INTERFACE_PROTOCOL_TYPE.
+  REDFISH_DISCOVER_NETWORK_INTERFACE_PROTOCOL    NetworkInterfaceProtocolInfo; ///< Network interface protocol information.
+  EFI_HANDLE                                     RestExHandle;                 ///< REST EX handle associated with this network interface.
 } EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL;
 } EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL;
 
 
 //
 //
 // Internal structure used to maintain REST EX properties.
 // Internal structure used to maintain REST EX properties.
 //
 //
 typedef struct {
 typedef struct {
-    LIST_ENTRY      Entry;                          ///< Link list entry.
-    EFI_HANDLE      OpenDriverAgentHandle;          ///< The agent to open network protocol.
-    EFI_HANDLE      OpenDriverControllerHandle;     ///< The controller handle to open network protocol.
-    EFI_HANDLE      RestExChildHandle;              ///< The child handle created throught REST EX Service Protocol.
-    EFI_HANDLE      RestExControllerHandle;         ///< The controller handle which provide REST EX protocol.
-    EFI_REST_EX_PROTOCOL *RestExProtocolInterface;  ///< Pointer to EFI_REST_EX_PROTOCOL.
-    UINT32          RestExId;                       ///< The identifier installed on REST EX controller handle.
+  LIST_ENTRY              Entry;                      ///< Link list entry.
+  EFI_HANDLE              OpenDriverAgentHandle;      ///< The agent to open network protocol.
+  EFI_HANDLE              OpenDriverControllerHandle; ///< The controller handle to open network protocol.
+  EFI_HANDLE              RestExChildHandle;          ///< The child handle created throught REST EX Service Protocol.
+  EFI_HANDLE              RestExControllerHandle;     ///< The controller handle which provide REST EX protocol.
+  EFI_REST_EX_PROTOCOL    *RestExProtocolInterface;   ///< Pointer to EFI_REST_EX_PROTOCOL.
+  UINT32                  RestExId;                   ///< The identifier installed on REST EX controller handle.
 } EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL;
 } EFI_REDFISH_DISCOVER_REST_EX_INSTANCE_INTERNAL;
 
 
 /**
 /**
@@ -135,46 +135,46 @@ EFI_STATUS
 (EFIAPI *EFI_REDFISH_DISCOVER_GET_SUBNET_INFO)(
 (EFIAPI *EFI_REDFISH_DISCOVER_GET_SUBNET_INFO)(
   IN EFI_HANDLE ImageHandle,
   IN EFI_HANDLE ImageHandle,
   IN EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *Instance
   IN EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *Instance
-);
+  );
 
 
 //
 //
 // The require network protocol matrix.
 // The require network protocol matrix.
 //
 //
 typedef struct {
 typedef struct {
-  UINT32   ProtocolType;                                ///< Network protocol type,
-                                                        ///< Refer to NETWORK_INTERFACE_PROTOCOL_TYPE.
-  CHAR16   *ProtocolName;                               ///< Protocol name.
-  EFI_GUID *RequiredProtocolGuid;                       ///< Network protocol interface GUID.
-  EFI_GUID *RequiredServiceBindingProtocolGuid;         ///< Network protocol service GUID.
-  EFI_GUID *DiscoveredProtocolGuid;                     ///< Protocol interface GUID use to install identifier.
-  EFI_REDFISH_DISCOVER_GET_SUBNET_INFO GetSubnetInfo;   ///< Function of getting subnet information.
+  UINT32                                  ProtocolType;                        ///< Network protocol type,
+                                                                               ///< Refer to NETWORK_INTERFACE_PROTOCOL_TYPE.
+  CHAR16                                  *ProtocolName;                       ///< Protocol name.
+  EFI_GUID                                *RequiredProtocolGuid;               ///< Network protocol interface GUID.
+  EFI_GUID                                *RequiredServiceBindingProtocolGuid; ///< Network protocol service GUID.
+  EFI_GUID                                *DiscoveredProtocolGuid;             ///< Protocol interface GUID use to install identifier.
+  EFI_REDFISH_DISCOVER_GET_SUBNET_INFO    GetSubnetInfo;                       ///< Function of getting subnet information.
 } REDFISH_DISCOVER_REQUIRED_PROTOCOL;
 } REDFISH_DISCOVER_REQUIRED_PROTOCOL;
 
 
 //
 //
 // Link list of Redfish discover instance.
 // Link list of Redfish discover instance.
 //
 //
 typedef struct {
 typedef struct {
-  LIST_ENTRY  NextInstance;                             ///< Next list.
-  EFI_REDFISH_DISCOVERED_INSTANCE *Instance;            ///< Pointer to EFI_REDFISH_DISCOVERED_INSTANCE.
+  LIST_ENTRY                         NextInstance;      ///< Next list.
+  EFI_REDFISH_DISCOVERED_INSTANCE    *Instance;         ///< Pointer to EFI_REDFISH_DISCOVERED_INSTANCE.
 } EFI_REDFISH_DISCOVERED_INTERNAL_LIST;
 } EFI_REDFISH_DISCOVERED_INTERNAL_LIST;
 
 
 //
 //
 // Internal structure of Redfish discover instance.
 // Internal structure of Redfish discover instance.
 //
 //
 typedef struct {
 typedef struct {
-  LIST_ENTRY  Entry;                                    ///< Link list entry.
-  EFI_HANDLE  Owner;                                    ///< The owner owns this Redfish service discovery.
-                                                        ///< It's the EFI image handle of driver uses
-                                                        ///< EFI Redfish Discover Protocol.
-  EFI_REDFISH_DISCOVER_FLAG DiscoverFlags;              ///< EFI_REDFISH_DISCOVER_FLAG
-  EFI_REDFISH_DISCOVERED_TOKEN *DiscoverToken;          ///< Token used to signal when Redfish service is discovered.
-  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL *NetworkInterface; ///< EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL
-                                                                     ///< instance used to discover Redfish service.
+  LIST_ENTRY                                         Entry;             ///< Link list entry.
+  EFI_HANDLE                                         Owner;             ///< The owner owns this Redfish service discovery.
+                                                                        ///< It's the EFI image handle of driver uses
+                                                                        ///< EFI Redfish Discover Protocol.
+  EFI_REDFISH_DISCOVER_FLAG                          DiscoverFlags;     ///< EFI_REDFISH_DISCOVER_FLAG
+  EFI_REDFISH_DISCOVERED_TOKEN                       *DiscoverToken;    ///< Token used to signal when Redfish service is discovered.
+  EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL    *NetworkInterface; ///< EFI_REDFISH_DISCOVER_NETWORK_INTERFACE_INTERNAL
+                                                                        ///< instance used to discover Redfish service.
   //
   //
   // Below for Host insterface discovery.
   // Below for Host insterface discovery.
   //
   //
-  BOOLEAN         HostIntfValidation;                   ///< Indicates whether to validate Redfish Host interface.
-  EFI_IP_ADDRESS  TargetIpAddress;                      ///< Target IP address reported in Redfish Host interface.
+  BOOLEAN                                            HostIntfValidation; ///< Indicates whether to validate Redfish Host interface.
+  EFI_IP_ADDRESS                                     TargetIpAddress;    ///< Target IP address reported in Redfish Host interface.
 } EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE;
 } EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE;
 
 
 /**
 /**
@@ -197,15 +197,15 @@ typedef struct {
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 AddAndSignalNewRedfishService (
 AddAndSignalNewRedfishService (
-  IN EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE *Instance,
-  IN UINTN *RedfishVersion OPTIONAL,
-  IN CHAR8 *RedfishLocation OPTIONAL,
-  IN CHAR8 *Uuid  OPTIONAL,
-  IN CHAR8 *Os  OPTIONAL,
-  IN CHAR8 *OsVer  OPTIONAL,
-  IN CHAR8 *Product  OPTIONAL,
-  IN CHAR8 *ProductVer  OPTIONAL,
-  IN BOOLEAN UseHttps
+  IN EFI_REDFISH_DISCOVERED_INTERNAL_INSTANCE  *Instance,
+  IN UINTN                                     *RedfishVersion OPTIONAL,
+  IN CHAR8                                     *RedfishLocation OPTIONAL,
+  IN CHAR8                                     *Uuid  OPTIONAL,
+  IN CHAR8                                     *Os  OPTIONAL,
+  IN CHAR8                                     *OsVer  OPTIONAL,
+  IN CHAR8                                     *Product  OPTIONAL,
+  IN CHAR8                                     *ProductVer  OPTIONAL,
+  IN BOOLEAN                                   UseHttps
   );
   );
 
 
 /**
 /**
@@ -223,12 +223,12 @@ AddAndSignalNewRedfishService (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishGetHostInterfaceProtocolData (
 RedfishGetHostInterfaceProtocolData (
-  IN EFI_SMBIOS_PROTOCOL              *Smbios,
-  OUT REDFISH_INTERFACE_DATA          **DeviceDescriptor,
-  OUT REDFISH_OVER_IP_PROTOCOL_DATA   **ProtocolData
+  IN EFI_SMBIOS_PROTOCOL             *Smbios,
+  OUT REDFISH_INTERFACE_DATA         **DeviceDescriptor,
+  OUT REDFISH_OVER_IP_PROTOCOL_DATA  **ProtocolData
   );
   );
 
 
-extern EFI_GUID gRedfishDiscoverTcp4Instance;
-extern EFI_GUID gRedfishDiscoverTcp6Instance;
-extern EFI_GUID gRedfishDiscoverRestEXInstance;
+extern EFI_GUID  gRedfishDiscoverTcp4Instance;
+extern EFI_GUID  gRedfishDiscoverTcp6Instance;
+extern EFI_GUID  gRedfishDiscoverRestEXInstance;
 #endif
 #endif

+ 26 - 24
RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c

@@ -28,41 +28,41 @@ SMBIOS_TABLE_TYPE42  *mType42Record;
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishGetHostInterfaceProtocolData (
 RedfishGetHostInterfaceProtocolData (
-  IN EFI_SMBIOS_PROTOCOL              *Smbios,
-  OUT REDFISH_INTERFACE_DATA          **DeviceDescriptor,
-  OUT REDFISH_OVER_IP_PROTOCOL_DATA   **ProtocolData
+  IN EFI_SMBIOS_PROTOCOL             *Smbios,
+  OUT REDFISH_INTERFACE_DATA         **DeviceDescriptor,
+  OUT REDFISH_OVER_IP_PROTOCOL_DATA  **ProtocolData
   )
   )
 {
 {
-  EFI_STATUS                        Status;
-  EFI_SMBIOS_HANDLE                 SmbiosHandle;
-  EFI_SMBIOS_TABLE_HEADER           *Record;
-  UINT16                            Offset;
-  UINT8                             *RecordTmp;
-  UINT8                             ProtocolLength;
-  UINT8                             SpecificDataLen;
+  EFI_STATUS               Status;
+  EFI_SMBIOS_HANDLE        SmbiosHandle;
+  EFI_SMBIOS_TABLE_HEADER  *Record;
+  UINT16                   Offset;
+  UINT8                    *RecordTmp;
+  UINT8                    ProtocolLength;
+  UINT8                    SpecificDataLen;
 
 
   if ((Smbios == NULL) || (ProtocolData == NULL)) {
   if ((Smbios == NULL) || (ProtocolData == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
   SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
   SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
-  Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
+  Status       = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
   while (!EFI_ERROR (Status) && SmbiosHandle != SMBIOS_HANDLE_PI_RESERVED) {
   while (!EFI_ERROR (Status) && SmbiosHandle != SMBIOS_HANDLE_PI_RESERVED) {
     if (Record->Type == SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE) {
     if (Record->Type == SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE) {
       //
       //
       // Check Interface Type, should be Network Host Interface = 40h
       // Check Interface Type, should be Network Host Interface = 40h
       //
       //
-      mType42Record = (SMBIOS_TABLE_TYPE42 *) Record;
+      mType42Record = (SMBIOS_TABLE_TYPE42 *)Record;
       if (mType42Record->InterfaceType == MCHostInterfaceTypeNetworkHostInterface) {
       if (mType42Record->InterfaceType == MCHostInterfaceTypeNetworkHostInterface) {
         ASSERT (Record->Length >= 9);
         ASSERT (Record->Length >= 9);
-        Offset = 5;
-        RecordTmp = (UINT8 *) Record + Offset;
+        Offset    = 5;
+        RecordTmp = (UINT8 *)Record + Offset;
         //
         //
         // Get interface specific data length.
         // Get interface specific data length.
         //
         //
         SpecificDataLen = *RecordTmp;
         SpecificDataLen = *RecordTmp;
-        Offset += 1;
-        RecordTmp = (UINT8 *) Record + Offset;
+        Offset         += 1;
+        RecordTmp       = (UINT8 *)Record + Offset;
 
 
         //
         //
         // Check Device Type, only PCI/PCIe Network Interface v2 is supported now.
         // Check Device Type, only PCI/PCIe Network Interface v2 is supported now.
@@ -70,24 +70,24 @@ RedfishGetHostInterfaceProtocolData (
         if (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) {
         if (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) {
           ASSERT (SpecificDataLen == sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
           ASSERT (SpecificDataLen == sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
           *DeviceDescriptor = (REDFISH_INTERFACE_DATA *)RecordTmp;
           *DeviceDescriptor = (REDFISH_INTERFACE_DATA *)RecordTmp;
-          Offset = Offset + SpecificDataLen;
-          RecordTmp = (UINT8 *) Record + Offset;
+          Offset            = Offset + SpecificDataLen;
+          RecordTmp         = (UINT8 *)Record + Offset;
           //
           //
           // Check Protocol count. if > 1, only use the first protocol.
           // Check Protocol count. if > 1, only use the first protocol.
           //
           //
           ASSERT (*RecordTmp == 1);
           ASSERT (*RecordTmp == 1);
-          Offset += 1;
-          RecordTmp = (UINT8 *) Record + Offset;
+          Offset   += 1;
+          RecordTmp = (UINT8 *)Record + Offset;
           //
           //
           // Check protocol identifier.
           // Check protocol identifier.
           //
           //
           if (*RecordTmp == MCHostInterfaceProtocolTypeRedfishOverIP) {
           if (*RecordTmp == MCHostInterfaceProtocolTypeRedfishOverIP) {
-            Offset += 1;
-            RecordTmp = (UINT8 *) Record + Offset;
+            Offset        += 1;
+            RecordTmp      = (UINT8 *)Record + Offset;
             ProtocolLength = *RecordTmp;
             ProtocolLength = *RecordTmp;
 
 
-            Offset += 1;
-            RecordTmp = (UINT8 *) Record + Offset;
+            Offset   += 1;
+            RecordTmp = (UINT8 *)Record + Offset;
 
 
             //
             //
             // This SMBIOS record is invalid, if the length of protocol specific data for
             // This SMBIOS record is invalid, if the length of protocol specific data for
@@ -104,12 +104,14 @@ RedfishGetHostInterfaceProtocolData (
             if (Offset > mType42Record->Hdr.Length) {
             if (Offset > mType42Record->Hdr.Length) {
               return EFI_SECURITY_VIOLATION;
               return EFI_SECURITY_VIOLATION;
             }
             }
+
             *ProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *)RecordTmp;
             *ProtocolData = (REDFISH_OVER_IP_PROTOCOL_DATA *)RecordTmp;
             return EFI_SUCCESS;
             return EFI_SUCCESS;
           }
           }
         }
         }
       }
       }
     }
     }
+
     Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
     Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
   }
   }
 
 

+ 67 - 49
RedfishPkg/RedfishHostInterfaceDxe/RedfishHostInterfaceDxe.c

@@ -33,20 +33,20 @@ RedfishCreateSmbiosTable42 (
   VOID
   VOID
   )
   )
 {
 {
-  REDFISH_INTERFACE_DATA *DeviceDescriptor;
-  UINT8 DeviceDataLength;
-  UINT8 DeviceType;
-  EFI_STATUS Status;
-  MC_HOST_INTERFACE_PROTOCOL_RECORD *ProtocolRecord;
-  VOID *ProtocolRecords;
-  VOID *NewProtocolRecords;
-  UINT8 ProtocolCount;
-  UINT8 CurrentProtocolsDataLength;
-  UINT8 NewProtocolsDataLength;
-  UINT8 ProtocolDataSize;
-  SMBIOS_TABLE_TYPE42 *Type42Record;
-  EFI_SMBIOS_PROTOCOL *Smbios;
-  EFI_SMBIOS_HANDLE MemArrayMappedAddrSmbiosHandle;
+  REDFISH_INTERFACE_DATA             *DeviceDescriptor;
+  UINT8                              DeviceDataLength;
+  UINT8                              DeviceType;
+  EFI_STATUS                         Status;
+  MC_HOST_INTERFACE_PROTOCOL_RECORD  *ProtocolRecord;
+  VOID                               *ProtocolRecords;
+  VOID                               *NewProtocolRecords;
+  UINT8                              ProtocolCount;
+  UINT8                              CurrentProtocolsDataLength;
+  UINT8                              NewProtocolsDataLength;
+  UINT8                              ProtocolDataSize;
+  SMBIOS_TABLE_TYPE42                *Type42Record;
+  EFI_SMBIOS_PROTOCOL                *Smbios;
+  EFI_SMBIOS_HANDLE                  MemArrayMappedAddrSmbiosHandle;
 
 
   //
   //
   // Get platform Redfish host interface device type descriptor data.
   // Get platform Redfish host interface device type descriptor data.
@@ -57,46 +57,55 @@ RedfishCreateSmbiosTable42 (
       DEBUG ((DEBUG_ERROR, "%a: No Redfish host interface descriptor is provided on this platform.", __FUNCTION__));
       DEBUG ((DEBUG_ERROR, "%a: No Redfish host interface descriptor is provided on this platform.", __FUNCTION__));
       return EFI_NOT_FOUND;
       return EFI_NOT_FOUND;
     }
     }
-    DEBUG((DEBUG_ERROR, "%a: Fail to get device descriptor, %r.", __FUNCTION__, Status));
+
+    DEBUG ((DEBUG_ERROR, "%a: Fail to get device descriptor, %r.", __FUNCTION__, Status));
     return Status;
     return Status;
   }
   }
-  if (DeviceType != REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2 &&
-      DeviceType != REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2
-    ) {
+
+  if ((DeviceType != REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2) &&
+      (DeviceType != REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2)
+      )
+  {
     DEBUG ((DEBUG_ERROR, "%a: Only support either protocol type 04h or 05h as Redfish host interface.", __FUNCTION__));
     DEBUG ((DEBUG_ERROR, "%a: Only support either protocol type 04h or 05h as Redfish host interface.", __FUNCTION__));
     return EFI_UNSUPPORTED;
     return EFI_UNSUPPORTED;
   }
   }
+
   if (DeviceType == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) {
   if (DeviceType == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) {
     DeviceDataLength = DeviceDescriptor->DeviceDescriptor.PciPcieDeviceV2.Length;
     DeviceDataLength = DeviceDescriptor->DeviceDescriptor.PciPcieDeviceV2.Length;
   } else {
   } else {
     DeviceDataLength = DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.Length;
     DeviceDataLength = DeviceDescriptor->DeviceDescriptor.UsbDeviceV2.Length;
   }
   }
+
   //
   //
   // Loop to get platform Redfish host interface protocol type data.
   // Loop to get platform Redfish host interface protocol type data.
   //
   //
-  ProtocolRecord = NULL;
-  ProtocolRecords = NULL;
-  NewProtocolRecords = NULL;
-  Type42Record = NULL;
-  ProtocolCount = 0;
+  ProtocolRecord             = NULL;
+  ProtocolRecords            = NULL;
+  NewProtocolRecords         = NULL;
+  Type42Record               = NULL;
+  ProtocolCount              = 0;
   CurrentProtocolsDataLength = 0;
   CurrentProtocolsDataLength = 0;
-  NewProtocolsDataLength = 0;
+  NewProtocolsDataLength     = 0;
   while (TRUE) {
   while (TRUE) {
     Status = RedfishPlatformHostInterfaceProtocolData (&ProtocolRecord, ProtocolCount);
     Status = RedfishPlatformHostInterfaceProtocolData (&ProtocolRecord, ProtocolCount);
     if (Status == EFI_NOT_FOUND) {
     if (Status == EFI_NOT_FOUND) {
       break;
       break;
     }
     }
-    if (EFI_ERROR(Status)) {
+
+    if (EFI_ERROR (Status)) {
       DEBUG ((DEBUG_ERROR, "%a: Fail to get Redfish host interafce protocol type data.", __FUNCTION__));
       DEBUG ((DEBUG_ERROR, "%a: Fail to get Redfish host interafce protocol type data.", __FUNCTION__));
       if (ProtocolRecords != NULL) {
       if (ProtocolRecords != NULL) {
         FreePool (ProtocolRecords);
         FreePool (ProtocolRecords);
       }
       }
+
       if (ProtocolRecord != NULL) {
       if (ProtocolRecord != NULL) {
         FreePool (ProtocolRecord);
         FreePool (ProtocolRecord);
       }
       }
+
       return Status;
       return Status;
     }
     }
-    ProtocolDataSize = sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - sizeof(ProtocolRecord->ProtocolTypeData) + ProtocolRecord->ProtocolTypeDataLen;
+
+    ProtocolDataSize        = sizeof (MC_HOST_INTERFACE_PROTOCOL_RECORD) - sizeof (ProtocolRecord->ProtocolTypeData) + ProtocolRecord->ProtocolTypeDataLen;
     NewProtocolsDataLength += ProtocolDataSize;
     NewProtocolsDataLength += ProtocolDataSize;
     if (ProtocolRecords == NULL) {
     if (ProtocolRecords == NULL) {
       ProtocolRecords = AllocateZeroPool (NewProtocolsDataLength);
       ProtocolRecords = AllocateZeroPool (NewProtocolsDataLength);
@@ -104,29 +113,34 @@ RedfishCreateSmbiosTable42 (
         FreePool (ProtocolRecord);
         FreePool (ProtocolRecord);
         return EFI_OUT_OF_RESOURCES;
         return EFI_OUT_OF_RESOURCES;
       }
       }
+
       CopyMem ((VOID *)ProtocolRecords, (VOID *)ProtocolRecord, ProtocolDataSize);
       CopyMem ((VOID *)ProtocolRecords, (VOID *)ProtocolRecord, ProtocolDataSize);
       NewProtocolRecords = ProtocolRecords;
       NewProtocolRecords = ProtocolRecords;
     } else {
     } else {
-      NewProtocolRecords = ReallocatePool(CurrentProtocolsDataLength, NewProtocolsDataLength, (VOID *)ProtocolRecords);
+      NewProtocolRecords = ReallocatePool (CurrentProtocolsDataLength, NewProtocolsDataLength, (VOID *)ProtocolRecords);
       if (NewProtocolRecords == NULL) {
       if (NewProtocolRecords == NULL) {
         DEBUG ((DEBUG_ERROR, "%a: Fail to allocate memory for Redfish host interface protocol data."));
         DEBUG ((DEBUG_ERROR, "%a: Fail to allocate memory for Redfish host interface protocol data."));
         FreePool (ProtocolRecords);
         FreePool (ProtocolRecords);
         FreePool (ProtocolRecord);
         FreePool (ProtocolRecord);
         return EFI_OUT_OF_RESOURCES;
         return EFI_OUT_OF_RESOURCES;
       }
       }
+
       CopyMem (
       CopyMem (
         (VOID *)((UINT8 *)NewProtocolRecords + CurrentProtocolsDataLength),
         (VOID *)((UINT8 *)NewProtocolRecords + CurrentProtocolsDataLength),
         (VOID *)ProtocolRecord,
         (VOID *)ProtocolRecord,
         ProtocolDataSize
         ProtocolDataSize
         );
         );
     }
     }
+
     FreePool (ProtocolRecord);
     FreePool (ProtocolRecord);
     CurrentProtocolsDataLength = NewProtocolsDataLength;
     CurrentProtocolsDataLength = NewProtocolsDataLength;
-    ProtocolCount ++;
-  };
+    ProtocolCount++;
+  }
+
   if (ProtocolCount == 0) {
   if (ProtocolCount == 0) {
     goto ON_EXIT;
     goto ON_EXIT;
   }
   }
+
   //
   //
   // Construct SMBIOS Type 42h for Redfish host inteface.
   // Construct SMBIOS Type 42h for Redfish host inteface.
   //
   //
@@ -140,13 +154,13 @@ RedfishCreateSmbiosTable42 (
   // 06h+n number of protocols defined for the host interface (typically 1)
   // 06h+n number of protocols defined for the host interface (typically 1)
   // 07h+n Include a Protocol Record for each protocol supported.
   // 07h+n Include a Protocol Record for each protocol supported.
   //
   //
-  Type42Record = (SMBIOS_TABLE_TYPE42 *) AllocateZeroPool (
-                                           sizeof (SMBIOS_TABLE_TYPE42) - 4
-                                           + DeviceDataLength
-                                           + 1 /// For Protocol Record Count
-                                           + CurrentProtocolsDataLength
-                                           + 2 /// Double NULL terminator/
-                                           );
+  Type42Record = (SMBIOS_TABLE_TYPE42 *)AllocateZeroPool (
+                                          sizeof (SMBIOS_TABLE_TYPE42) - 4
+                                          + DeviceDataLength
+                                          + 1  /// For Protocol Record Count
+                                          + CurrentProtocolsDataLength
+                                          + 2  /// Double NULL terminator/
+                                          );
   if (Type42Record == NULL) {
   if (Type42Record == NULL) {
     Status = EFI_OUT_OF_RESOURCES;
     Status = EFI_OUT_OF_RESOURCES;
     goto ON_EXIT;
     goto ON_EXIT;
@@ -154,10 +168,10 @@ RedfishCreateSmbiosTable42 (
 
 
   Type42Record->Hdr.Type   = EFI_SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE;
   Type42Record->Hdr.Type   = EFI_SMBIOS_TYPE_MANAGEMENT_CONTROLLER_HOST_INTERFACE;
   Type42Record->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE42) - 4
   Type42Record->Hdr.Length = sizeof (SMBIOS_TABLE_TYPE42) - 4
-                               + DeviceDataLength
-                               + 1
-                               + CurrentProtocolsDataLength;
-  Type42Record->Hdr.Handle = 0;
+                             + DeviceDataLength
+                             + 1
+                             + CurrentProtocolsDataLength;
+  Type42Record->Hdr.Handle    = 0;
   Type42Record->InterfaceType = MCHostInterfaceTypeNetworkHostInterface; // Network Host Interface
   Type42Record->InterfaceType = MCHostInterfaceTypeNetworkHostInterface; // Network Host Interface
 
 
   //
   //
@@ -189,34 +203,38 @@ RedfishCreateSmbiosTable42 (
   //
   //
   // 5. Add Redfish interface data record to SMBIOS table 42
   // 5. Add Redfish interface data record to SMBIOS table 42
   //
   //
-  Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);
+  Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios);
   if (EFI_ERROR (Status)) {
   if (EFI_ERROR (Status)) {
     goto ON_EXIT;
     goto ON_EXIT;
   }
   }
 
 
   MemArrayMappedAddrSmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
   MemArrayMappedAddrSmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
-  Status = Smbios->Add (
-                    Smbios,
-                    NULL,
-                    &MemArrayMappedAddrSmbiosHandle,
-                    (EFI_SMBIOS_TABLE_HEADER*) Type42Record
-                    );
+  Status                         = Smbios->Add (
+                                             Smbios,
+                                             NULL,
+                                             &MemArrayMappedAddrSmbiosHandle,
+                                             (EFI_SMBIOS_TABLE_HEADER *)Type42Record
+                                             );
   DEBUG ((DEBUG_INFO, "RedfishPlatformDxe: Smbios->Add() - %r\n", Status));
   DEBUG ((DEBUG_INFO, "RedfishPlatformDxe: Smbios->Add() - %r\n", Status));
   if (EFI_ERROR (Status)) {
   if (EFI_ERROR (Status)) {
     goto ON_EXIT;
     goto ON_EXIT;
   }
   }
+
   Status = EFI_SUCCESS;
   Status = EFI_SUCCESS;
 
 
 ON_EXIT:
 ON_EXIT:
   if (DeviceDescriptor != NULL) {
   if (DeviceDescriptor != NULL) {
     FreePool (DeviceDescriptor);
     FreePool (DeviceDescriptor);
   }
   }
+
   if (NewProtocolRecords != NULL) {
   if (NewProtocolRecords != NULL) {
     FreePool (NewProtocolRecords);
     FreePool (NewProtocolRecords);
   }
   }
+
   if (Type42Record != NULL) {
   if (Type42Record != NULL) {
     FreePool (Type42Record);
     FreePool (Type42Record);
   }
   }
+
   return Status;
   return Status;
 }
 }
 
 
@@ -232,8 +250,8 @@ ON_EXIT:
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishHostInterfaceDxeEntryPoint (
 RedfishHostInterfaceDxeEntryPoint (
-  IN EFI_HANDLE         ImageHandle,
-  IN EFI_SYSTEM_TABLE   *SystemTable
+  IN EFI_HANDLE        ImageHandle,
+  IN EFI_SYSTEM_TABLE  *SystemTable
   )
   )
 {
 {
   //
   //

+ 14 - 13
RedfishPkg/RedfishRestExDxe/ComponentName.c

@@ -18,6 +18,7 @@
 //
 //
 // EFI Component Name Functions
 // EFI Component Name Functions
 //
 //
+
 /**
 /**
   Retrieves a Unicode string that is the user-readable name of the EFI Driver.
   Retrieves a Unicode string that is the user-readable name of the EFI Driver.
 
 
@@ -92,10 +93,10 @@ EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExComponentNameGetControllerName (
 RedfishRestExComponentNameGetControllerName (
   IN  EFI_COMPONENT_NAME_PROTOCOL  *This,
   IN  EFI_COMPONENT_NAME_PROTOCOL  *This,
-  IN  EFI_HANDLE                    ControllerHandle,
-  IN  EFI_HANDLE                    ChildHandle        OPTIONAL,
-  IN  CHAR8                         *Language,
-  OUT CHAR16                        **ControllerName
+  IN  EFI_HANDLE                   ControllerHandle,
+  IN  EFI_HANDLE                   ChildHandle        OPTIONAL,
+  IN  CHAR8                        *Language,
+  OUT CHAR16                       **ControllerName
   );
   );
 
 
 ///
 ///
@@ -113,8 +114,8 @@ EFI_COMPONENT_NAME_PROTOCOL  gRedfishRestExComponentName = {
 ///
 ///
 GLOBAL_REMOVE_IF_UNREFERENCED
 GLOBAL_REMOVE_IF_UNREFERENCED
 EFI_COMPONENT_NAME2_PROTOCOL  gRedfishRestExComponentName2 = {
 EFI_COMPONENT_NAME2_PROTOCOL  gRedfishRestExComponentName2 = {
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)     RedfishRestExComponentNameGetDriverName,
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) RedfishRestExComponentNameGetControllerName,
+  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)RedfishRestExComponentNameGetDriverName,
+  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)RedfishRestExComponentNameGetControllerName,
   "en"
   "en"
 };
 };
 
 
@@ -122,12 +123,12 @@ EFI_COMPONENT_NAME2_PROTOCOL  gRedfishRestExComponentName2 = {
 /// Table of driver names
 /// Table of driver names
 ///
 ///
 GLOBAL_REMOVE_IF_UNREFERENCED
 GLOBAL_REMOVE_IF_UNREFERENCED
-EFI_UNICODE_STRING_TABLE mRedfishRestExDriverNameTable[] = {
+EFI_UNICODE_STRING_TABLE  mRedfishRestExDriverNameTable[] = {
   { "eng;en", (CHAR16 *)L"Redfish RestEx Network Service Driver" },
   { "eng;en", (CHAR16 *)L"Redfish RestEx Network Service Driver" },
-  { NULL, NULL }
+  { NULL,     NULL                                               }
 };
 };
 
 
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gRedfishRestExControllerNameTable = NULL;
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE  *gRedfishRestExControllerNameTable = NULL;
 
 
 /**
 /**
   Retrieves a Unicode string that is the user-readable name of the EFI Driver.
   Retrieves a Unicode string that is the user-readable name of the EFI Driver.
@@ -212,10 +213,10 @@ EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExComponentNameGetControllerName (
 RedfishRestExComponentNameGetControllerName (
   IN  EFI_COMPONENT_NAME_PROTOCOL  *This,
   IN  EFI_COMPONENT_NAME_PROTOCOL  *This,
-  IN  EFI_HANDLE                    ControllerHandle,
-  IN  EFI_HANDLE                    ChildHandle        OPTIONAL,
-  IN  CHAR8                         *Language,
-  OUT CHAR16                        **ControllerName
+  IN  EFI_HANDLE                   ControllerHandle,
+  IN  EFI_HANDLE                   ChildHandle        OPTIONAL,
+  IN  CHAR8                        *Language,
+  OUT CHAR16                       **ControllerName
   )
   )
 {
 {
   return EFI_UNSUPPORTED;
   return EFI_UNSUPPORTED;

+ 71 - 74
RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.c

@@ -11,7 +11,7 @@
 #include <Uefi.h>
 #include <Uefi.h>
 #include "RedfishRestExDriver.h"
 #include "RedfishRestExDriver.h"
 
 
-EFI_DRIVER_BINDING_PROTOCOL gRedfishRestExDriverBinding = {
+EFI_DRIVER_BINDING_PROTOCOL  gRedfishRestExDriverBinding = {
   RedfishRestExDriverBindingSupported,
   RedfishRestExDriverBindingSupported,
   RedfishRestExDriverBindingStart,
   RedfishRestExDriverBindingStart,
   RedfishRestExDriverBindingStop,
   RedfishRestExDriverBindingStop,
@@ -20,7 +20,7 @@ EFI_DRIVER_BINDING_PROTOCOL gRedfishRestExDriverBinding = {
   NULL
   NULL
 };
 };
 
 
-EFI_SERVICE_BINDING_PROTOCOL mRedfishRestExServiceBinding = {
+EFI_SERVICE_BINDING_PROTOCOL  mRedfishRestExServiceBinding = {
   RedfishRestExServiceBindingCreateChild,
   RedfishRestExServiceBindingCreateChild,
   RedfishRestExServiceBindingDestroyChild
   RedfishRestExServiceBindingDestroyChild
 };
 };
@@ -38,8 +38,8 @@ EFI_SERVICE_BINDING_PROTOCOL mRedfishRestExServiceBinding = {
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RestExDestroyChildEntryInHandleBuffer (
 RestExDestroyChildEntryInHandleBuffer (
-  IN LIST_ENTRY         *Entry,
-  IN VOID               *Context
+  IN LIST_ENTRY  *Entry,
+  IN VOID        *Context
   )
   )
 {
 {
   RESTEX_INSTANCE               *Instance;
   RESTEX_INSTANCE               *Instance;
@@ -47,14 +47,14 @@ RestExDestroyChildEntryInHandleBuffer (
   UINTN                         NumberOfChildren;
   UINTN                         NumberOfChildren;
   EFI_HANDLE                    *ChildHandleBuffer;
   EFI_HANDLE                    *ChildHandleBuffer;
 
 
-  if (Entry == NULL || Context == NULL) {
+  if ((Entry == NULL) || (Context == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
-  Instance = NET_LIST_USER_STRUCT_S (Entry, RESTEX_INSTANCE, Link, RESTEX_INSTANCE_SIGNATURE);
-  ServiceBinding    = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ServiceBinding;
-  NumberOfChildren  = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->NumberOfChildren;
-  ChildHandleBuffer = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *) Context)->ChildHandleBuffer;
+  Instance          = NET_LIST_USER_STRUCT_S (Entry, RESTEX_INSTANCE, Link, RESTEX_INSTANCE_SIGNATURE);
+  ServiceBinding    = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ServiceBinding;
+  NumberOfChildren  = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->NumberOfChildren;
+  ChildHandleBuffer = ((RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT *)Context)->ChildHandleBuffer;
 
 
   if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) {
   if (!NetIsInHandleBuffer (Instance->ChildHandle, NumberOfChildren, ChildHandleBuffer)) {
     return EFI_SUCCESS;
     return EFI_SUCCESS;
@@ -71,7 +71,7 @@ RestExDestroyChildEntryInHandleBuffer (
 **/
 **/
 VOID
 VOID
 RestExDestroyInstance (
 RestExDestroyInstance (
-  IN RESTEX_INSTANCE         *Instance
+  IN RESTEX_INSTANCE  *Instance
   )
   )
 {
 {
   HttpIoDestroyIo (&(Instance->HttpIo));
   HttpIoDestroyIo (&(Instance->HttpIo));
@@ -91,12 +91,12 @@ RestExDestroyInstance (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RestExCreateInstance (
 RestExCreateInstance (
-  IN  RESTEX_SERVICE         *Service,
-  OUT RESTEX_INSTANCE        **Instance
+  IN  RESTEX_SERVICE   *Service,
+  OUT RESTEX_INSTANCE  **Instance
   )
   )
 {
 {
-  RESTEX_INSTANCE            *RestExIns;
-  EFI_STATUS                 Status;
+  RESTEX_INSTANCE  *RestExIns;
+  EFI_STATUS       Status;
 
 
   *Instance = NULL;
   *Instance = NULL;
   Status    = EFI_SUCCESS;
   Status    = EFI_SUCCESS;
@@ -143,7 +143,7 @@ RestExCreateInstance (
 **/
 **/
 VOID
 VOID
 RestExDestroyService (
 RestExDestroyService (
-  IN RESTEX_SERVICE     *RestExSb
+  IN RESTEX_SERVICE  *RestExSb
   )
   )
 {
 {
   if (RestExSb->HttpChildHandle != NULL) {
   if (RestExSb->HttpChildHandle != NULL) {
@@ -184,7 +184,7 @@ RestExDestroyService (
 **/
 **/
 EFI_REST_EX_SERVICE_ACCESS_MODE
 EFI_REST_EX_SERVICE_ACCESS_MODE
 RestExServiceAccessMode (
 RestExServiceAccessMode (
-  IN     EFI_HANDLE            Controller
+  IN     EFI_HANDLE  Controller
   )
   )
 {
 {
   //
   //
@@ -213,18 +213,18 @@ RestExServiceAccessMode (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RestExCreateService (
 RestExCreateService (
-  IN     EFI_HANDLE            Controller,
-  IN     EFI_HANDLE            Image,
-  OUT    RESTEX_SERVICE        **Service
+  IN     EFI_HANDLE      Controller,
+  IN     EFI_HANDLE      Image,
+  OUT    RESTEX_SERVICE  **Service
   )
   )
 {
 {
-  EFI_STATUS                Status;
-  RESTEX_SERVICE            *RestExSb;
+  EFI_STATUS      Status;
+  RESTEX_SERVICE  *RestExSb;
 
 
-  Status       = EFI_SUCCESS;
-  RestExSb     = NULL;
+  Status   = EFI_SUCCESS;
+  RestExSb = NULL;
 
 
-  *Service  = NULL;
+  *Service = NULL;
 
 
   RestExSb = AllocateZeroPool (sizeof (RESTEX_SERVICE));
   RestExSb = AllocateZeroPool (sizeof (RESTEX_SERVICE));
   if (RestExSb == NULL) {
   if (RestExSb == NULL) {
@@ -241,13 +241,13 @@ RestExCreateService (
   RestExSb->ControllerHandle = Controller;
   RestExSb->ControllerHandle = Controller;
   RestExSb->ImageHandle      = Image;
   RestExSb->ImageHandle      = Image;
 
 
-  RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.EfiRestExServiceInfoHeader.Length = sizeof (EFI_REST_EX_SERVICE_INFO);
+  RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.EfiRestExServiceInfoHeader.Length                   = sizeof (EFI_REST_EX_SERVICE_INFO);
   RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.EfiRestExServiceInfoHeader.RestServiceInfoVer.Major = 1;
   RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.EfiRestExServiceInfoHeader.RestServiceInfoVer.Major = 1;
   RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.EfiRestExServiceInfoHeader.RestServiceInfoVer.Minor = 0;
   RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.EfiRestExServiceInfoHeader.RestServiceInfoVer.Minor = 0;
-  RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.RestServiceType = EfiRestExServiceRedfish;
-  RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.RestServiceAccessMode = RestExServiceAccessMode (Controller);
-  RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.RestExConfigType = EfiRestExConfigHttp;
-  RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.RestExConfigDataLength = sizeof (EFI_REST_EX_HTTP_CONFIG_DATA);
+  RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.RestServiceType                                     = EfiRestExServiceRedfish;
+  RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.RestServiceAccessMode                               = RestExServiceAccessMode (Controller);
+  RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.RestExConfigType                                    = EfiRestExConfigHttp;
+  RestExSb->RestExServiceInfo.EfiRestExServiceInfoV10.RestExConfigDataLength                              = sizeof (EFI_REST_EX_HTTP_CONFIG_DATA);
 
 
   Status = gBS->InstallProtocolInterface (
   Status = gBS->InstallProtocolInterface (
                   &Controller,
                   &Controller,
@@ -354,7 +354,6 @@ RedfishRestExDriverBindingSupported (
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
   )
   )
 {
 {
-
   //
   //
   // Test for the HttpServiceBinding Protocol.
   // Test for the HttpServiceBinding Protocol.
   //
   //
@@ -366,7 +365,6 @@ RedfishRestExDriverBindingSupported (
                 ControllerHandle,
                 ControllerHandle,
                 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
                 EFI_OPEN_PROTOCOL_TEST_PROTOCOL
                 );
                 );
-
 }
 }
 
 
 /**
 /**
@@ -412,15 +410,15 @@ RedfishRestExDriverBindingStart (
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
   )
   )
 {
 {
-  RESTEX_SERVICE         *RestExSb;
-  EFI_STATUS             Status;
-  UINT32                 *Id;
-  VOID                   *Interface;
+  RESTEX_SERVICE  *RestExSb;
+  EFI_STATUS      Status;
+  UINT32          *Id;
+  VOID            *Interface;
 
 
   Status = gBS->OpenProtocol (
   Status = gBS->OpenProtocol (
                   ControllerHandle,
                   ControllerHandle,
                   &gEfiCallerIdGuid,
                   &gEfiCallerIdGuid,
-                  (VOID **) &Id,
+                  (VOID **)&Id,
                   This->DriverBindingHandle,
                   This->DriverBindingHandle,
                   ControllerHandle,
                   ControllerHandle,
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -518,12 +516,12 @@ RedfishRestExDriverBindingStop (
   IN EFI_HANDLE                   *ChildHandleBuffer OPTIONAL
   IN EFI_HANDLE                   *ChildHandleBuffer OPTIONAL
   )
   )
 {
 {
-  EFI_SERVICE_BINDING_PROTOCOL               *ServiceBinding;
-  RESTEX_SERVICE                             *RestExSb;
-  EFI_HANDLE                                 NicHandle;
-  EFI_STATUS                                 Status;
-  LIST_ENTRY                                 *List;
-  RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT Context;
+  EFI_SERVICE_BINDING_PROTOCOL                *ServiceBinding;
+  RESTEX_SERVICE                              *RestExSb;
+  EFI_HANDLE                                  NicHandle;
+  EFI_STATUS                                  Status;
+  LIST_ENTRY                                  *List;
+  RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT  Context;
 
 
   //
   //
   // RestEx driver opens HTTP child, So, Controller is a HTTP
   // RestEx driver opens HTTP child, So, Controller is a HTTP
@@ -538,7 +536,7 @@ RedfishRestExDriverBindingStop (
   Status = gBS->OpenProtocol (
   Status = gBS->OpenProtocol (
                   NicHandle,
                   NicHandle,
                   &gEfiRestExServiceBindingProtocolGuid,
                   &gEfiRestExServiceBindingProtocolGuid,
-                  (VOID **) &ServiceBinding,
+                  (VOID **)&ServiceBinding,
                   This->DriverBindingHandle,
                   This->DriverBindingHandle,
                   NicHandle,
                   NicHandle,
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -553,19 +551,19 @@ RedfishRestExDriverBindingStop (
     //
     //
     // Destroy the RestEx child instance in ChildHandleBuffer.
     // Destroy the RestEx child instance in ChildHandleBuffer.
     //
     //
-    List = &RestExSb->RestExChildrenList;
+    List                      = &RestExSb->RestExChildrenList;
     Context.ServiceBinding    = ServiceBinding;
     Context.ServiceBinding    = ServiceBinding;
     Context.NumberOfChildren  = NumberOfChildren;
     Context.NumberOfChildren  = NumberOfChildren;
     Context.ChildHandleBuffer = ChildHandleBuffer;
     Context.ChildHandleBuffer = ChildHandleBuffer;
-    Status = NetDestroyLinkList (
-               List,
-               RestExDestroyChildEntryInHandleBuffer,
-               &Context,
-               NULL
-               );
+    Status                    = NetDestroyLinkList (
+                                  List,
+                                  RestExDestroyChildEntryInHandleBuffer,
+                                  &Context,
+                                  NULL
+                                  );
   }
   }
 
 
-  if (NumberOfChildren == 0 && IsListEmpty (&RestExSb->RestExChildrenList)) {
+  if ((NumberOfChildren == 0) && IsListEmpty (&RestExSb->RestExChildrenList)) {
     gBS->UninstallProtocolInterface (
     gBS->UninstallProtocolInterface (
            NicHandle,
            NicHandle,
            &gEfiRestExServiceBindingProtocolGuid,
            &gEfiRestExServiceBindingProtocolGuid,
@@ -611,11 +609,11 @@ RedfishRestExServiceBindingCreateChild (
   IN EFI_HANDLE                    *ChildHandle
   IN EFI_HANDLE                    *ChildHandle
   )
   )
 {
 {
-  RESTEX_SERVICE               *RestExSb;
-  RESTEX_INSTANCE              *Instance;
-  EFI_STATUS                   Status;
-  EFI_TPL                      OldTpl;
-  VOID                         *Http;
+  RESTEX_SERVICE   *RestExSb;
+  RESTEX_INSTANCE  *Instance;
+  EFI_STATUS       Status;
+  EFI_TPL          OldTpl;
+  VOID             *Http;
 
 
   if ((This == NULL) || (ChildHandle == NULL)) {
   if ((This == NULL) || (ChildHandle == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
@@ -627,6 +625,7 @@ RedfishRestExServiceBindingCreateChild (
   if (EFI_ERROR (Status)) {
   if (EFI_ERROR (Status)) {
     return Status;
     return Status;
   }
   }
+
   ASSERT (Instance != NULL);
   ASSERT (Instance != NULL);
 
 
   //
   //
@@ -650,7 +649,7 @@ RedfishRestExServiceBindingCreateChild (
   Status = gBS->OpenProtocol (
   Status = gBS->OpenProtocol (
                   RestExSb->HttpChildHandle,
                   RestExSb->HttpChildHandle,
                   &gEfiHttpProtocolGuid,
                   &gEfiHttpProtocolGuid,
-                  (VOID **) &Http,
+                  (VOID **)&Http,
                   gRedfishRestExDriverBinding.DriverBindingHandle,
                   gRedfishRestExDriverBinding.DriverBindingHandle,
                   Instance->ChildHandle,
                   Instance->ChildHandle,
                   EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
                   EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -672,7 +671,7 @@ RedfishRestExServiceBindingCreateChild (
   Status = gBS->OpenProtocol (
   Status = gBS->OpenProtocol (
                   Instance->HttpIo.Handle,
                   Instance->HttpIo.Handle,
                   &gEfiHttpProtocolGuid,
                   &gEfiHttpProtocolGuid,
-                  (VOID **) &Http,
+                  (VOID **)&Http,
                   gRedfishRestExDriverBinding.DriverBindingHandle,
                   gRedfishRestExDriverBinding.DriverBindingHandle,
                   Instance->ChildHandle,
                   Instance->ChildHandle,
                   EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
                   EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
@@ -688,12 +687,12 @@ RedfishRestExServiceBindingCreateChild (
            ChildHandle
            ChildHandle
            );
            );
 
 
-     gBS->UninstallMultipleProtocolInterfaces (
-            Instance->ChildHandle,
-            &gEfiRestExProtocolGuid,
-            &Instance->RestEx,
-            NULL
-            );
+    gBS->UninstallMultipleProtocolInterfaces (
+           Instance->ChildHandle,
+           &gEfiRestExProtocolGuid,
+           &Instance->RestEx,
+           NULL
+           );
 
 
     goto ON_ERROR;
     goto ON_ERROR;
   }
   }
@@ -741,12 +740,12 @@ RedfishRestExServiceBindingDestroyChild (
   IN EFI_HANDLE                    ChildHandle
   IN EFI_HANDLE                    ChildHandle
   )
   )
 {
 {
-  RESTEX_SERVICE               *RestExSb;
-  RESTEX_INSTANCE              *Instance;
+  RESTEX_SERVICE   *RestExSb;
+  RESTEX_INSTANCE  *Instance;
 
 
-  EFI_REST_EX_PROTOCOL         *RestEx;
-  EFI_STATUS                   Status;
-  EFI_TPL                      OldTpl;
+  EFI_REST_EX_PROTOCOL  *RestEx;
+  EFI_STATUS            Status;
+  EFI_TPL               OldTpl;
 
 
   if ((This == NULL) || (ChildHandle == NULL)) {
   if ((This == NULL) || (ChildHandle == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
@@ -758,7 +757,7 @@ RedfishRestExServiceBindingDestroyChild (
   Status = gBS->OpenProtocol (
   Status = gBS->OpenProtocol (
                   ChildHandle,
                   ChildHandle,
                   &gEfiRestExProtocolGuid,
                   &gEfiRestExProtocolGuid,
-                  (VOID **) &RestEx,
+                  (VOID **)&RestEx,
                   NULL,
                   NULL,
                   NULL,
                   NULL,
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
@@ -768,8 +767,8 @@ RedfishRestExServiceBindingDestroyChild (
     return EFI_UNSUPPORTED;
     return EFI_UNSUPPORTED;
   }
   }
 
 
-  Instance  = RESTEX_INSTANCE_FROM_THIS (RestEx);
-  RestExSb  = RESTEX_SERVICE_FROM_THIS (This);
+  Instance = RESTEX_INSTANCE_FROM_THIS (RestEx);
+  RestExSb = RESTEX_SERVICE_FROM_THIS (This);
 
 
   if (Instance->Service != RestExSb) {
   if (Instance->Service != RestExSb) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
@@ -800,7 +799,6 @@ RedfishRestExServiceBindingDestroyChild (
          ChildHandle
          ChildHandle
          );
          );
 
 
-
   gBS->RestoreTPL (OldTpl);
   gBS->RestoreTPL (OldTpl);
 
 
   //
   //
@@ -828,4 +826,3 @@ RedfishRestExServiceBindingDestroyChild (
   RestExDestroyInstance (Instance);
   RestExDestroyInstance (Instance);
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }
-

+ 57 - 58
RedfishPkg/RedfishRestExDxe/RedfishRestExDriver.h

@@ -45,7 +45,7 @@ extern EFI_REST_EX_PROTOCOL          mRedfishRestExProtocol;
 ///
 ///
 /// RestEx service block
 /// RestEx service block
 ///
 ///
-typedef struct _RESTEX_SERVICE  RESTEX_SERVICE;
+typedef struct _RESTEX_SERVICE RESTEX_SERVICE;
 
 
 ///
 ///
 /// RestEx instance block
 /// RestEx instance block
@@ -57,8 +57,8 @@ typedef struct _RESTEX_INSTANCE RESTEX_INSTANCE;
 ///
 ///
 #define REDFISH_RESTEX_DRIVER_VERSION  0x0100
 #define REDFISH_RESTEX_DRIVER_VERSION  0x0100
 
 
-#define RESTEX_SERVICE_SIGNATURE    SIGNATURE_32 ('R', 'E', 'S', 'S')
-#define RESTEX_INSTANCE_SIGNATURE   SIGNATURE_32 ('R', 'E', 'I', 'S')
+#define RESTEX_SERVICE_SIGNATURE   SIGNATURE_32 ('R', 'E', 'S', 'S')
+#define RESTEX_INSTANCE_SIGNATURE  SIGNATURE_32 ('R', 'E', 'I', 'S')
 
 
 #define RESTEX_SERVICE_FROM_THIS(a)   \
 #define RESTEX_SERVICE_FROM_THIS(a)   \
   CR (a, RESTEX_SERVICE, ServiceBinding, RESTEX_SERVICE_SIGNATURE)
   CR (a, RESTEX_SERVICE, ServiceBinding, RESTEX_SERVICE_SIGNATURE)
@@ -66,59 +66,58 @@ typedef struct _RESTEX_INSTANCE RESTEX_INSTANCE;
 #define RESTEX_INSTANCE_FROM_THIS(a)  \
 #define RESTEX_INSTANCE_FROM_THIS(a)  \
   CR (a, RESTEX_INSTANCE, RestEx, RESTEX_INSTANCE_SIGNATURE)
   CR (a, RESTEX_INSTANCE, RestEx, RESTEX_INSTANCE_SIGNATURE)
 
 
-
-#define RESTEX_STATE_UNCONFIGED     0
-#define RESTEX_STATE_CONFIGED       1
+#define RESTEX_STATE_UNCONFIGED  0
+#define RESTEX_STATE_CONFIGED    1
 
 
 struct _RESTEX_SERVICE {
 struct _RESTEX_SERVICE {
-  UINT32                        Signature;
-  EFI_SERVICE_BINDING_PROTOCOL  ServiceBinding;
+  UINT32                          Signature;
+  EFI_SERVICE_BINDING_PROTOCOL    ServiceBinding;
 
 
-  UINT16                        RestExChildrenNum;
-  LIST_ENTRY                    RestExChildrenList;
+  UINT16                          RestExChildrenNum;
+  LIST_ENTRY                      RestExChildrenList;
 
 
-  EFI_HANDLE                    ControllerHandle;
-  EFI_HANDLE                    ImageHandle;
+  EFI_HANDLE                      ControllerHandle;
+  EFI_HANDLE                      ImageHandle;
 
 
   //
   //
   // Use to establish the parent-child relationship.
   // Use to establish the parent-child relationship.
   //
   //
-  EFI_HANDLE                    HttpChildHandle;
+  EFI_HANDLE                      HttpChildHandle;
 
 
-  UINT32                        Id;
+  UINT32                          Id;
 
 
-  EFI_REST_EX_SERVICE_INFO      RestExServiceInfo;
+  EFI_REST_EX_SERVICE_INFO        RestExServiceInfo;
 };
 };
 
 
-#define RESTEX_INSTANCE_FLAGS_TLS_RETRY       0x00000001
-#define RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY 0x00000002
+#define RESTEX_INSTANCE_FLAGS_TLS_RETRY        0x00000001
+#define RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY  0x00000002
 
 
 struct _RESTEX_INSTANCE {
 struct _RESTEX_INSTANCE {
-  UINT32                        Signature;
-  LIST_ENTRY                    Link;
+  UINT32                     Signature;
+  LIST_ENTRY                 Link;
 
 
-  EFI_REST_EX_PROTOCOL          RestEx;
+  EFI_REST_EX_PROTOCOL       RestEx;
 
 
-  INTN                          State;
-  BOOLEAN                       InDestroy;
+  INTN                       State;
+  BOOLEAN                    InDestroy;
 
 
-  RESTEX_SERVICE                *Service;
-  EFI_HANDLE                    ChildHandle;
+  RESTEX_SERVICE             *Service;
+  EFI_HANDLE                 ChildHandle;
 
 
-  EFI_REST_EX_CONFIG_DATA       ConfigData;
+  EFI_REST_EX_CONFIG_DATA    ConfigData;
 
 
   //
   //
   // HTTP_IO to access the HTTP service
   // HTTP_IO to access the HTTP service
   //
   //
-  HTTP_IO                       HttpIo;
+  HTTP_IO                    HttpIo;
 
 
-  UINT32                        Flags;
+  UINT32                     Flags;
 };
 };
 
 
 typedef struct {
 typedef struct {
-  EFI_SERVICE_BINDING_PROTOCOL  *ServiceBinding;
-  UINTN                         NumberOfChildren;
-  EFI_HANDLE                    *ChildHandleBuffer;
+  EFI_SERVICE_BINDING_PROTOCOL    *ServiceBinding;
+  UINTN                           NumberOfChildren;
+  EFI_HANDLE                      *ChildHandleBuffer;
 } RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
 } RESTEX_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;
 
 
 /**
 /**
@@ -143,9 +142,9 @@ typedef struct {
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExSendReceive (
 RedfishRestExSendReceive (
-  IN      EFI_REST_EX_PROTOCOL   *This,
-  IN      EFI_HTTP_MESSAGE       *RequestMessage,
-  OUT     EFI_HTTP_MESSAGE       *ResponseMessage
+  IN      EFI_REST_EX_PROTOCOL  *This,
+  IN      EFI_HTTP_MESSAGE      *RequestMessage,
+  OUT     EFI_HTTP_MESSAGE      *ResponseMessage
   );
   );
 
 
 /**
 /**
@@ -173,8 +172,8 @@ RedfishRestExSendReceive (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExGetServiceTime (
 RedfishRestExGetServiceTime (
-  IN      EFI_REST_EX_PROTOCOL   *This,
-  OUT     EFI_TIME               *Time
+  IN      EFI_REST_EX_PROTOCOL  *This,
+  OUT     EFI_TIME              *Time
   );
   );
 
 
 /**
 /**
@@ -244,8 +243,8 @@ RedfishRestExGetService (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExGetModeData (
 RedfishRestExGetModeData (
-  IN  EFI_REST_EX_PROTOCOL      *This,
-  OUT EFI_REST_EX_CONFIG_DATA   *RestExConfigData
+  IN  EFI_REST_EX_PROTOCOL     *This,
+  OUT EFI_REST_EX_CONFIG_DATA  *RestExConfigData
   );
   );
 
 
 /**
 /**
@@ -282,8 +281,8 @@ RedfishRestExGetModeData (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExConfigure (
 RedfishRestExConfigure (
-  IN  EFI_REST_EX_PROTOCOL    *This,
-  IN  EFI_REST_EX_CONFIG_DATA RestExConfigData
+  IN  EFI_REST_EX_PROTOCOL     *This,
+  IN  EFI_REST_EX_CONFIG_DATA  RestExConfigData
   );
   );
 
 
 /**
 /**
@@ -320,10 +319,10 @@ RedfishRestExConfigure (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExAyncSendReceive (
 RedfishRestExAyncSendReceive (
-  IN      EFI_REST_EX_PROTOCOL   *This,
-  IN      EFI_HTTP_MESSAGE       *RequestMessage OPTIONAL,
-  IN      EFI_REST_EX_TOKEN      *RestExToken,
-  IN      UINTN                  *TimeOutInMilliSeconds OPTIONAL
+  IN      EFI_REST_EX_PROTOCOL  *This,
+  IN      EFI_HTTP_MESSAGE      *RequestMessage OPTIONAL,
+  IN      EFI_REST_EX_TOKEN     *RestExToken,
+  IN      UINTN                 *TimeOutInMilliSeconds OPTIONAL
   );
   );
 
 
 /**
 /**
@@ -355,10 +354,11 @@ RedfishRestExAyncSendReceive (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExEventService (
 RedfishRestExEventService (
-  IN      EFI_REST_EX_PROTOCOL   *This,
-  IN      EFI_HTTP_MESSAGE       *RequestMessage OPTIONAL,
-  IN      EFI_REST_EX_TOKEN      *RestExToken
+  IN      EFI_REST_EX_PROTOCOL  *This,
+  IN      EFI_HTTP_MESSAGE      *RequestMessage OPTIONAL,
+  IN      EFI_REST_EX_TOKEN     *RestExToken
   );
   );
+
 /**
 /**
   Create a new TLS session becuase the previous on is closed.
   Create a new TLS session becuase the previous on is closed.
   status.
   status.
@@ -372,8 +372,7 @@ RedfishRestExEventService (
 EFI_STATUS
 EFI_STATUS
 ResetHttpTslSession (
 ResetHttpTslSession (
   IN   RESTEX_INSTANCE  *Instance
   IN   RESTEX_INSTANCE  *Instance
-);
-
+  );
 
 
 /**
 /**
   Callback function which provided by user to remove one node in NetDestroyLinkList process.
   Callback function which provided by user to remove one node in NetDestroyLinkList process.
@@ -388,8 +387,8 @@ ResetHttpTslSession (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RestExDestroyChildEntryInHandleBuffer (
 RestExDestroyChildEntryInHandleBuffer (
-  IN LIST_ENTRY         *Entry,
-  IN VOID               *Context
+  IN LIST_ENTRY  *Entry,
+  IN VOID        *Context
   );
   );
 
 
 /**
 /**
@@ -400,7 +399,7 @@ RestExDestroyChildEntryInHandleBuffer (
 **/
 **/
 VOID
 VOID
 RestExDestroyInstance (
 RestExDestroyInstance (
-  IN RESTEX_INSTANCE         *Instance
+  IN RESTEX_INSTANCE  *Instance
   );
   );
 
 
 /**
 /**
@@ -415,11 +414,10 @@ RestExDestroyInstance (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RestExCreateInstance (
 RestExCreateInstance (
-  IN  RESTEX_SERVICE         *Service,
-  OUT RESTEX_INSTANCE        **Instance
+  IN  RESTEX_SERVICE   *Service,
+  OUT RESTEX_INSTANCE  **Instance
   );
   );
 
 
-
 /**
 /**
   Release all the resource used the RestEx service binding instance.
   Release all the resource used the RestEx service binding instance.
 
 
@@ -428,7 +426,7 @@ RestExCreateInstance (
 **/
 **/
 VOID
 VOID
 RestExDestroyService (
 RestExDestroyService (
-  IN RESTEX_SERVICE     *RestExSb
+  IN RESTEX_SERVICE  *RestExSb
   );
   );
 
 
 /**
 /**
@@ -446,9 +444,9 @@ RestExDestroyService (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RestExCreateService (
 RestExCreateService (
-  IN     EFI_HANDLE            Controller,
-  IN     EFI_HANDLE            Image,
-  OUT    RESTEX_SERVICE        **Service
+  IN     EFI_HANDLE      Controller,
+  IN     EFI_HANDLE      Image,
+  OUT    RESTEX_SERVICE  **Service
   );
   );
 
 
 /**
 /**
@@ -647,4 +645,5 @@ RedfishRestExServiceBindingDestroyChild (
   IN EFI_SERVICE_BINDING_PROTOCOL  *This,
   IN EFI_SERVICE_BINDING_PROTOCOL  *This,
   IN EFI_HANDLE                    ChildHandle
   IN EFI_HANDLE                    ChildHandle
   );
   );
+
 #endif
 #endif

+ 40 - 33
RedfishPkg/RedfishRestExDxe/RedfishRestExImpl.c

@@ -23,9 +23,9 @@
 EFI_STATUS
 EFI_STATUS
 ResetHttpTslSession (
 ResetHttpTslSession (
   IN   RESTEX_INSTANCE  *Instance
   IN   RESTEX_INSTANCE  *Instance
-)
+  )
 {
 {
-  EFI_STATUS Status;
+  EFI_STATUS  Status;
 
 
   DEBUG ((DEBUG_INFO, "%a: TCP connection is finished. Could be TSL session closure, reset HTTP instance for the new TLS session.\n", __FUNCTION__));
   DEBUG ((DEBUG_INFO, "%a: TCP connection is finished. Could be TSL session closure, reset HTTP instance for the new TLS session.\n", __FUNCTION__));
 
 
@@ -34,12 +34,15 @@ ResetHttpTslSession (
     DEBUG ((DEBUG_ERROR, "%a: Error to reset HTTP instance.\n", __FUNCTION__));
     DEBUG ((DEBUG_ERROR, "%a: Error to reset HTTP instance.\n", __FUNCTION__));
     return Status;
     return Status;
   }
   }
-  Status = Instance->HttpIo.Http->Configure(Instance->HttpIo.Http, &((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData);
+
+  Status = Instance->HttpIo.Http->Configure (Instance->HttpIo.Http, &((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData);
   if (EFI_ERROR (Status)) {
   if (EFI_ERROR (Status)) {
     DEBUG ((DEBUG_ERROR, "%a: Error to re-initiate HTTP instance.\n", __FUNCTION__));
     DEBUG ((DEBUG_ERROR, "%a: Error to re-initiate HTTP instance.\n", __FUNCTION__));
   }
   }
+
   return Status;
   return Status;
 }
 }
+
 /**
 /**
   This function check
   This function check
 
 
@@ -55,16 +58,16 @@ ResetHttpTslSession (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishCheckHttpReceiveStatus (
 RedfishCheckHttpReceiveStatus (
-  IN RESTEX_INSTANCE *Instance,
-  IN EFI_STATUS HttpIoReceiveStatus
+  IN RESTEX_INSTANCE  *Instance,
+  IN EFI_STATUS       HttpIoReceiveStatus
   )
   )
 {
 {
-  EFI_STATUS Status;
-  EFI_STATUS ReturnStatus;
+  EFI_STATUS  Status;
+  EFI_STATUS  ReturnStatus;
 
 
-  if (!EFI_ERROR (HttpIoReceiveStatus)){
+  if (!EFI_ERROR (HttpIoReceiveStatus)) {
     ReturnStatus = EFI_SUCCESS;
     ReturnStatus = EFI_SUCCESS;
-  } else if (EFI_ERROR (HttpIoReceiveStatus) && HttpIoReceiveStatus != EFI_CONNECTION_FIN) {
+  } else if (EFI_ERROR (HttpIoReceiveStatus) && (HttpIoReceiveStatus != EFI_CONNECTION_FIN)) {
     if ((Instance->Flags & RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY) == 0) {
     if ((Instance->Flags & RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY) == 0) {
       DEBUG ((DEBUG_ERROR, "%a: TCP error, reset HTTP session.\n", __FUNCTION__));
       DEBUG ((DEBUG_ERROR, "%a: TCP error, reset HTTP session.\n", __FUNCTION__));
       Instance->Flags |= RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY;
       Instance->Flags |= RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY;
@@ -80,24 +83,27 @@ RedfishCheckHttpReceiveStatus (
       ReturnStatus = EFI_DEVICE_ERROR;
       ReturnStatus = EFI_DEVICE_ERROR;
     }
     }
   } else {
   } else {
-      if (HttpIoReceiveStatus == EFI_CONNECTION_FIN) {
-        if ((Instance->Flags & RESTEX_INSTANCE_FLAGS_TLS_RETRY) != 0) {
-          DEBUG ((DEBUG_ERROR, "%a: REST_EX Send and receive fail even with a new TLS session.\n", __FUNCTION__));
-          ReturnStatus = EFI_DEVICE_ERROR;
-        }
-        Instance->Flags |= RESTEX_INSTANCE_FLAGS_TLS_RETRY;
-        Status = ResetHttpTslSession (Instance);
-        if (EFI_ERROR (Status)) {
-          DEBUG ((DEBUG_ERROR, "%a: Reset HTTP instance fail.\n", __FUNCTION__));
-          ReturnStatus = EFI_DEVICE_ERROR;
-        }
-        return EFI_NOT_READY;
+    if (HttpIoReceiveStatus == EFI_CONNECTION_FIN) {
+      if ((Instance->Flags & RESTEX_INSTANCE_FLAGS_TLS_RETRY) != 0) {
+        DEBUG ((DEBUG_ERROR, "%a: REST_EX Send and receive fail even with a new TLS session.\n", __FUNCTION__));
+        ReturnStatus = EFI_DEVICE_ERROR;
+      }
+
+      Instance->Flags |= RESTEX_INSTANCE_FLAGS_TLS_RETRY;
+      Status           = ResetHttpTslSession (Instance);
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_ERROR, "%a: Reset HTTP instance fail.\n", __FUNCTION__));
+        ReturnStatus = EFI_DEVICE_ERROR;
       }
       }
+
+      return EFI_NOT_READY;
+    }
   }
   }
+
   //
   //
   // Clean TLS new session retry and error try flags.
   // Clean TLS new session retry and error try flags.
   //
   //
-  Instance->Flags &= ~ (RESTEX_INSTANCE_FLAGS_TLS_RETRY | RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY);
+  Instance->Flags &= ~(RESTEX_INSTANCE_FLAGS_TLS_RETRY | RESTEX_INSTANCE_FLAGS_TCP_ERROR_RETRY);
   return ReturnStatus;
   return ReturnStatus;
 }
 }
 
 
@@ -124,15 +130,15 @@ RedfishCheckHttpReceiveStatus (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishHttpAddExpectation (
 RedfishHttpAddExpectation (
-  IN EFI_REST_EX_PROTOCOL   *This,
-  IN EFI_HTTP_MESSAGE       *RequestMessage,
-  IN EFI_HTTP_HEADER        **PreservedRequestHeaders,
-  IN BOOLEAN                *ItsWrite
+  IN EFI_REST_EX_PROTOCOL  *This,
+  IN EFI_HTTP_MESSAGE      *RequestMessage,
+  IN EFI_HTTP_HEADER       **PreservedRequestHeaders,
+  IN BOOLEAN               *ItsWrite
   )
   )
 {
 {
-  EFI_HTTP_HEADER *NewHeaders;
+  EFI_HTTP_HEADER  *NewHeaders;
 
 
-  if (This == NULL || RequestMessage == NULL) {
+  if ((This == NULL) || (RequestMessage == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
@@ -142,16 +148,17 @@ RedfishHttpAddExpectation (
   }
   }
 
 
   if ((RequestMessage->Data.Request->Method != HttpMethodPut) && (RequestMessage->Data.Request->Method != HttpMethodPost) &&
   if ((RequestMessage->Data.Request->Method != HttpMethodPut) && (RequestMessage->Data.Request->Method != HttpMethodPost) &&
-      (RequestMessage->Data.Request->Method != HttpMethodPatch)) {
+      (RequestMessage->Data.Request->Method != HttpMethodPatch))
+  {
     return EFI_SUCCESS;
     return EFI_SUCCESS;
   }
   }
+
   *ItsWrite = TRUE;
   *ItsWrite = TRUE;
 
 
-  NewHeaders = AllocateZeroPool((RequestMessage->HeaderCount + 1) * sizeof(EFI_HTTP_HEADER));
-  CopyMem ((VOID*)NewHeaders, (VOID *)RequestMessage->Headers, RequestMessage->HeaderCount * sizeof (EFI_HTTP_HEADER));
+  NewHeaders = AllocateZeroPool ((RequestMessage->HeaderCount + 1) * sizeof (EFI_HTTP_HEADER));
+  CopyMem ((VOID *)NewHeaders, (VOID *)RequestMessage->Headers, RequestMessage->HeaderCount * sizeof (EFI_HTTP_HEADER));
   HttpSetFieldNameAndValue (NewHeaders + RequestMessage->HeaderCount, HTTP_HEADER_EXPECT, HTTP_EXPECT_100_CONTINUE);
   HttpSetFieldNameAndValue (NewHeaders + RequestMessage->HeaderCount, HTTP_HEADER_EXPECT, HTTP_EXPECT_100_CONTINUE);
-  RequestMessage->HeaderCount ++;
+  RequestMessage->HeaderCount++;
   RequestMessage->Headers = NewHeaders;
   RequestMessage->Headers = NewHeaders;
   return EFI_SUCCESS;
   return EFI_SUCCESS;
 }
 }
-

+ 34 - 34
RedfishPkg/RedfishRestExDxe/RedfishRestExInternal.h

@@ -49,8 +49,8 @@
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishCheckHttpReceiveStatus (
 RedfishCheckHttpReceiveStatus (
-  IN RESTEX_INSTANCE *Instance,
-  IN EFI_STATUS HttpIoReceiveStatus
+  IN RESTEX_INSTANCE  *Instance,
+  IN EFI_STATUS       HttpIoReceiveStatus
   );
   );
 
 
 /**
 /**
@@ -76,10 +76,10 @@ RedfishCheckHttpReceiveStatus (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RedfishHttpAddExpectation (
 RedfishHttpAddExpectation (
-  IN EFI_REST_EX_PROTOCOL   *This,
-  IN EFI_HTTP_MESSAGE       *RequestMessage,
-  IN EFI_HTTP_HEADER        **PreservedRequestHeaders,
-  IN BOOLEAN                *ItsWrite
+  IN EFI_REST_EX_PROTOCOL  *This,
+  IN EFI_HTTP_MESSAGE      *RequestMessage,
+  IN EFI_HTTP_HEADER       **PreservedRequestHeaders,
+  IN BOOLEAN               *ItsWrite
   );
   );
 
 
 /**
 /**
@@ -104,9 +104,9 @@ RedfishHttpAddExpectation (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExSendReceive (
 RedfishRestExSendReceive (
-  IN      EFI_REST_EX_PROTOCOL   *This,
-  IN      EFI_HTTP_MESSAGE       *RequestMessage,
-  OUT     EFI_HTTP_MESSAGE       *ResponseMessage
+  IN      EFI_REST_EX_PROTOCOL  *This,
+  IN      EFI_HTTP_MESSAGE      *RequestMessage,
+  OUT     EFI_HTTP_MESSAGE      *ResponseMessage
   );
   );
 
 
 /**
 /**
@@ -134,8 +134,8 @@ RedfishRestExSendReceive (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExGetServiceTime (
 RedfishRestExGetServiceTime (
-  IN      EFI_REST_EX_PROTOCOL   *This,
-  OUT     EFI_TIME               *Time
+  IN      EFI_REST_EX_PROTOCOL  *This,
+  OUT     EFI_TIME              *Time
   );
   );
 
 
 /**
 /**
@@ -205,8 +205,8 @@ RedfishRestExGetService (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExGetModeData (
 RedfishRestExGetModeData (
-  IN  EFI_REST_EX_PROTOCOL      *This,
-  OUT EFI_REST_EX_CONFIG_DATA   *RestExConfigData
+  IN  EFI_REST_EX_PROTOCOL     *This,
+  OUT EFI_REST_EX_CONFIG_DATA  *RestExConfigData
   );
   );
 
 
 /**
 /**
@@ -243,8 +243,8 @@ RedfishRestExGetModeData (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExConfigure (
 RedfishRestExConfigure (
-  IN  EFI_REST_EX_PROTOCOL    *This,
-  IN  EFI_REST_EX_CONFIG_DATA RestExConfigData
+  IN  EFI_REST_EX_PROTOCOL     *This,
+  IN  EFI_REST_EX_CONFIG_DATA  RestExConfigData
   );
   );
 
 
 /**
 /**
@@ -281,10 +281,10 @@ RedfishRestExConfigure (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExAyncSendReceive (
 RedfishRestExAyncSendReceive (
-  IN      EFI_REST_EX_PROTOCOL   *This,
-  IN      EFI_HTTP_MESSAGE       *RequestMessage OPTIONAL,
-  IN      EFI_REST_EX_TOKEN      *RestExToken,
-  IN      UINTN                  *TimeOutInMilliSeconds OPTIONAL
+  IN      EFI_REST_EX_PROTOCOL  *This,
+  IN      EFI_HTTP_MESSAGE      *RequestMessage OPTIONAL,
+  IN      EFI_REST_EX_TOKEN     *RestExToken,
+  IN      UINTN                 *TimeOutInMilliSeconds OPTIONAL
   );
   );
 
 
 /**
 /**
@@ -316,10 +316,11 @@ RedfishRestExAyncSendReceive (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExEventService (
 RedfishRestExEventService (
-  IN      EFI_REST_EX_PROTOCOL   *This,
-  IN      EFI_HTTP_MESSAGE       *RequestMessage OPTIONAL,
-  IN      EFI_REST_EX_TOKEN      *RestExToken
+  IN      EFI_REST_EX_PROTOCOL  *This,
+  IN      EFI_HTTP_MESSAGE      *RequestMessage OPTIONAL,
+  IN      EFI_REST_EX_TOKEN     *RestExToken
   );
   );
+
 /**
 /**
   Create a new TLS session becuase the previous on is closed.
   Create a new TLS session becuase the previous on is closed.
   status.
   status.
@@ -333,8 +334,7 @@ RedfishRestExEventService (
 EFI_STATUS
 EFI_STATUS
 ResetHttpTslSession (
 ResetHttpTslSession (
   IN   RESTEX_INSTANCE  *Instance
   IN   RESTEX_INSTANCE  *Instance
-);
-
+  );
 
 
 /**
 /**
   Callback function which provided by user to remove one node in NetDestroyLinkList process.
   Callback function which provided by user to remove one node in NetDestroyLinkList process.
@@ -349,8 +349,8 @@ ResetHttpTslSession (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RestExDestroyChildEntryInHandleBuffer (
 RestExDestroyChildEntryInHandleBuffer (
-  IN LIST_ENTRY         *Entry,
-  IN VOID               *Context
+  IN LIST_ENTRY  *Entry,
+  IN VOID        *Context
   );
   );
 
 
 /**
 /**
@@ -361,7 +361,7 @@ RestExDestroyChildEntryInHandleBuffer (
 **/
 **/
 VOID
 VOID
 RestExDestroyInstance (
 RestExDestroyInstance (
-  IN RESTEX_INSTANCE         *Instance
+  IN RESTEX_INSTANCE  *Instance
   );
   );
 
 
 /**
 /**
@@ -376,11 +376,10 @@ RestExDestroyInstance (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RestExCreateInstance (
 RestExCreateInstance (
-  IN  RESTEX_SERVICE         *Service,
-  OUT RESTEX_INSTANCE        **Instance
+  IN  RESTEX_SERVICE   *Service,
+  OUT RESTEX_INSTANCE  **Instance
   );
   );
 
 
-
 /**
 /**
   Release all the resource used the RestEx service binding instance.
   Release all the resource used the RestEx service binding instance.
 
 
@@ -389,7 +388,7 @@ RestExCreateInstance (
 **/
 **/
 VOID
 VOID
 RestExDestroyService (
 RestExDestroyService (
-  IN RESTEX_SERVICE     *RestExSb
+  IN RESTEX_SERVICE  *RestExSb
   );
   );
 
 
 /**
 /**
@@ -407,9 +406,9 @@ RestExDestroyService (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 RestExCreateService (
 RestExCreateService (
-  IN     EFI_HANDLE            Controller,
-  IN     EFI_HANDLE            Image,
-  OUT    RESTEX_SERVICE        **Service
+  IN     EFI_HANDLE      Controller,
+  IN     EFI_HANDLE      Image,
+  OUT    RESTEX_SERVICE  **Service
   );
   );
 
 
 /**
 /**
@@ -608,4 +607,5 @@ RedfishRestExServiceBindingDestroyChild (
   IN EFI_SERVICE_BINDING_PROTOCOL  *This,
   IN EFI_SERVICE_BINDING_PROTOCOL  *This,
   IN EFI_HANDLE                    ChildHandle
   IN EFI_HANDLE                    ChildHandle
   );
   );
+
 #endif
 #endif

+ 121 - 100
RedfishPkg/RedfishRestExDxe/RedfishRestExProtocol.c

@@ -45,37 +45,37 @@ EFI_REST_EX_PROTOCOL  mRedfishRestExProtocol = {
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExSendReceive (
 RedfishRestExSendReceive (
-  IN      EFI_REST_EX_PROTOCOL   *This,
-  IN      EFI_HTTP_MESSAGE       *RequestMessage,
-  OUT     EFI_HTTP_MESSAGE       *ResponseMessage
+  IN      EFI_REST_EX_PROTOCOL  *This,
+  IN      EFI_HTTP_MESSAGE      *RequestMessage,
+  OUT     EFI_HTTP_MESSAGE      *ResponseMessage
   )
   )
 {
 {
-  EFI_STATUS             Status;
-  RESTEX_INSTANCE        *Instance;
-  HTTP_IO_RESPONSE_DATA  *ResponseData;
-  UINTN                  TotalReceivedSize;
-  UINTN                  Index;
-  LIST_ENTRY             *ChunkListLink;
-  HTTP_IO_CHUNKS        *ThisChunk;
-  BOOLEAN                CopyChunkData;
-  BOOLEAN                MediaPresent;
-  EFI_HTTP_HEADER        *PreservedRequestHeaders;
-  BOOLEAN                ItsWrite;
-  BOOLEAN                IsGetChunkedTransfer;
-  HTTP_IO_SEND_CHUNK_PROCESS     SendChunkProcess;
-  HTTP_IO_SEND_NON_CHUNK_PROCESS SendNonChunkProcess;
-  EFI_HTTP_MESSAGE       ChunkTransferRequestMessage;
-
-  Status            = EFI_SUCCESS;
-  ResponseData      = NULL;
+  EFI_STATUS                      Status;
+  RESTEX_INSTANCE                 *Instance;
+  HTTP_IO_RESPONSE_DATA           *ResponseData;
+  UINTN                           TotalReceivedSize;
+  UINTN                           Index;
+  LIST_ENTRY                      *ChunkListLink;
+  HTTP_IO_CHUNKS                  *ThisChunk;
+  BOOLEAN                         CopyChunkData;
+  BOOLEAN                         MediaPresent;
+  EFI_HTTP_HEADER                 *PreservedRequestHeaders;
+  BOOLEAN                         ItsWrite;
+  BOOLEAN                         IsGetChunkedTransfer;
+  HTTP_IO_SEND_CHUNK_PROCESS      SendChunkProcess;
+  HTTP_IO_SEND_NON_CHUNK_PROCESS  SendNonChunkProcess;
+  EFI_HTTP_MESSAGE                ChunkTransferRequestMessage;
+
+  Status               = EFI_SUCCESS;
+  ResponseData         = NULL;
   IsGetChunkedTransfer = FALSE;
   IsGetChunkedTransfer = FALSE;
-  SendChunkProcess = HttpIoSendChunkNone;
-  SendNonChunkProcess = HttpIoSendNonChunkNone;
+  SendChunkProcess     = HttpIoSendChunkNone;
+  SendNonChunkProcess  = HttpIoSendNonChunkNone;
 
 
   //
   //
   // Validate the parameters
   // Validate the parameters
   //
   //
-  if ((This == NULL) || (RequestMessage == NULL) || ResponseMessage == NULL) {
+  if ((This == NULL) || (RequestMessage == NULL) || (ResponseMessage == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
@@ -101,17 +101,19 @@ RedfishRestExSendReceive (
   if (EFI_ERROR (Status)) {
   if (EFI_ERROR (Status)) {
     return Status;
     return Status;
   }
   }
+
   if (ItsWrite == TRUE) {
   if (ItsWrite == TRUE) {
     if (RequestMessage->BodyLength > HTTP_IO_MAX_SEND_PAYLOAD) {
     if (RequestMessage->BodyLength > HTTP_IO_MAX_SEND_PAYLOAD) {
       //
       //
       // Send chunked transfer.
       // Send chunked transfer.
       //
       //
-      SendChunkProcess ++;
+      SendChunkProcess++;
       CopyMem ((VOID *)&ChunkTransferRequestMessage, (VOID *)RequestMessage, sizeof (EFI_HTTP_MESSAGE));
       CopyMem ((VOID *)&ChunkTransferRequestMessage, (VOID *)RequestMessage, sizeof (EFI_HTTP_MESSAGE));
     } else {
     } else {
-      SendNonChunkProcess ++;
+      SendNonChunkProcess++;
     }
     }
   }
   }
+
 ReSendRequest:;
 ReSendRequest:;
   //
   //
   // Send out the request to REST service.
   // Send out the request to REST service.
@@ -127,7 +129,7 @@ ReSendRequest:;
       // following request message body using chunk transfer.
       // following request message body using chunk transfer.
       //
       //
       do {
       do {
-        Status = HttpIoSendChunkedTransfer(
+        Status = HttpIoSendChunkedTransfer (
                    &(Instance->HttpIo),
                    &(Instance->HttpIo),
                    &SendChunkProcess,
                    &SendChunkProcess,
                    &ChunkTransferRequestMessage
                    &ChunkTransferRequestMessage
@@ -141,20 +143,20 @@ ReSendRequest:;
       // This is the non-chunk transfer, send request header first and then
       // This is the non-chunk transfer, send request header first and then
       // handle the following request message body using chunk transfer.
       // handle the following request message body using chunk transfer.
       //
       //
-      Status = HttpIoSendRequest(
+      Status = HttpIoSendRequest (
                  &(Instance->HttpIo),
                  &(Instance->HttpIo),
-                 (SendNonChunkProcess == HttpIoSendNonChunkContent)? NULL: RequestMessage->Data.Request,
-                 (SendNonChunkProcess == HttpIoSendNonChunkContent)? 0: RequestMessage->HeaderCount,
-                 (SendNonChunkProcess == HttpIoSendNonChunkContent)? NULL: RequestMessage->Headers,
-                 (SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent)? 0: RequestMessage->BodyLength,
-                 (SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent)? NULL: RequestMessage->Body
+                 (SendNonChunkProcess == HttpIoSendNonChunkContent) ? NULL : RequestMessage->Data.Request,
+                 (SendNonChunkProcess == HttpIoSendNonChunkContent) ? 0 : RequestMessage->HeaderCount,
+                 (SendNonChunkProcess == HttpIoSendNonChunkContent) ? NULL : RequestMessage->Headers,
+                 (SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent) ? 0 : RequestMessage->BodyLength,
+                 (SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent) ? NULL : RequestMessage->Body
                  );
                  );
     }
     }
   } else {
   } else {
     //
     //
     // This is read from URI.
     // This is read from URI.
     //
     //
-    Status = HttpIoSendRequest(
+    Status = HttpIoSendRequest (
                &(Instance->HttpIo),
                &(Instance->HttpIo),
                RequestMessage->Data.Request,
                RequestMessage->Data.Request,
                RequestMessage->HeaderCount,
                RequestMessage->HeaderCount,
@@ -163,6 +165,7 @@ ReSendRequest:;
                RequestMessage->Body
                RequestMessage->Body
                );
                );
   }
   }
+
   if (EFI_ERROR (Status)) {
   if (EFI_ERROR (Status)) {
     goto ON_EXIT;
     goto ON_EXIT;
   }
   }
@@ -173,20 +176,20 @@ ReSendRequest:;
   // Clean the previous buffers and all of them will be allocated later according to the actual situation.
   // Clean the previous buffers and all of them will be allocated later according to the actual situation.
   //
   //
   if (ResponseMessage->Data.Response != NULL) {
   if (ResponseMessage->Data.Response != NULL) {
-    FreePool(ResponseMessage->Data.Response);
+    FreePool (ResponseMessage->Data.Response);
     ResponseMessage->Data.Response = NULL;
     ResponseMessage->Data.Response = NULL;
   }
   }
 
 
   ResponseMessage->BodyLength = 0;
   ResponseMessage->BodyLength = 0;
   if (ResponseMessage->Body != NULL) {
   if (ResponseMessage->Body != NULL) {
-    FreePool(ResponseMessage->Body);
+    FreePool (ResponseMessage->Body);
     ResponseMessage->Body = NULL;
     ResponseMessage->Body = NULL;
   }
   }
 
 
   //
   //
   // Use zero BodyLength to only receive the response headers.
   // Use zero BodyLength to only receive the response headers.
   //
   //
-  ResponseData = AllocateZeroPool (sizeof(HTTP_IO_RESPONSE_DATA));
+  ResponseData = AllocateZeroPool (sizeof (HTTP_IO_RESPONSE_DATA));
   if (ResponseData == NULL) {
   if (ResponseData == NULL) {
     Status = EFI_OUT_OF_RESOURCES;
     Status = EFI_OUT_OF_RESOURCES;
     goto ON_EXIT;
     goto ON_EXIT;
@@ -194,25 +197,26 @@ ReSendRequest:;
 
 
   DEBUG ((DEBUG_INFO, "Receiving HTTP response and headers...\n"));
   DEBUG ((DEBUG_INFO, "Receiving HTTP response and headers...\n"));
   Status = RedfishCheckHttpReceiveStatus (
   Status = RedfishCheckHttpReceiveStatus (
-                Instance,
-                HttpIoRecvResponse (
-                  &(Instance->HttpIo),
-                  TRUE,
-                  ResponseData
-                  )
+             Instance,
+             HttpIoRecvResponse (
+               &(Instance->HttpIo),
+               TRUE,
+               ResponseData
+               )
              );
              );
   if (Status == EFI_NOT_READY) {
   if (Status == EFI_NOT_READY) {
-     goto ReSendRequest;
+    goto ReSendRequest;
   } else if (Status == EFI_DEVICE_ERROR) {
   } else if (Status == EFI_DEVICE_ERROR) {
     goto ON_EXIT;
     goto ON_EXIT;
   }
   }
+
   //
   //
   // Restore the headers if it ever changed in RedfishHttpAddExpectation().
   // Restore the headers if it ever changed in RedfishHttpAddExpectation().
   //
   //
   if (RequestMessage->Headers != PreservedRequestHeaders) {
   if (RequestMessage->Headers != PreservedRequestHeaders) {
     FreePool (RequestMessage->Headers);
     FreePool (RequestMessage->Headers);
     RequestMessage->Headers = PreservedRequestHeaders; // Restore headers before we adding "Expect".
     RequestMessage->Headers = PreservedRequestHeaders; // Restore headers before we adding "Expect".
-    RequestMessage->HeaderCount --;                    // Minus one header count for "Expect".
+    RequestMessage->HeaderCount--;                     // Minus one header count for "Expect".
   }
   }
 
 
   DEBUG ((DEBUG_INFO, "HTTP Response StatusCode - %d:", ResponseData->Response.StatusCode));
   DEBUG ((DEBUG_INFO, "HTTP Response StatusCode - %d:", ResponseData->Response.StatusCode));
@@ -221,7 +225,7 @@ ReSendRequest:;
 
 
     if (SendChunkProcess == HttpIoSendChunkHeaderZeroContent) {
     if (SendChunkProcess == HttpIoSendChunkHeaderZeroContent) {
       DEBUG ((DEBUG_INFO, "This is chunk transfer, start to send all chunks.", ResponseData->Response.StatusCode));
       DEBUG ((DEBUG_INFO, "This is chunk transfer, start to send all chunks.", ResponseData->Response.StatusCode));
-      SendChunkProcess ++;
+      SendChunkProcess++;
       goto ReSendRequest;
       goto ReSendRequest;
     }
     }
   } else if (ResponseData->Response.StatusCode == HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE) {
   } else if (ResponseData->Response.StatusCode == HTTP_STATUS_413_REQUEST_ENTITY_TOO_LARGE) {
@@ -229,7 +233,7 @@ ReSendRequest:;
 
 
     Status = EFI_BAD_BUFFER_SIZE;
     Status = EFI_BAD_BUFFER_SIZE;
     goto ON_EXIT;
     goto ON_EXIT;
-  } else if (ResponseData->Response.StatusCode == HTTP_STATUS_405_METHOD_NOT_ALLOWED){
+  } else if (ResponseData->Response.StatusCode == HTTP_STATUS_405_METHOD_NOT_ALLOWED) {
     DEBUG ((DEBUG_ERROR, "HTTP_STATUS_405_METHOD_NOT_ALLOWED\n"));
     DEBUG ((DEBUG_ERROR, "HTTP_STATUS_405_METHOD_NOT_ALLOWED\n"));
 
 
     Status = EFI_ACCESS_DENIED;
     Status = EFI_ACCESS_DENIED;
@@ -238,7 +242,7 @@ ReSendRequest:;
     DEBUG ((DEBUG_INFO, "HTTP_STATUS_400_BAD_REQUEST\n"));
     DEBUG ((DEBUG_INFO, "HTTP_STATUS_400_BAD_REQUEST\n"));
     if (SendChunkProcess == HttpIoSendChunkHeaderZeroContent) {
     if (SendChunkProcess == HttpIoSendChunkHeaderZeroContent) {
       DEBUG ((DEBUG_INFO, "Bad request may caused by zero length chunk. Try to send all chunks...\n"));
       DEBUG ((DEBUG_INFO, "Bad request may caused by zero length chunk. Try to send all chunks...\n"));
-      SendChunkProcess ++;
+      SendChunkProcess++;
       goto ReSendRequest;
       goto ReSendRequest;
     }
     }
   } else if (ResponseData->Response.StatusCode == HTTP_STATUS_100_CONTINUE) {
   } else if (ResponseData->Response.StatusCode == HTTP_STATUS_100_CONTINUE) {
@@ -248,22 +252,25 @@ ReSendRequest:;
       // We get HTTP_STATUS_100_CONTINUE to send the body using chunk transfer.
       // We get HTTP_STATUS_100_CONTINUE to send the body using chunk transfer.
       //
       //
       DEBUG ((DEBUG_INFO, "HTTP_STATUS_100_CONTINUE for chunk transfer...\n"));
       DEBUG ((DEBUG_INFO, "HTTP_STATUS_100_CONTINUE for chunk transfer...\n"));
-      SendChunkProcess ++;
+      SendChunkProcess++;
       goto ReSendRequest;
       goto ReSendRequest;
     }
     }
+
     if (SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent) {
     if (SendNonChunkProcess == HttpIoSendNonChunkHeaderZeroContent) {
       DEBUG ((DEBUG_INFO, "HTTP_STATUS_100_CONTINUE for non chunk transfer...\n"));
       DEBUG ((DEBUG_INFO, "HTTP_STATUS_100_CONTINUE for non chunk transfer...\n"));
-      SendNonChunkProcess ++;
+      SendNonChunkProcess++;
       goto ReSendRequest;
       goto ReSendRequest;
     }
     }
+
     //
     //
     // It's the REST protocol's responsibility to handle the interim HTTP response (e.g. 100 Continue Informational),
     // It's the REST protocol's responsibility to handle the interim HTTP response (e.g. 100 Continue Informational),
     // and return the final response content to the caller.
     // and return the final response content to the caller.
     //
     //
-    if (ResponseData->Headers != NULL && ResponseData->HeaderCount != 0) {
+    if ((ResponseData->Headers != NULL) && (ResponseData->HeaderCount != 0)) {
       FreePool (ResponseData->Headers);
       FreePool (ResponseData->Headers);
     }
     }
-    ZeroMem (ResponseData, sizeof(HTTP_IO_RESPONSE_DATA));
+
+    ZeroMem (ResponseData, sizeof (HTTP_IO_RESPONSE_DATA));
     Status = HttpIoRecvResponse (
     Status = HttpIoRecvResponse (
                &(Instance->HttpIo),
                &(Instance->HttpIo),
                TRUE,
                TRUE,
@@ -288,15 +295,15 @@ ReSendRequest:;
   }
   }
 
 
   ResponseMessage->Data.Response->StatusCode = ResponseData->Response.StatusCode;
   ResponseMessage->Data.Response->StatusCode = ResponseData->Response.StatusCode;
-  ResponseMessage->HeaderCount = ResponseData->HeaderCount;
-  ResponseMessage->Headers = ResponseData->Headers;
+  ResponseMessage->HeaderCount               = ResponseData->HeaderCount;
+  ResponseMessage->Headers                   = ResponseData->Headers;
 
 
   //
   //
   // Get response message body.
   // Get response message body.
   //
   //
   if (ResponseMessage->HeaderCount > 0) {
   if (ResponseMessage->HeaderCount > 0) {
     Status = HttpIoGetContentLength (ResponseMessage->HeaderCount, ResponseMessage->Headers, &ResponseMessage->BodyLength);
     Status = HttpIoGetContentLength (ResponseMessage->HeaderCount, ResponseMessage->Headers, &ResponseMessage->BodyLength);
-    if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) {
+    if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
       goto ON_EXIT;
       goto ON_EXIT;
     }
     }
 
 
@@ -315,46 +322,52 @@ ReSendRequest:;
                  &ChunkListLink,
                  &ChunkListLink,
                  &ResponseMessage->BodyLength
                  &ResponseMessage->BodyLength
                  );
                  );
-      if (EFI_ERROR (Status) && Status != EFI_NOT_FOUND) {
+      if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
         goto ON_EXIT;
         goto ON_EXIT;
       }
       }
-      if (Status == EFI_SUCCESS &&
-          ChunkListLink != NULL &&
-          !IsListEmpty(ChunkListLink) &&
-          ResponseMessage->BodyLength != 0) {
+
+      if ((Status == EFI_SUCCESS) &&
+          (ChunkListLink != NULL) &&
+          !IsListEmpty (ChunkListLink) &&
+          (ResponseMessage->BodyLength != 0))
+      {
         IsGetChunkedTransfer = TRUE;
         IsGetChunkedTransfer = TRUE;
         //
         //
         // Copy data to Message body.
         // Copy data to Message body.
         //
         //
-        CopyChunkData = TRUE;
+        CopyChunkData         = TRUE;
         ResponseMessage->Body = AllocateZeroPool (ResponseMessage->BodyLength);
         ResponseMessage->Body = AllocateZeroPool (ResponseMessage->BodyLength);
         if (ResponseMessage->Body == NULL) {
         if (ResponseMessage->Body == NULL) {
-          Status = EFI_OUT_OF_RESOURCES;
+          Status        = EFI_OUT_OF_RESOURCES;
           CopyChunkData = FALSE;
           CopyChunkData = FALSE;
         }
         }
+
         Index = 0;
         Index = 0;
-        while (!IsListEmpty(ChunkListLink)) {
+        while (!IsListEmpty (ChunkListLink)) {
           ThisChunk = (HTTP_IO_CHUNKS *)GetFirstNode (ChunkListLink);
           ThisChunk = (HTTP_IO_CHUNKS *)GetFirstNode (ChunkListLink);
           if (CopyChunkData) {
           if (CopyChunkData) {
-            CopyMem(((UINT8 *)ResponseMessage->Body + Index), (UINT8 *)ThisChunk->Data, ThisChunk->Length);
+            CopyMem (((UINT8 *)ResponseMessage->Body + Index), (UINT8 *)ThisChunk->Data, ThisChunk->Length);
             Index += ThisChunk->Length;
             Index += ThisChunk->Length;
           }
           }
+
           RemoveEntryList (&ThisChunk->NextChunk);
           RemoveEntryList (&ThisChunk->NextChunk);
           FreePool ((VOID *)ThisChunk->Data);
           FreePool ((VOID *)ThisChunk->Data);
           FreePool ((VOID *)ThisChunk);
           FreePool ((VOID *)ThisChunk);
-        };
+        }
+
         FreePool ((VOID *)ChunkListLink);
         FreePool ((VOID *)ChunkListLink);
       }
       }
     }
     }
+
     Status = EFI_SUCCESS;
     Status = EFI_SUCCESS;
   }
   }
 
 
   //
   //
   // Ready to return the Body from REST service if have any.
   // Ready to return the Body from REST service if have any.
   //
   //
-  if (ResponseMessage->BodyLength > 0 && !IsGetChunkedTransfer) {
+  if ((ResponseMessage->BodyLength > 0) && !IsGetChunkedTransfer) {
     ResponseData->HeaderCount = 0;
     ResponseData->HeaderCount = 0;
-    ResponseData->Headers = NULL;
+    ResponseData->Headers     = NULL;
 
 
     ResponseMessage->Body = AllocateZeroPool (ResponseMessage->BodyLength);
     ResponseMessage->Body = AllocateZeroPool (ResponseMessage->BodyLength);
     if (ResponseMessage->Body == NULL) {
     if (ResponseMessage->Body == NULL) {
@@ -368,20 +381,22 @@ ReSendRequest:;
     TotalReceivedSize = 0;
     TotalReceivedSize = 0;
     while (TotalReceivedSize < ResponseMessage->BodyLength) {
     while (TotalReceivedSize < ResponseMessage->BodyLength) {
       ResponseData->BodyLength = ResponseMessage->BodyLength - TotalReceivedSize;
       ResponseData->BodyLength = ResponseMessage->BodyLength - TotalReceivedSize;
-      ResponseData->Body = (CHAR8 *) ResponseMessage->Body + TotalReceivedSize;
-      Status = HttpIoRecvResponse (
-                 &(Instance->HttpIo),
-                 FALSE,
-                 ResponseData
-                 );
+      ResponseData->Body       = (CHAR8 *)ResponseMessage->Body + TotalReceivedSize;
+      Status                   = HttpIoRecvResponse (
+                                   &(Instance->HttpIo),
+                                   FALSE,
+                                   ResponseData
+                                   );
       if (EFI_ERROR (Status)) {
       if (EFI_ERROR (Status)) {
         goto ON_EXIT;
         goto ON_EXIT;
       }
       }
 
 
       TotalReceivedSize += ResponseData->BodyLength;
       TotalReceivedSize += ResponseData->BodyLength;
     }
     }
+
     DEBUG ((DEBUG_INFO, "Total of lengh of Response :%d\n", TotalReceivedSize));
     DEBUG ((DEBUG_INFO, "Total of lengh of Response :%d\n", TotalReceivedSize));
   }
   }
+
   DEBUG ((DEBUG_INFO, "RedfishRestExSendReceive()- EFI_STATUS: %r\n", Status));
   DEBUG ((DEBUG_INFO, "RedfishRestExSendReceive()- EFI_STATUS: %r\n", Status));
 
 
 ON_EXIT:
 ON_EXIT:
@@ -401,6 +416,7 @@ ON_EXIT:
       ResponseMessage->Body = NULL;
       ResponseMessage->Body = NULL;
     }
     }
   }
   }
+
   return Status;
   return Status;
 }
 }
 
 
@@ -429,8 +445,8 @@ ON_EXIT:
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExGetServiceTime (
 RedfishRestExGetServiceTime (
-  IN      EFI_REST_EX_PROTOCOL   *This,
-  OUT     EFI_TIME               *Time
+  IN      EFI_REST_EX_PROTOCOL  *This,
+  OUT     EFI_TIME              *Time
   )
   )
 {
 {
   return EFI_UNSUPPORTED;
   return EFI_UNSUPPORTED;
@@ -474,17 +490,17 @@ RedfishRestExGetService (
   OUT  EFI_REST_EX_SERVICE_INFO  **RestExServiceInfo
   OUT  EFI_REST_EX_SERVICE_INFO  **RestExServiceInfo
   )
   )
 {
 {
-  EFI_TPL                  OldTpl;
-  RESTEX_INSTANCE          *Instance;
-  EFI_REST_EX_SERVICE_INFO *ServiceInfo;
+  EFI_TPL                   OldTpl;
+  RESTEX_INSTANCE           *Instance;
+  EFI_REST_EX_SERVICE_INFO  *ServiceInfo;
 
 
   ServiceInfo = NULL;
   ServiceInfo = NULL;
 
 
-  if (This == NULL || RestExServiceInfo == NULL) {
+  if ((This == NULL) || (RestExServiceInfo == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
-  OldTpl   = gBS->RaiseTPL (TPL_CALLBACK);
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
 
 
   Instance = RESTEX_INSTANCE_FROM_THIS (This);
   Instance = RESTEX_INSTANCE_FROM_THIS (This);
 
 
@@ -531,8 +547,8 @@ RedfishRestExGetService (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExGetModeData (
 RedfishRestExGetModeData (
-  IN  EFI_REST_EX_PROTOCOL      *This,
-  OUT EFI_REST_EX_CONFIG_DATA   *RestExConfigData
+  IN  EFI_REST_EX_PROTOCOL     *This,
+  OUT EFI_REST_EX_CONFIG_DATA  *RestExConfigData
   )
   )
 {
 {
   return EFI_UNSUPPORTED;
   return EFI_UNSUPPORTED;
@@ -572,15 +588,15 @@ RedfishRestExGetModeData (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExConfigure (
 RedfishRestExConfigure (
-  IN  EFI_REST_EX_PROTOCOL    *This,
-  IN  EFI_REST_EX_CONFIG_DATA RestExConfigData
+  IN  EFI_REST_EX_PROTOCOL     *This,
+  IN  EFI_REST_EX_CONFIG_DATA  RestExConfigData
   )
   )
 {
 {
-  EFI_STATUS               Status;
-  EFI_TPL                  OldTpl;
-  RESTEX_INSTANCE          *Instance;
+  EFI_STATUS       Status;
+  EFI_TPL          OldTpl;
+  RESTEX_INSTANCE  *Instance;
 
 
-  EFI_HTTP_CONFIG_DATA     *HttpConfigData;
+  EFI_HTTP_CONFIG_DATA  *HttpConfigData;
 
 
   Status         = EFI_SUCCESS;
   Status         = EFI_SUCCESS;
   HttpConfigData = NULL;
   HttpConfigData = NULL;
@@ -589,7 +605,7 @@ RedfishRestExConfigure (
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
-  OldTpl   = gBS->RaiseTPL (TPL_CALLBACK);
+  OldTpl = gBS->RaiseTPL (TPL_CALLBACK);
 
 
   Instance = RESTEX_INSTANCE_FROM_THIS (This);
   Instance = RESTEX_INSTANCE_FROM_THIS (This);
 
 
@@ -601,19 +617,21 @@ RedfishRestExConfigure (
 
 
     if (Instance->ConfigData != NULL) {
     if (Instance->ConfigData != NULL) {
       if (((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node != NULL) {
       if (((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node != NULL) {
-        FreePool(((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node);
+        FreePool (((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node);
       }
       }
-      FreePool(Instance->ConfigData);
+
+      FreePool (Instance->ConfigData);
       Instance->ConfigData = NULL;
       Instance->ConfigData = NULL;
     }
     }
 
 
     Instance->State = RESTEX_STATE_UNCONFIGED;
     Instance->State = RESTEX_STATE_UNCONFIGED;
   } else {
   } else {
     HttpConfigData = &((EFI_REST_EX_HTTP_CONFIG_DATA *)RestExConfigData)->HttpConfigData;
     HttpConfigData = &((EFI_REST_EX_HTTP_CONFIG_DATA *)RestExConfigData)->HttpConfigData;
-    Status = Instance->HttpIo.Http->Configure (Instance->HttpIo.Http, HttpConfigData);
+    Status         = Instance->HttpIo.Http->Configure (Instance->HttpIo.Http, HttpConfigData);
     if (EFI_ERROR (Status)) {
     if (EFI_ERROR (Status)) {
       goto ON_EXIT;
       goto ON_EXIT;
     }
     }
+
     Instance->HttpIo.Timeout = ((EFI_REST_EX_HTTP_CONFIG_DATA *)RestExConfigData)->SendReceiveTimeout;
     Instance->HttpIo.Timeout = ((EFI_REST_EX_HTTP_CONFIG_DATA *)RestExConfigData)->SendReceiveTimeout;
 
 
     Instance->ConfigData = AllocateZeroPool (sizeof (EFI_REST_EX_HTTP_CONFIG_DATA));
     Instance->ConfigData = AllocateZeroPool (sizeof (EFI_REST_EX_HTTP_CONFIG_DATA));
@@ -621,6 +639,7 @@ RedfishRestExConfigure (
       Status = EFI_OUT_OF_RESOURCES;
       Status = EFI_OUT_OF_RESOURCES;
       goto ON_EXIT;
       goto ON_EXIT;
     }
     }
+
     CopyMem (Instance->ConfigData, RestExConfigData, sizeof (EFI_REST_EX_HTTP_CONFIG_DATA));
     CopyMem (Instance->ConfigData, RestExConfigData, sizeof (EFI_REST_EX_HTTP_CONFIG_DATA));
     if (HttpConfigData->LocalAddressIsIPv6 == TRUE) {
     if (HttpConfigData->LocalAddressIsIPv6 == TRUE) {
       ((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv6Node = AllocateZeroPool (sizeof (EFI_HTTPv6_ACCESS_POINT));
       ((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv6Node = AllocateZeroPool (sizeof (EFI_HTTPv6_ACCESS_POINT));
@@ -628,6 +647,7 @@ RedfishRestExConfigure (
         Status = EFI_OUT_OF_RESOURCES;
         Status = EFI_OUT_OF_RESOURCES;
         goto ON_EXIT;
         goto ON_EXIT;
       }
       }
+
       CopyMem (
       CopyMem (
         ((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv6Node,
         ((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv6Node,
         HttpConfigData->AccessPoint.IPv6Node,
         HttpConfigData->AccessPoint.IPv6Node,
@@ -639,12 +659,14 @@ RedfishRestExConfigure (
         Status = EFI_OUT_OF_RESOURCES;
         Status = EFI_OUT_OF_RESOURCES;
         goto ON_EXIT;
         goto ON_EXIT;
       }
       }
+
       CopyMem (
       CopyMem (
         ((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node,
         ((EFI_REST_EX_HTTP_CONFIG_DATA *)Instance->ConfigData)->HttpConfigData.AccessPoint.IPv4Node,
         HttpConfigData->AccessPoint.IPv4Node,
         HttpConfigData->AccessPoint.IPv4Node,
         sizeof (EFI_HTTPv4_ACCESS_POINT)
         sizeof (EFI_HTTPv4_ACCESS_POINT)
         );
         );
     }
     }
+
     Instance->State = RESTEX_STATE_CONFIGED;
     Instance->State = RESTEX_STATE_CONFIGED;
   }
   }
 
 
@@ -687,10 +709,10 @@ ON_EXIT:
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExAyncSendReceive (
 RedfishRestExAyncSendReceive (
-  IN      EFI_REST_EX_PROTOCOL   *This,
-  IN      EFI_HTTP_MESSAGE       *RequestMessage OPTIONAL,
-  IN      EFI_REST_EX_TOKEN      *RestExToken,
-  IN      UINTN                  *TimeOutInMilliSeconds OPTIONAL
+  IN      EFI_REST_EX_PROTOCOL  *This,
+  IN      EFI_HTTP_MESSAGE      *RequestMessage OPTIONAL,
+  IN      EFI_REST_EX_TOKEN     *RestExToken,
+  IN      UINTN                 *TimeOutInMilliSeconds OPTIONAL
   )
   )
 {
 {
   return EFI_UNSUPPORTED;
   return EFI_UNSUPPORTED;
@@ -725,11 +747,10 @@ RedfishRestExAyncSendReceive (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RedfishRestExEventService (
 RedfishRestExEventService (
-  IN      EFI_REST_EX_PROTOCOL   *This,
-  IN      EFI_HTTP_MESSAGE       *RequestMessage OPTIONAL,
-  IN      EFI_REST_EX_TOKEN      *RestExToken
+  IN      EFI_REST_EX_PROTOCOL  *This,
+  IN      EFI_HTTP_MESSAGE      *RequestMessage OPTIONAL,
+  IN      EFI_REST_EX_TOKEN     *RestExToken
   )
   )
 {
 {
   return EFI_UNSUPPORTED;
   return EFI_UNSUPPORTED;
 }
 }
-

+ 246 - 196
RedfishPkg/RestJsonStructureDxe/RestJsonStructureDxe.c

@@ -13,8 +13,8 @@
 #include <Protocol/RestJsonStructure.h>
 #include <Protocol/RestJsonStructure.h>
 #include "RestJsonStructureInternal.h"
 #include "RestJsonStructureInternal.h"
 
 
-LIST_ENTRY mRestJsonStructureList;
-EFI_HANDLE mProtocolHandle;
+LIST_ENTRY  mRestJsonStructureList;
+EFI_HANDLE  mProtocolHandle;
 
 
 /**
 /**
   This function registers Restful resource interpreter for the
   This function registers Restful resource interpreter for the
@@ -34,63 +34,66 @@ EFI_HANDLE mProtocolHandle;
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RestJsonStructureRegister (
 RestJsonStructureRegister (
-  IN EFI_REST_JSON_STRUCTURE_PROTOCOL       *This,
-  IN EFI_REST_JSON_STRUCTURE_SUPPORTED      *JsonStructureSupported,
-  IN EFI_REST_JSON_STRUCTURE_TO_STRUCTURE   ToStructure,
-  IN EFI_REST_JSON_STRUCTURE_TO_JSON        ToJson,
-  IN EFI_REST_JSON_STRUCTURE_DESTORY_STRUCTURE DestroyStructure
-)
+  IN EFI_REST_JSON_STRUCTURE_PROTOCOL           *This,
+  IN EFI_REST_JSON_STRUCTURE_SUPPORTED          *JsonStructureSupported,
+  IN EFI_REST_JSON_STRUCTURE_TO_STRUCTURE       ToStructure,
+  IN EFI_REST_JSON_STRUCTURE_TO_JSON            ToJson,
+  IN EFI_REST_JSON_STRUCTURE_DESTORY_STRUCTURE  DestroyStructure
+  )
 {
 {
-  UINTN NumberOfNS;
-  UINTN Index;
-  LIST_ENTRY *ThisList;
-  REST_JSON_STRUCTURE_INSTANCE *Instance;
-  EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *CloneSupportedInterpId;
-  EFI_REST_JSON_STRUCTURE_SUPPORTED *ThisSupportedInterp;
-
-  if (This == NULL ||
-      ToStructure == NULL ||
-      ToJson == NULL ||
-      DestroyStructure == NULL ||
-      JsonStructureSupported == NULL
-      ) {
+  UINTN                                   NumberOfNS;
+  UINTN                                   Index;
+  LIST_ENTRY                              *ThisList;
+  REST_JSON_STRUCTURE_INSTANCE            *Instance;
+  EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER  *CloneSupportedInterpId;
+  EFI_REST_JSON_STRUCTURE_SUPPORTED       *ThisSupportedInterp;
+
+  if ((This == NULL) ||
+      (ToStructure == NULL) ||
+      (ToJson == NULL) ||
+      (DestroyStructure == NULL) ||
+      (JsonStructureSupported == NULL)
+      )
+  {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
   //
   //
   // Check how many name space interpreter can interpret.
   // Check how many name space interpreter can interpret.
   //
   //
-  ThisList = &JsonStructureSupported->NextSupportedRsrcInterp;
+  ThisList   = &JsonStructureSupported->NextSupportedRsrcInterp;
   NumberOfNS = 1;
   NumberOfNS = 1;
   while (TRUE) {
   while (TRUE) {
     if (ThisList->ForwardLink == &JsonStructureSupported->NextSupportedRsrcInterp) {
     if (ThisList->ForwardLink == &JsonStructureSupported->NextSupportedRsrcInterp) {
       break;
       break;
     } else {
     } else {
       ThisList = ThisList->ForwardLink;
       ThisList = ThisList->ForwardLink;
-      NumberOfNS ++;
+      NumberOfNS++;
     }
     }
-  };
+  }
 
 
   Instance =
   Instance =
     (REST_JSON_STRUCTURE_INSTANCE *)AllocateZeroPool (sizeof (REST_JSON_STRUCTURE_INSTANCE) + NumberOfNS * sizeof (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER));
     (REST_JSON_STRUCTURE_INSTANCE *)AllocateZeroPool (sizeof (REST_JSON_STRUCTURE_INSTANCE) + NumberOfNS * sizeof (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER));
   if (Instance == NULL) {
   if (Instance == NULL) {
     return EFI_OUT_OF_RESOURCES;
     return EFI_OUT_OF_RESOURCES;
   }
   }
+
   InitializeListHead (&Instance->NextRestJsonStructureInstance);
   InitializeListHead (&Instance->NextRestJsonStructureInstance);
   Instance->NumberOfNameSpaceToConvert = NumberOfNS;
   Instance->NumberOfNameSpaceToConvert = NumberOfNS;
-  Instance->SupportedRsrcIndentifier = (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *)((REST_JSON_STRUCTURE_INSTANCE *)Instance + 1);
+  Instance->SupportedRsrcIndentifier   = (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *)((REST_JSON_STRUCTURE_INSTANCE *)Instance + 1);
   //
   //
   // Copy supported resource identifer interpreter.
   // Copy supported resource identifer interpreter.
   //
   //
   CloneSupportedInterpId = Instance->SupportedRsrcIndentifier;
   CloneSupportedInterpId = Instance->SupportedRsrcIndentifier;
-  ThisSupportedInterp = JsonStructureSupported;
-  for (Index = 0; Index < NumberOfNS; Index ++) {
+  ThisSupportedInterp    = JsonStructureSupported;
+  for (Index = 0; Index < NumberOfNS; Index++) {
     CopyMem ((VOID *)CloneSupportedInterpId, (VOID *)&ThisSupportedInterp->RestResourceInterp, sizeof (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER));
     CopyMem ((VOID *)CloneSupportedInterpId, (VOID *)&ThisSupportedInterp->RestResourceInterp, sizeof (EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER));
     ThisSupportedInterp = (EFI_REST_JSON_STRUCTURE_SUPPORTED *)ThisSupportedInterp->NextSupportedRsrcInterp.ForwardLink;
     ThisSupportedInterp = (EFI_REST_JSON_STRUCTURE_SUPPORTED *)ThisSupportedInterp->NextSupportedRsrcInterp.ForwardLink;
-    CloneSupportedInterpId ++;
+    CloneSupportedInterpId++;
   }
   }
-  Instance->JsonToStructure = ToStructure;
-  Instance->StructureToJson = ToJson;
+
+  Instance->JsonToStructure  = ToStructure;
+  Instance->StructureToJson  = ToJson;
   Instance->DestroyStructure = DestroyStructure;
   Instance->DestroyStructure = DestroyStructure;
   InsertTailList (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
   InsertTailList (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
   return EFI_SUCCESS;
   return EFI_SUCCESS;
@@ -111,23 +114,24 @@ RestJsonStructureRegister (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 InterpreterInstanceToStruct (
 InterpreterInstanceToStruct (
-  IN EFI_REST_JSON_STRUCTURE_PROTOCOL         *This,
-  IN REST_JSON_STRUCTURE_INSTANCE             *InterpreterInstance,
-  IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER   *RsrcTypeIdentifier OPTIONAL,
-  IN CHAR8                                    *ResourceRaw,
-  OUT EFI_REST_JSON_STRUCTURE_HEADER          **RestJSonHeader
- )
+  IN EFI_REST_JSON_STRUCTURE_PROTOCOL        *This,
+  IN REST_JSON_STRUCTURE_INSTANCE            *InterpreterInstance,
+  IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER  *RsrcTypeIdentifier OPTIONAL,
+  IN CHAR8                                   *ResourceRaw,
+  OUT EFI_REST_JSON_STRUCTURE_HEADER         **RestJSonHeader
+  )
 {
 {
-  UINTN Index;
-  EFI_STATUS Status;
-  EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId;
-
-  if (This == NULL ||
-      InterpreterInstance == NULL ||
-      ResourceRaw == NULL ||
-      RestJSonHeader == NULL
-      ) {
-      return EFI_INVALID_PARAMETER;
+  UINTN                                   Index;
+  EFI_STATUS                              Status;
+  EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER  *ThisSupportedRsrcTypeId;
+
+  if ((This == NULL) ||
+      (InterpreterInstance == NULL) ||
+      (ResourceRaw == NULL) ||
+      (RestJSonHeader == NULL)
+      )
+  {
+    return EFI_INVALID_PARAMETER;
   }
   }
 
 
   Status = EFI_UNSUPPORTED;
   Status = EFI_UNSUPPORTED;
@@ -137,62 +141,72 @@ InterpreterInstanceToStruct (
     // Interpreter may recognize this resource.
     // Interpreter may recognize this resource.
     //
     //
     Status = InterpreterInstance->JsonToStructure (
     Status = InterpreterInstance->JsonToStructure (
-                This,
-                NULL,
-                ResourceRaw,
-                RestJSonHeader
-                );
+                                    This,
+                                    NULL,
+                                    ResourceRaw,
+                                    RestJSonHeader
+                                    );
   } else {
   } else {
     //
     //
     // Check if the namesapce and version is supported by this interpreter.
     // Check if the namesapce and version is supported by this interpreter.
     //
     //
     ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier;
     ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier;
-    for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index ++){
+    for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index++) {
       if (AsciiStrCmp (
       if (AsciiStrCmp (
             RsrcTypeIdentifier->NameSpace.ResourceTypeName,
             RsrcTypeIdentifier->NameSpace.ResourceTypeName,
-            ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName) == 0){
+            ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName
+            ) == 0)
+      {
         if ((RsrcTypeIdentifier->NameSpace.MajorVersion == NULL) &&
         if ((RsrcTypeIdentifier->NameSpace.MajorVersion == NULL) &&
             (RsrcTypeIdentifier->NameSpace.MinorVersion == NULL) &&
             (RsrcTypeIdentifier->NameSpace.MinorVersion == NULL) &&
             (RsrcTypeIdentifier->NameSpace.ErrataVersion == NULL)
             (RsrcTypeIdentifier->NameSpace.ErrataVersion == NULL)
-            ) {
+            )
+        {
           //
           //
           // Don't check version of this resource type identifier.
           // Don't check version of this resource type identifier.
           //
           //
           Status = InterpreterInstance->JsonToStructure (
           Status = InterpreterInstance->JsonToStructure (
-                      This,
-                      RsrcTypeIdentifier,
-                      ResourceRaw,
-                      RestJSonHeader
-                      );
+                                          This,
+                                          RsrcTypeIdentifier,
+                                          ResourceRaw,
+                                          RestJSonHeader
+                                          );
           break;
           break;
         } else {
         } else {
           //
           //
           // Check version.
           // Check version.
           //
           //
           if ((AsciiStrCmp (
           if ((AsciiStrCmp (
-                RsrcTypeIdentifier->NameSpace.MajorVersion,
-                ThisSupportedRsrcTypeId->NameSpace.MajorVersion) == 0) &&
+                 RsrcTypeIdentifier->NameSpace.MajorVersion,
+                 ThisSupportedRsrcTypeId->NameSpace.MajorVersion
+                 ) == 0) &&
               (AsciiStrCmp (
               (AsciiStrCmp (
-                RsrcTypeIdentifier->NameSpace.MinorVersion,
-                ThisSupportedRsrcTypeId->NameSpace.MinorVersion) == 0) &&
+                 RsrcTypeIdentifier->NameSpace.MinorVersion,
+                 ThisSupportedRsrcTypeId->NameSpace.MinorVersion
+                 ) == 0) &&
               (AsciiStrCmp (
               (AsciiStrCmp (
-                RsrcTypeIdentifier->NameSpace.ErrataVersion,
-                ThisSupportedRsrcTypeId->NameSpace.ErrataVersion) == 0)) {
+                 RsrcTypeIdentifier->NameSpace.ErrataVersion,
+                 ThisSupportedRsrcTypeId->NameSpace.ErrataVersion
+                 ) == 0))
+          {
             Status = InterpreterInstance->JsonToStructure (
             Status = InterpreterInstance->JsonToStructure (
-                      This,
-                      RsrcTypeIdentifier,
-                      ResourceRaw,
-                      RestJSonHeader
-                      );
+                                            This,
+                                            RsrcTypeIdentifier,
+                                            ResourceRaw,
+                                            RestJSonHeader
+                                            );
             break;
             break;
           }
           }
         }
         }
       }
       }
-      ThisSupportedRsrcTypeId ++;
+
+      ThisSupportedRsrcTypeId++;
     }
     }
   }
   }
+
   return Status;
   return Status;
 }
 }
+
 /**
 /**
   This function converts JSON C structure to JSON property.
   This function converts JSON C structure to JSON property.
 
 
@@ -207,65 +221,76 @@ InterpreterInstanceToStruct (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 InterpreterEfiStructToInstance (
 InterpreterEfiStructToInstance (
-  IN EFI_REST_JSON_STRUCTURE_PROTOCOL   *This,
-  IN REST_JSON_STRUCTURE_INSTANCE       *InterpreterInstance,
-  IN EFI_REST_JSON_STRUCTURE_HEADER     *RestJSonHeader,
-  OUT CHAR8 **ResourceRaw
-)
+  IN EFI_REST_JSON_STRUCTURE_PROTOCOL  *This,
+  IN REST_JSON_STRUCTURE_INSTANCE      *InterpreterInstance,
+  IN EFI_REST_JSON_STRUCTURE_HEADER    *RestJSonHeader,
+  OUT CHAR8                            **ResourceRaw
+  )
 {
 {
-  UINTN Index;
-  EFI_STATUS Status;
-  EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId;
-  EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier;
-
-  if (This == NULL ||
-      InterpreterInstance == NULL ||
-      RestJSonHeader == NULL ||
-      ResourceRaw == NULL
-      ) {
+  UINTN                                   Index;
+  EFI_STATUS                              Status;
+  EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER  *ThisSupportedRsrcTypeId;
+  EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER  *RsrcTypeIdentifier;
+
+  if ((This == NULL) ||
+      (InterpreterInstance == NULL) ||
+      (RestJSonHeader == NULL) ||
+      (ResourceRaw == NULL)
+      )
+  {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
+
   RsrcTypeIdentifier = &RestJSonHeader->JsonRsrcIdentifier;
   RsrcTypeIdentifier = &RestJSonHeader->JsonRsrcIdentifier;
-  if (RsrcTypeIdentifier == NULL ||
-      RsrcTypeIdentifier->NameSpace.ResourceTypeName == NULL ||
-      RsrcTypeIdentifier->NameSpace.MajorVersion == NULL ||
-      RsrcTypeIdentifier->NameSpace.MinorVersion == NULL ||
-      RsrcTypeIdentifier->NameSpace.ErrataVersion == NULL
-      ) {
+  if ((RsrcTypeIdentifier == NULL) ||
+      (RsrcTypeIdentifier->NameSpace.ResourceTypeName == NULL) ||
+      (RsrcTypeIdentifier->NameSpace.MajorVersion == NULL) ||
+      (RsrcTypeIdentifier->NameSpace.MinorVersion == NULL) ||
+      (RsrcTypeIdentifier->NameSpace.ErrataVersion == NULL)
+      )
+  {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
   //
   //
   // Check if the namesapce and version is supported by this interpreter.
   // Check if the namesapce and version is supported by this interpreter.
   //
   //
-  Status = EFI_UNSUPPORTED;
+  Status                  = EFI_UNSUPPORTED;
   ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier;
   ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier;
-  for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index ++){
+  for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index++) {
     if (AsciiStrCmp (
     if (AsciiStrCmp (
           RsrcTypeIdentifier->NameSpace.ResourceTypeName,
           RsrcTypeIdentifier->NameSpace.ResourceTypeName,
-          ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName) == 0){
+          ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName
+          ) == 0)
+    {
       //
       //
       // Check version.
       // Check version.
       //
       //
       if ((AsciiStrCmp (
       if ((AsciiStrCmp (
-            RsrcTypeIdentifier->NameSpace.MajorVersion,
-            ThisSupportedRsrcTypeId->NameSpace.MajorVersion) == 0) &&
+             RsrcTypeIdentifier->NameSpace.MajorVersion,
+             ThisSupportedRsrcTypeId->NameSpace.MajorVersion
+             ) == 0) &&
           (AsciiStrCmp (
           (AsciiStrCmp (
-            RsrcTypeIdentifier->NameSpace.MinorVersion,
-            ThisSupportedRsrcTypeId->NameSpace.MinorVersion) == 0) &&
+             RsrcTypeIdentifier->NameSpace.MinorVersion,
+             ThisSupportedRsrcTypeId->NameSpace.MinorVersion
+             ) == 0) &&
           (AsciiStrCmp (
           (AsciiStrCmp (
-            RsrcTypeIdentifier->NameSpace.ErrataVersion,
-            ThisSupportedRsrcTypeId->NameSpace.ErrataVersion) == 0)) {
+             RsrcTypeIdentifier->NameSpace.ErrataVersion,
+             ThisSupportedRsrcTypeId->NameSpace.ErrataVersion
+             ) == 0))
+      {
         Status = InterpreterInstance->StructureToJson (
         Status = InterpreterInstance->StructureToJson (
-                  This,
-                  RestJSonHeader,
-                  ResourceRaw
-                  );
+                                        This,
+                                        RestJSonHeader,
+                                        ResourceRaw
+                                        );
         break;
         break;
       }
       }
     }
     }
-    ThisSupportedRsrcTypeId ++;
+
+    ThisSupportedRsrcTypeId++;
   }
   }
+
   return Status;
   return Status;
 }
 }
 
 
@@ -282,19 +307,20 @@ InterpreterEfiStructToInstance (
 **/
 **/
 EFI_STATUS
 EFI_STATUS
 InterpreterInstanceDestoryJsonStruct (
 InterpreterInstanceDestoryJsonStruct (
-  IN EFI_REST_JSON_STRUCTURE_PROTOCOL       *This,
-  IN REST_JSON_STRUCTURE_INSTANCE           *InterpreterInstance,
-  IN EFI_REST_JSON_STRUCTURE_HEADER         *RestJSonHeader
- )
+  IN EFI_REST_JSON_STRUCTURE_PROTOCOL  *This,
+  IN REST_JSON_STRUCTURE_INSTANCE      *InterpreterInstance,
+  IN EFI_REST_JSON_STRUCTURE_HEADER    *RestJSonHeader
+  )
 {
 {
-  UINTN Index;
-  EFI_STATUS Status;
-  EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *ThisSupportedRsrcTypeId;
-
-  if (This == NULL ||
-      InterpreterInstance == NULL ||
-      RestJSonHeader == NULL
-      ) {
+  UINTN                                   Index;
+  EFI_STATUS                              Status;
+  EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER  *ThisSupportedRsrcTypeId;
+
+  if ((This == NULL) ||
+      (InterpreterInstance == NULL) ||
+      (RestJSonHeader == NULL)
+      )
+  {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
@@ -303,45 +329,54 @@ InterpreterInstanceDestoryJsonStruct (
   // Check if the namesapce and version is supported by this interpreter.
   // Check if the namesapce and version is supported by this interpreter.
   //
   //
   ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier;
   ThisSupportedRsrcTypeId = InterpreterInstance->SupportedRsrcIndentifier;
-  for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index ++){
+  for (Index = 0; Index < InterpreterInstance->NumberOfNameSpaceToConvert; Index++) {
     if (AsciiStrCmp (
     if (AsciiStrCmp (
           RestJSonHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName,
           RestJSonHeader->JsonRsrcIdentifier.NameSpace.ResourceTypeName,
-          ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName) == 0) {
+          ThisSupportedRsrcTypeId->NameSpace.ResourceTypeName
+          ) == 0)
+    {
       if ((RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion == NULL) &&
       if ((RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion == NULL) &&
           (RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion == NULL) &&
           (RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion == NULL) &&
           (RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion == NULL)
           (RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion == NULL)
-          ) {
+          )
+      {
         //
         //
         // Don't check version of this resource type identifier.
         // Don't check version of this resource type identifier.
         //
         //
         Status = InterpreterInstance->DestroyStructure (
         Status = InterpreterInstance->DestroyStructure (
-                    This,
-                    RestJSonHeader
-                    );
+                                        This,
+                                        RestJSonHeader
+                                        );
         break;
         break;
       } else {
       } else {
         //
         //
         // Check version.
         // Check version.
         //
         //
         if ((AsciiStrCmp (
         if ((AsciiStrCmp (
-              RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion,
-              ThisSupportedRsrcTypeId->NameSpace.MajorVersion) == 0) &&
+               RestJSonHeader->JsonRsrcIdentifier.NameSpace.MajorVersion,
+               ThisSupportedRsrcTypeId->NameSpace.MajorVersion
+               ) == 0) &&
             (AsciiStrCmp (
             (AsciiStrCmp (
-              RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion,
-              ThisSupportedRsrcTypeId->NameSpace.MinorVersion) == 0) &&
+               RestJSonHeader->JsonRsrcIdentifier.NameSpace.MinorVersion,
+               ThisSupportedRsrcTypeId->NameSpace.MinorVersion
+               ) == 0) &&
             (AsciiStrCmp (
             (AsciiStrCmp (
-              RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion,
-              ThisSupportedRsrcTypeId->NameSpace.ErrataVersion) == 0)) {
+               RestJSonHeader->JsonRsrcIdentifier.NameSpace.ErrataVersion,
+               ThisSupportedRsrcTypeId->NameSpace.ErrataVersion
+               ) == 0))
+        {
           Status = InterpreterInstance->DestroyStructure (
           Status = InterpreterInstance->DestroyStructure (
-                    This,
-                    RestJSonHeader
-                    );
+                                          This,
+                                          RestJSonHeader
+                                          );
           break;
           break;
         }
         }
       }
       }
     }
     }
-    ThisSupportedRsrcTypeId ++;
+
+    ThisSupportedRsrcTypeId++;
   }
   }
+
   return Status;
   return Status;
 }
 }
 
 
@@ -360,44 +395,49 @@ InterpreterInstanceDestoryJsonStruct (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RestJsonStructureToStruct (
 RestJsonStructureToStruct (
-  IN EFI_REST_JSON_STRUCTURE_PROTOCOL       *This,
-  IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER *RsrcTypeIdentifier OPTIONAL,
-  IN CHAR8                                  *ResourceJsonText,
-  OUT EFI_REST_JSON_STRUCTURE_HEADER        **JsonStructure
-)
+  IN EFI_REST_JSON_STRUCTURE_PROTOCOL        *This,
+  IN EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER  *RsrcTypeIdentifier OPTIONAL,
+  IN CHAR8                                   *ResourceJsonText,
+  OUT EFI_REST_JSON_STRUCTURE_HEADER         **JsonStructure
+  )
 {
 {
-  EFI_STATUS Status;
-  REST_JSON_STRUCTURE_INSTANCE *Instance;
-
-  if (This == NULL ||
-      ResourceJsonText == NULL ||
-      JsonStructure == NULL
-    ) {
+  EFI_STATUS                    Status;
+  REST_JSON_STRUCTURE_INSTANCE  *Instance;
+
+  if ((This == NULL) ||
+      (ResourceJsonText == NULL) ||
+      (JsonStructure == NULL)
+      )
+  {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
   if (IsListEmpty (&mRestJsonStructureList)) {
   if (IsListEmpty (&mRestJsonStructureList)) {
     return EFI_UNSUPPORTED;
     return EFI_UNSUPPORTED;
   }
   }
-  Status = EFI_SUCCESS;
+
+  Status   = EFI_SUCCESS;
   Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
   Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
   while (TRUE) {
   while (TRUE) {
     Status = InterpreterInstanceToStruct (
     Status = InterpreterInstanceToStruct (
-                This,
-                Instance,
-                RsrcTypeIdentifier,
-                ResourceJsonText,
-                JsonStructure
-              );
+               This,
+               Instance,
+               RsrcTypeIdentifier,
+               ResourceJsonText,
+               JsonStructure
+               );
     if (!EFI_ERROR (Status)) {
     if (!EFI_ERROR (Status)) {
       break;
       break;
     }
     }
-    if (IsNodeAtEnd(&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
+
+    if (IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
       Status = EFI_UNSUPPORTED;
       Status = EFI_UNSUPPORTED;
       break;
       break;
     }
     }
+
     Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
     Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
-  };
+  }
+
   return Status;
   return Status;
 }
 }
 
 
@@ -415,37 +455,41 @@ RestJsonStructureToStruct (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RestJsonStructureDestroyStruct (
 RestJsonStructureDestroyStruct (
-  IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This,
-  IN EFI_REST_JSON_STRUCTURE_HEADER  *RestJSonHeader
-)
+  IN EFI_REST_JSON_STRUCTURE_PROTOCOL  *This,
+  IN EFI_REST_JSON_STRUCTURE_HEADER    *RestJSonHeader
+  )
 {
 {
-  EFI_STATUS Status;
-  REST_JSON_STRUCTURE_INSTANCE *Instance;
+  EFI_STATUS                    Status;
+  REST_JSON_STRUCTURE_INSTANCE  *Instance;
 
 
-  if (This == NULL || RestJSonHeader == NULL) {
+  if ((This == NULL) || (RestJSonHeader == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
   if (IsListEmpty (&mRestJsonStructureList)) {
   if (IsListEmpty (&mRestJsonStructureList)) {
     return EFI_UNSUPPORTED;
     return EFI_UNSUPPORTED;
   }
   }
-  Status = EFI_SUCCESS;
+
+  Status   = EFI_SUCCESS;
   Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
   Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
   while (TRUE) {
   while (TRUE) {
     Status = InterpreterInstanceDestoryJsonStruct (
     Status = InterpreterInstanceDestoryJsonStruct (
-                This,
-                Instance,
-                RestJSonHeader
-              );
+               This,
+               Instance,
+               RestJSonHeader
+               );
     if (!EFI_ERROR (Status)) {
     if (!EFI_ERROR (Status)) {
       break;
       break;
     }
     }
-    if (IsNodeAtEnd(&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
+
+    if (IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
       Status = EFI_UNSUPPORTED;
       Status = EFI_UNSUPPORTED;
       break;
       break;
     }
     }
+
     Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
     Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
-  };
+  }
+
   return Status;
   return Status;
 }
 }
 
 
@@ -463,43 +507,47 @@ RestJsonStructureDestroyStruct (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RestJsonStructureToJson (
 RestJsonStructureToJson (
-  IN EFI_REST_JSON_STRUCTURE_PROTOCOL *This,
-  IN EFI_REST_JSON_STRUCTURE_HEADER *RestJSonHeader,
-  OUT CHAR8 **ResourceRaw
-)
+  IN EFI_REST_JSON_STRUCTURE_PROTOCOL  *This,
+  IN EFI_REST_JSON_STRUCTURE_HEADER    *RestJSonHeader,
+  OUT CHAR8                            **ResourceRaw
+  )
 {
 {
-  EFI_STATUS Status;
-  REST_JSON_STRUCTURE_INSTANCE *Instance;
+  EFI_STATUS                    Status;
+  REST_JSON_STRUCTURE_INSTANCE  *Instance;
 
 
-  if (This == NULL || RestJSonHeader == NULL || ResourceRaw == NULL) {
+  if ((This == NULL) || (RestJSonHeader == NULL) || (ResourceRaw == NULL)) {
     return EFI_INVALID_PARAMETER;
     return EFI_INVALID_PARAMETER;
   }
   }
 
 
   if (IsListEmpty (&mRestJsonStructureList)) {
   if (IsListEmpty (&mRestJsonStructureList)) {
     return EFI_UNSUPPORTED;
     return EFI_UNSUPPORTED;
   }
   }
-  Status = EFI_SUCCESS;
+
+  Status   = EFI_SUCCESS;
   Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
   Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
   while (TRUE) {
   while (TRUE) {
     Status = InterpreterEfiStructToInstance (
     Status = InterpreterEfiStructToInstance (
-                This,
-                Instance,
-                RestJSonHeader,
-                ResourceRaw
-              );
+               This,
+               Instance,
+               RestJSonHeader,
+               ResourceRaw
+               );
     if (!EFI_ERROR (Status)) {
     if (!EFI_ERROR (Status)) {
       break;
       break;
     }
     }
-    if (IsNodeAtEnd(&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
+
+    if (IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
       Status = EFI_UNSUPPORTED;
       Status = EFI_UNSUPPORTED;
       break;
       break;
     }
     }
+
     Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
     Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
-  };
+  }
+
   return Status;
   return Status;
 }
 }
 
 
-EFI_REST_JSON_STRUCTURE_PROTOCOL mRestJsonStructureProtocol = {
+EFI_REST_JSON_STRUCTURE_PROTOCOL  mRestJsonStructureProtocol = {
   RestJsonStructureRegister,
   RestJsonStructureRegister,
   RestJsonStructureToStruct,
   RestJsonStructureToStruct,
   RestJsonStructureToJson,
   RestJsonStructureToJson,
@@ -522,19 +570,19 @@ RestJsonStructureEntryPoint (
   IN EFI_SYSTEM_TABLE  *SystemTable
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
   )
 {
 {
-  EFI_STATUS Status;
+  EFI_STATUS  Status;
 
 
   InitializeListHead (&mRestJsonStructureList);
   InitializeListHead (&mRestJsonStructureList);
   //
   //
   // Install the Restful Resource Interpreter Protocol.
   // Install the Restful Resource Interpreter Protocol.
   //
   //
   mProtocolHandle = NULL;
   mProtocolHandle = NULL;
-  Status = gBS->InstallProtocolInterface (
-                  &mProtocolHandle,
-                  &gEfiRestJsonStructureProtocolGuid,
-                  EFI_NATIVE_INTERFACE,
-                  (VOID *)&mRestJsonStructureProtocol
-                  );
+  Status          = gBS->InstallProtocolInterface (
+                           &mProtocolHandle,
+                           &gEfiRestJsonStructureProtocolGuid,
+                           EFI_NATIVE_INTERFACE,
+                           (VOID *)&mRestJsonStructureProtocol
+                           );
   return Status;
   return Status;
 }
 }
 
 
@@ -553,12 +601,12 @@ RestJsonStructureEntryPoint (
 EFI_STATUS
 EFI_STATUS
 EFIAPI
 EFIAPI
 RestJsonStructureUnload (
 RestJsonStructureUnload (
-  IN EFI_HANDLE ImageHandle
+  IN EFI_HANDLE  ImageHandle
   )
   )
 {
 {
-  EFI_STATUS Status;
-  REST_JSON_STRUCTURE_INSTANCE *Instance;
-  REST_JSON_STRUCTURE_INSTANCE *NextInstance;
+  EFI_STATUS                    Status;
+  REST_JSON_STRUCTURE_INSTANCE  *Instance;
+  REST_JSON_STRUCTURE_INSTANCE  *NextInstance;
 
 
   Status = gBS->UninstallProtocolInterface (
   Status = gBS->UninstallProtocolInterface (
                   mProtocolHandle,
                   mProtocolHandle,
@@ -569,15 +617,17 @@ RestJsonStructureUnload (
   if (IsListEmpty (&mRestJsonStructureList)) {
   if (IsListEmpty (&mRestJsonStructureList)) {
     return Status;
     return Status;
   }
   }
+
   //
   //
   // Free memory of REST_JSON_STRUCTURE_INSTANCE instance.
   // Free memory of REST_JSON_STRUCTURE_INSTANCE instance.
   //
   //
   Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
   Instance = (REST_JSON_STRUCTURE_INSTANCE *)GetFirstNode (&mRestJsonStructureList);
   do {
   do {
     NextInstance = NULL;
     NextInstance = NULL;
-    if (!IsNodeAtEnd(&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
+    if (!IsNodeAtEnd (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance)) {
       NextInstance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
       NextInstance = (REST_JSON_STRUCTURE_INSTANCE *)GetNextNode (&mRestJsonStructureList, &Instance->NextRestJsonStructureInstance);
     }
     }
+
     FreePool ((VOID *)Instance);
     FreePool ((VOID *)Instance);
     Instance = NextInstance;
     Instance = NextInstance;
   } while (Instance != NULL);
   } while (Instance != NULL);

+ 6 - 6
RedfishPkg/RestJsonStructureDxe/RestJsonStructureInternal.h

@@ -23,11 +23,11 @@
 /// C structure convertor.
 /// C structure convertor.
 ///
 ///
 typedef struct _REST_JSON_STRUCTURE_INSTANCE {
 typedef struct _REST_JSON_STRUCTURE_INSTANCE {
-  LIST_ENTRY NextRestJsonStructureInstance;  ///< Next convertor instance
-  UINTN NumberOfNameSpaceToConvert;          ///< Number of resource type this convertor supports.
-  EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER     *SupportedRsrcIndentifier; ///< The resource type linklist
-  EFI_REST_JSON_STRUCTURE_TO_STRUCTURE        JsonToStructure;          ///< JSON to C structure function
-  EFI_REST_JSON_STRUCTURE_TO_JSON             StructureToJson;          ///< C structure to JSON function
-  EFI_REST_JSON_STRUCTURE_DESTORY_STRUCTURE   DestroyStructure;         ///< Destory C struture function.
+  LIST_ENTRY                                   NextRestJsonStructureInstance; ///< Next convertor instance
+  UINTN                                        NumberOfNameSpaceToConvert;    ///< Number of resource type this convertor supports.
+  EFI_REST_JSON_RESOURCE_TYPE_IDENTIFIER       *SupportedRsrcIndentifier;     ///< The resource type linklist
+  EFI_REST_JSON_STRUCTURE_TO_STRUCTURE         JsonToStructure;               ///< JSON to C structure function
+  EFI_REST_JSON_STRUCTURE_TO_JSON              StructureToJson;               ///< C structure to JSON function
+  EFI_REST_JSON_STRUCTURE_DESTORY_STRUCTURE    DestroyStructure;              ///< Destory C struture function.
 } REST_JSON_STRUCTURE_INSTANCE;
 } REST_JSON_STRUCTURE_INSTANCE;
 #endif
 #endif

Some files were not shown because too many files changed in this diff