Changeset b7fd2a0 in mainline for uspace/lib/usbdev/src/request.c


Ignore:
Timestamp:
2018-01-13T03:10:29Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a53ed3a
Parents:
36f0738
Message:

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/src/request.c

    r36f0738 rb7fd2a0  
    6868 *
    6969 */
    70 int usb_control_request_set(usb_pipe_t *pipe,
     70errno_t usb_control_request_set(usb_pipe_t *pipe,
    7171    usb_request_type_t request_type, usb_request_recipient_t recipient,
    7272    uint8_t request, uint16_t value, uint16_t index,
     
    127127 *
    128128 */
    129 int usb_control_request_get(usb_pipe_t *pipe,
     129errno_t usb_control_request_get(usb_pipe_t *pipe,
    130130    usb_request_type_t request_type, usb_request_recipient_t recipient,
    131131    uint8_t request, uint16_t value, uint16_t index,
     
    170170 * @return Error code.
    171171 */
    172 int usb_request_get_status(usb_pipe_t *pipe,
     172errno_t usb_request_get_status(usb_pipe_t *pipe,
    173173    usb_request_recipient_t recipient, uint16_t index,
    174174    uint16_t *status)
     
    184184        uint16_t status_usb_endianess;
    185185        size_t data_transfered_size;
    186         int rc = usb_control_request_get(pipe, USB_REQUEST_TYPE_STANDARD,
     186        errno_t rc = usb_control_request_get(pipe, USB_REQUEST_TYPE_STANDARD,
    187187            recipient, USB_DEVREQ_GET_STATUS, 0, uint16_host2usb(index),
    188188            &status_usb_endianess, 2, &data_transfered_size);
     
    208208 * @return Error code.
    209209 */
    210 int usb_request_clear_feature(usb_pipe_t *pipe,
     210errno_t usb_request_clear_feature(usb_pipe_t *pipe,
    211211    usb_request_type_t request_type, usb_request_recipient_t recipient,
    212212    uint16_t feature_selector, uint16_t index)
     
    232232 * @return Error code.
    233233 */
    234 int usb_request_set_feature(usb_pipe_t *pipe,
     234errno_t usb_request_set_feature(usb_pipe_t *pipe,
    235235    usb_request_type_t request_type, usb_request_recipient_t recipient,
    236236    uint16_t feature_selector, uint16_t index)
     
    260260 * @return Error code.
    261261 */
    262 int usb_request_get_descriptor(usb_pipe_t *pipe,
     262errno_t usb_request_get_descriptor(usb_pipe_t *pipe,
    263263    usb_request_type_t request_type, usb_request_recipient_t recipient,
    264264    uint8_t descriptor_type, uint8_t descriptor_index,
     
    298298 * @return
    299299 */
    300 int usb_request_get_descriptor_alloc(usb_pipe_t * pipe,
     300errno_t usb_request_get_descriptor_alloc(usb_pipe_t * pipe,
    301301    usb_request_type_t request_type, usb_request_recipient_t recipient,
    302302    uint8_t descriptor_type, uint8_t descriptor_index,
     
    308308        }
    309309
    310         int rc;
     310        errno_t rc;
    311311
    312312        /*
     
    364364 * @return Error code.
    365365 */
    366 int usb_request_get_device_descriptor(usb_pipe_t *pipe,
     366errno_t usb_request_get_device_descriptor(usb_pipe_t *pipe,
    367367    usb_standard_device_descriptor_t *descriptor)
    368368{
     
    373373        size_t actually_transferred = 0;
    374374        usb_standard_device_descriptor_t descriptor_tmp;
    375         int rc = usb_request_get_descriptor(pipe,
     375        errno_t rc = usb_request_get_descriptor(pipe,
    376376            USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,
    377377            USB_DESCTYPE_DEVICE, 0, 0, &descriptor_tmp, sizeof(descriptor_tmp),
     
    404404 * @return Error code.
    405405 */
    406 int usb_request_get_bare_configuration_descriptor(usb_pipe_t *pipe,
     406errno_t usb_request_get_bare_configuration_descriptor(usb_pipe_t *pipe,
    407407    int index, usb_standard_configuration_descriptor_t *descriptor)
    408408{
     
    417417        size_t actually_transferred = 0;
    418418        usb_standard_configuration_descriptor_t descriptor_tmp;
    419         const int rc = usb_request_get_descriptor(pipe,
     419        const errno_t rc = usb_request_get_descriptor(pipe,
    420420            USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,
    421421            USB_DESCTYPE_CONFIGURATION, index, 0,
     
    448448 * @return Error code.
    449449 */
    450 int usb_request_get_full_configuration_descriptor(usb_pipe_t *pipe,
     450errno_t usb_request_get_full_configuration_descriptor(usb_pipe_t *pipe,
    451451    int index, void *descriptor, size_t descriptor_size, size_t *actual_size)
    452452{
     
    473473 * @return Error code.
    474474 */
    475 int usb_request_get_full_configuration_descriptor_alloc(
     475errno_t usb_request_get_full_configuration_descriptor_alloc(
    476476    usb_pipe_t *pipe, int index,
    477477    const void **descriptor_ptr, size_t *descriptor_size)
    478478{
    479         int rc;
     479        errno_t rc;
    480480
    481481        if (descriptor_ptr == NULL) {
     
    539539 * @return Error code.
    540540 */
    541 int usb_request_set_descriptor(usb_pipe_t *pipe,
     541errno_t usb_request_set_descriptor(usb_pipe_t *pipe,
    542542    usb_request_type_t request_type, usb_request_recipient_t recipient,
    543543    uint8_t descriptor_type, uint8_t descriptor_index,
     
    565565 * @return Error code.
    566566 */
    567 int usb_request_get_configuration(usb_pipe_t *pipe,
     567errno_t usb_request_get_configuration(usb_pipe_t *pipe,
    568568    uint8_t *configuration_value)
    569569{
     
    571571        size_t actual_size;
    572572
    573         const int rc = usb_control_request_get(pipe,
     573        const errno_t rc = usb_control_request_get(pipe,
    574574            USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,
    575575            USB_DEVREQ_GET_CONFIGURATION, 0, 0, &value, 1, &actual_size);
     
    595595 * @return Error code.
    596596 */
    597 int usb_request_set_configuration(usb_pipe_t *pipe,
     597errno_t usb_request_set_configuration(usb_pipe_t *pipe,
    598598    uint8_t configuration_value)
    599599{
     
    614614 * @return Error code.
    615615 */
    616 int usb_request_get_interface(usb_pipe_t *pipe,
     616errno_t usb_request_get_interface(usb_pipe_t *pipe,
    617617    uint8_t interface_index, uint8_t *alternate_setting)
    618618{
     
    620620        size_t actual_size;
    621621
    622         const int rc = usb_control_request_get(pipe,
     622        const errno_t rc = usb_control_request_get(pipe,
    623623            USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_INTERFACE,
    624624            USB_DEVREQ_GET_INTERFACE,
     
    647647 * @return Error code.
    648648 */
    649 int usb_request_set_interface(usb_pipe_t *pipe,
     649errno_t usb_request_set_interface(usb_pipe_t *pipe,
    650650    uint8_t interface_index, uint8_t alternate_setting)
    651651{
     
    666666 * @return Error code.
    667667 */
    668 int usb_request_get_supported_languages(usb_pipe_t *pipe,
     668errno_t usb_request_get_supported_languages(usb_pipe_t *pipe,
    669669    l18_win_locales_t **languages_ptr, size_t *languages_count)
    670670{
     
    675675        uint8_t *string_descriptor = NULL;
    676676        size_t string_descriptor_size = 0;
    677         const int rc = usb_request_get_descriptor_alloc(pipe,
     677        const errno_t rc = usb_request_get_descriptor_alloc(pipe,
    678678            USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,
    679679            USB_DESCTYPE_STRING, 0, 0,
     
    733733 * @return Error code.
    734734 */
    735 int usb_request_get_string(usb_pipe_t *pipe,
     735errno_t usb_request_get_string(usb_pipe_t *pipe,
    736736    size_t index, l18_win_locales_t lang, char **string_ptr)
    737737{
     
    751751        }
    752752
    753         int rc;
     753        errno_t rc;
    754754
    755755        /* Prepare dynamically allocated variables. */
     
    824824 * @return Error code.
    825825 */
    826 int usb_request_clear_endpoint_halt(usb_pipe_t *pipe, uint16_t ep_index)
     826errno_t usb_request_clear_endpoint_halt(usb_pipe_t *pipe, uint16_t ep_index)
    827827{
    828828        return usb_request_clear_feature(pipe,
     
    838838 * @return Error code.
    839839 */
    840 int usb_pipe_clear_halt(usb_pipe_t *ctrl_pipe, usb_pipe_t *target_pipe)
     840errno_t usb_pipe_clear_halt(usb_pipe_t *ctrl_pipe, usb_pipe_t *target_pipe)
    841841{
    842842        if ((ctrl_pipe == NULL) || (target_pipe == NULL)) {
     
    854854 * @return Error code.
    855855 */
    856 int usb_request_get_endpoint_status(usb_pipe_t *ctrl_pipe, usb_pipe_t *pipe,
     856errno_t usb_request_get_endpoint_status(usb_pipe_t *ctrl_pipe, usb_pipe_t *pipe,
    857857    uint16_t *status)
    858858{
    859859        uint16_t status_tmp;
    860860        uint16_t pipe_index = (uint16_t) pipe->endpoint_no;
    861         int rc = usb_request_get_status(ctrl_pipe,
     861        errno_t rc = usb_request_get_status(ctrl_pipe,
    862862            USB_REQUEST_RECIPIENT_ENDPOINT, uint16_host2usb(pipe_index),
    863863            &status_tmp);
Note: See TracChangeset for help on using the changeset viewer.