/* If the requested operation results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUintnAdd(IN UINTN Augend, IN UINTN Addend, OUT UINTN *Result)
/* If the requested operation results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUintnAdd(IN UINTN Augend, IN UINTN Addend, OUT UINTN *Result)
{
  RETURN_STATUS  Status;
  if (Result == NULL) {
    return RETURN_INVALID_PARAMETER;
  }
  if (sizeof (UINTN) == sizeof (UINT32)) {
    if ((UINT32)(Augend + Addend) >= Augend) {
      *Result = (Augend + Addend);
      Status  = RETURN_SUCCESS;
    } else {
      *Result = UINTN_ERROR;
      Status  = RETURN_BUFFER_TOO_SMALL;
    }
    return Status;
  }
  return SafeUint64Add ((UINT64)Augend, (UINT64)Addend, (UINT64 *)Result);
}