Changeset b81410f in mainline for uspace/lib/usbdev/src/devpoll.c


Ignore:
Timestamp:
2011-11-26T14:34:20Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d085fbbe
Parents:
2703331b
Message:

libusbdev: Remove redundant checks. Add few const qualifiers.

File:
1 edited

Legend:

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

    r2703331b rb81410f  
    7070       
    7171        if (polling_data->auto_polling.debug > 0) {
    72                 usb_endpoint_mapping_t *mapping
     72                const usb_endpoint_mapping_t *mapping
    7373                    = &polling_data->dev->pipes[polling_data->pipe_index];
    7474                usb_log_debug("Poll%p: started polling of `%s' - " \
     
    8585        size_t failed_attempts = 0;
    8686        while (failed_attempts <= polling_data->auto_polling.max_failures) {
    87                 int rc;
    88 
    8987                size_t actual_size;
    90                 rc = usb_pipe_read(pipe, polling_data->buffer,
     88                const int rc = usb_pipe_read(pipe, polling_data->buffer,
    9189                    polling_data->request_size, &actual_size);
    9290
     
    113111                         */
    114112                        usb_request_clear_endpoint_halt(
    115                             &polling_data->dev->ctrl_pipe,
    116                             pipe->endpoint_no);
     113                            &polling_data->dev->ctrl_pipe, pipe->endpoint_no);
    117114                }
    118115
     
    196193    usb_polling_terminted_callback_t terminated_callback, void *arg)
    197194{
    198         if ((dev == NULL) || (callback == NULL)) {
    199                 return EBADMEM;
    200         }
    201         if (request_size == 0) {
    202                 return EINVAL;
    203         }
    204         if ((dev->pipes[pipe_index].pipe.transfer_type != USB_TRANSFER_INTERRUPT)
    205             || (dev->pipes[pipe_index].pipe.direction != USB_DIRECTION_IN)) {
    206                 return EINVAL;
    207         }
    208 
    209195        const usb_device_auto_polling_t auto_polling = {
    210196                .debug = 1,
     
    242228    size_t request_size, void *arg)
    243229{
    244         if (dev == NULL) {
     230        if ((dev == NULL) || (polling == NULL) || (polling->on_data == NULL)) {
    245231                return EBADMEM;
    246232        }
    247         if (pipe_index >= dev->pipes_count) {
     233
     234        if (pipe_index >= dev->pipes_count || request_size == 0) {
    248235                return EINVAL;
    249236        }
     
    251238            || (dev->pipes[pipe_index].pipe.direction != USB_DIRECTION_IN)) {
    252239                return EINVAL;
    253         }
    254         if ((polling == NULL) || (polling->on_data == NULL)) {
    255                 return EBADMEM;
    256240        }
    257241
Note: See TracChangeset for help on using the changeset viewer.