{sysaudio,sysgpu}: audit HRESULT success checks #1143

Open
opened 2024-01-14 19:14:04 +00:00 by emidoots · 0 comments
emidoots commented 2024-01-14 19:14:04 +00:00 (Migrated from github.com)

Code like:

            switch (hr) {
                win32.S_OK => {},
                win32.E_POINTER => unreachable,
                win32.E_INVALIDARG => unreachable,
                win32.E_OUTOFMEMORY => return error.OutOfMemory,
                else => return error.OpeningDevice,
            }

Is rather dubious, that's not what SUCCEEDED(hr) would check and methods could return other success conditions in obscure conditions:

#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)

We should audit both mach-sysaudio and mach-sysgpu for this type of error checking, and standardize on a correct error handling implementation.

Code like: ``` switch (hr) { win32.S_OK => {}, win32.E_POINTER => unreachable, win32.E_INVALIDARG => unreachable, win32.E_OUTOFMEMORY => return error.OutOfMemory, else => return error.OpeningDevice, } ``` Is rather dubious, that's not what `SUCCEEDED(hr)` would check and methods could return other success conditions in obscure conditions: ``` #define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) ``` We should audit both mach-sysaudio and mach-sysgpu for this type of error checking, and standardize on a correct error handling implementation.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach#1143
No description provided.