Skip to content

Commit

Permalink
main: Return sysexit.h codes instead of libusb codes
Browse files Browse the repository at this point in the history
Most errors ending here should be EX_IOERR cases.
The libusb error codes have in most cases already been
dumped by the lower-level functions, and only in a few
places we return something else, e.g. -1.

Signed-off-by: Tormod Volden <[email protected]>
  • Loading branch information
tormodvolden committed Nov 22, 2020
1 parent 6e79bf8 commit b8f19b4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,10 @@ int main(int argc, char **argv)
ret = dfuload_do_upload(dfu_root, transfer_size, expected_size, fd);
}
close(fd);
if (ret < 0)
ret = EX_IOERR;
else
ret = EX_OK;
break;

case MODE_DOWNLOAD:
Expand All @@ -708,6 +712,10 @@ int main(int argc, char **argv)
} else {
ret = dfuload_do_dnload(dfu_root, transfer_size, &file);
}
if (ret < 0)
ret = EX_IOERR;
else
ret = EX_OK;
break;
case MODE_DETACH:
ret = dfu_detach(dfu_root->dev_handle, dfu_root->interface, 1000);
Expand Down

0 comments on commit b8f19b4

Please sign in to comment.