mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[hal] Report previous allocation location for indexed resource duplicates (#3322)
This commit is contained in:
@@ -70,19 +70,14 @@ HAL_SerialPortHandle HAL_InitializeSerialPort(HAL_SerialPort port,
|
||||
HAL_SerialPortHandle HAL_InitializeSerialPortDirect(HAL_SerialPort port,
|
||||
const char* portName,
|
||||
int32_t* status) {
|
||||
auto handle = serialPortHandles->Allocate(static_cast<int16_t>(port), status);
|
||||
HAL_SerialPortHandle handle;
|
||||
auto serialPort =
|
||||
serialPortHandles->Allocate(static_cast<int16_t>(port), &handle, status);
|
||||
|
||||
if (*status != 0) {
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
auto serialPort = serialPortHandles->Get(handle);
|
||||
|
||||
if (serialPort == nullptr) {
|
||||
*status = HAL_HANDLE_ERROR;
|
||||
return HAL_kInvalidHandle;
|
||||
}
|
||||
|
||||
serialPort->portId = open(portName, O_RDWR | O_NOCTTY);
|
||||
if (serialPort->portId < 0) {
|
||||
*status = errno;
|
||||
|
||||
Reference in New Issue
Block a user