This repository has been archived by the owner on Nov 11, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Device change only: avoid modifying output parameter on error (#146)
Best practice is to avoid modifying output parameters if a function is failing, especially when handles are returned, this supports consistent cleanup code. The following pattern is now supported for uDeviceOpen(): uDeviceHandle_t device_handle = NULL; int32_t ret; if ((ret = uDeviceOpen(&gDeviceCfg, &device_handle)) != 0) { uPortLog("ERR: uDeviceOpen %d\n", ret); goto cleanup; } cleanup: if (device_handle != NULL) { uDeviceClose(device_handle, false); device_handle = NULL; } Signed-off-by: Alon Bar-Lev <alon.barlev@gmail.com>
- Loading branch information