Closed leidegre closed 3 months ago
e
wasn't declared yet at this point, so I'd either do so right here, like this:
find_data := &win32.WIN32_FIND_DATAW{}
find_handle := win32.FindFirstFileW(raw_data(wpath_search), find_data)
if find_handle == win32.INVALID_HANDLE_VALUE {
e := Errno(win32.GetLastError())
return dfi[:], e
}
defer win32.FindClose(find_handle)
Or use the err
return value we already have
find_data := &win32.WIN32_FIND_DATAW{}
find_handle := win32.FindFirstFileW(raw_data(wpath_search), find_data)
if find_handle == win32.INVALID_HANDLE_VALUE {
err = Errno(win32.GetLastError())
return dfi[:], err
}
defer win32.FindClose(find_handle)
We do still need to return dfi[:]
so the caller can free the (empty) result list backed by the dynamic array, like they would on a successful call, so return dfi[:], err
seems sensible.
Fix for https://github.com/odin-lang/Odin/issues/3705