/** INTN -> UINT32 conversion Converts the value specified by Operand to a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type. If Result is NULL, RETURN_INVALID_PARAMETER is returned. If the conversion results in an overflow or an underflow condition, then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned. @param[in] Operand Operand to be converted to new type @param[out] Result Pointer to the result of conversion @retval RETURN_SUCCESS Successful conversion @retval RETURN_BUFFER_TOO_SMALL Overflow @retval RETURN_INVALID_PARAMETER Result is NULL **/ RETURN_STATUS EFIAPI SafeIntnToUint32 ( IN INTN Operand, OUT UINT32 *Result ) { RETURN_STATUS Status; if (Result == NULL) { return RETURN_INVALID_PARAMETER; } if (sizeof (UINTN) == sizeof (UINT32)) { if (Operand >= 0) { *Result = (UINT32)Operand; Status = RETURN_SUCCESS; } else { *Result = UINT32_ERROR; Status = RETURN_BUFFER_TOO_SMALL; } return Status; } return SafeInt64ToUint32 ((INT64)Operand, Result); }
/** INTN -> UINT32 conversion Converts the value specified by Operand to a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type. If Result is NULL, RETURN_INVALID_PARAMETER is returned. If the conversion results in an overflow or an underflow condition, then Result is set to UINT32_ERROR and RETURN_BUFFER_TOO_SMALL is returned. @param[in] Operand Operand to be converted to new type @param[out] Result Pointer to the result of conversion @retval RETURN_SUCCESS Successful conversion @retval RETURN_BUFFER_TOO_SMALL Overflow @retval RETURN_INVALID_PARAMETER Result is NULL **/ RETURN_STATUS EFIAPI SafeIntnToUint32 ( IN INTN Operand, OUT UINT32 *Result ) { return SafeInt64ToUint32 ((INT64)Operand, Result); }
/** INT64 -> UINTN conversion Converts the value specified by Operand to a value specified by Result type and stores the converted value into the caller allocated output buffer specified by Result. The caller must pass in a Result buffer that is at least as large as the Result type. If Result is NULL, RETURN_INVALID_PARAMETER is returned. If the conversion results in an overflow or an underflow condition, then Result is set to UINTN_ERROR and RETURN_BUFFER_TOO_SMALL is returned. @param[in] Operand Operand to be converted to new type @param[out] Result Pointer to the result of conversion @retval RETURN_SUCCESS Successful conversion @retval RETURN_BUFFER_TOO_SMALL Overflow @retval RETURN_INVALID_PARAMETER Result is NULL **/ RETURN_STATUS EFIAPI SafeInt64ToUintn ( IN INT64 Operand, OUT UINTN *Result ) { if (sizeof (UINTN) == sizeof (UINT32)) { return SafeInt64ToUint32 (Operand, (UINT32 *)Result); } return SafeInt64ToUint64 (Operand, (UINT64 *)Result); }