/* If the conversion results in an overflow or an underflow condition, then Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUint32ToUint8(IN UINT32 Operand, OUT UINT8 *Result)
/* If the conversion results in an overflow or an underflow condition, then Result is set to UINT8_ERROR and RETURN_BUFFER_TOO_SMALL is returned. */
RETURN_STATUS EFIAPI SafeUint32ToUint8(IN UINT32 Operand, OUT UINT8 *Result)
{
  RETURN_STATUS  Status;
  if (Result == NULL) {
    return RETURN_INVALID_PARAMETER;
  }
  if (Operand <= MAX_UINT8) {
    *Result = (UINT8)Operand;
    Status  = RETURN_SUCCESS;
  } else {
    *Result = UINT8_ERROR;
    Status  = RETURN_BUFFER_TOO_SMALL;
  }
  return Status;
}