Skip to content

Commit 1138584

Browse files
committed
libusbp_write_pipe: Allow zero-length transfers. Fix a compilation error on Windows.
1 parent b1c1054 commit 1138584

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/windows/generic_handle_windows.c

+3-8
Original file line numberDiff line numberDiff line change
@@ -206,26 +206,21 @@ libusbp_error * libusbp_write_pipe(
206206
error = check_pipe_id_out(pipe_id);
207207
}
208208

209-
if (error == NULL && size == 0)
210-
{
211-
error = error_create("Transfer size 0 is not allowed.");
212-
}
213-
214209
if (error == NULL && size > ULONG_MAX)
215210
{
216211
error = error_create("Transfer size is too large.");
217212
}
218213

219-
if (error == NULL && data == NULL)
214+
if (error == NULL && data == NULL && size)
220215
{
221216
error = error_create("Buffer is null.");
222217
}
223218

224219
ULONG winusb_transferred = 0;
225220
if (error == NULL)
226221
{
227-
BOOL success = WinUsb_WritePipe(handle->winusb_handle, pipe_id, data,
228-
size, &winusb_transferred, NULL);
222+
BOOL success = WinUsb_WritePipe(handle->winusb_handle, pipe_id,
223+
(uint8_t *)data, size, &winusb_transferred, NULL);
229224
if (!success)
230225
{
231226
error = error_create_winapi("");

0 commit comments

Comments
 (0)