c22f52c MdeModulePkg/ReportStatusCodeLib: Avoid using AllocatePool if possible

2 files Authored by Max Knutsen 5 years ago, Committed by Liming Gao 5 years ago,
    MdeModulePkg/ReportStatusCodeLib: Avoid using AllocatePool if possible
    
    REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1114
    
    V2: simplify the code logic.
    update
    if (!mHaveExitedBootServices &&
      (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer)) {
      gBS->FreePool (StatusCodeData);
    }
    to
    if (StatusCodeData != (EFI_STATUS_CODE_DATA *) StatusCodeBuffer) {
      gBS->FreePool (StatusCodeData);
    }
    
    V3:
    And the code below into the else condition (stack buffer is not enough)
    in /DxeReportStatusCodeLib/ReportStatusCodeLib.c
    
      if (gBS == NULL || gBS->AllocatePool == NULL || gBS->FreePool == NULL) {
        return EFI_UNSUPPORTED;
      }
    
    V4:
    Refine code logic.
    
    When report status code with ExtendedData data,
    and the extended data can fit in the local static buffer,
    there is no need to use AllocatePool to hold the ExtendedData data.
    
    This patch is just to do the enhancement to avoid using AllocatePool.
    
    Cc: Star Zeng <star.zeng@intel.com>
    Cc: Jian J Wang <jian.j.wang@intel.com>
    Cc: Hao Wu <hao.a.wu@intel.com>
    Cc: Michael Turner <Michael.Turner@microsoft.com>
    Cc: Liming Gao <liming.gao@intel.com>
    Contributed-under: TianoCore Contribution Agreement 1.1
    Signed-off-by: Dandan Bi <dandan.bi@intel.com>
    Reviewed-by: Liming Gao <liming.gao@intel.com>
    Reviewed-by: Star Zeng <star.zeng@intel.com>