Changeset 584aa38 in mainline


Ignore:
Timestamp:
2014-01-25T03:27:29Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8a81e431
Parents:
bfff7fd
Message:

ohci: Remove error checking macro

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/ohci_batch.c

    rbfff7fd r584aa38  
    9797{
    9898        assert(usb_batch);
    99 #define CHECK_NULL_DISPOSE_RET(ptr, message...) \
    100 if (ptr == NULL) { \
    101         usb_log_error(message); \
    102         ohci_transfer_batch_dispose(ohci_batch); \
    103         return NULL; \
    104 } else (void)0
    10599
    106100        ohci_transfer_batch_t *ohci_batch =
    107101            calloc(1, sizeof(ohci_transfer_batch_t));
    108         CHECK_NULL_DISPOSE_RET(ohci_batch,
    109             "Failed to allocate OHCI batch data.\n");
     102        if (!ohci_batch) {
     103                usb_log_error("Failed to allocate OHCI batch data.");
     104                goto dispose;
     105        }
    110106        link_initialize(&ohci_batch->link);
    111107        ohci_batch->td_count =
     
    119115        /* We need an extra place for TD that was left at ED */
    120116        ohci_batch->tds = calloc(ohci_batch->td_count + 1, sizeof(td_t*));
    121         CHECK_NULL_DISPOSE_RET(ohci_batch->tds,
    122             "Failed to allocate OHCI transfer descriptors.\n");
     117        if (!ohci_batch->tds) {
     118                usb_log_error("Failed to allocate OHCI transfer descriptors.");
     119                goto dispose;
     120        }
    123121
    124122        /* Add TD left over by the previous transfer */
     
    128126        for (unsigned i = 1; i <= ohci_batch->td_count; ++i) {
    129127                ohci_batch->tds[i] = malloc32(sizeof(td_t));
    130                 CHECK_NULL_DISPOSE_RET(ohci_batch->tds[i],
    131                     "Failed to allocate TD %d.\n", i );
     128                if (!ohci_batch->tds[i]) {
     129                        usb_log_error("Failed to allocate TD %d.", i);
     130                        goto dispose;
     131                }
    132132        }
    133133
     
    141141                ohci_batch->device_buffer =
    142142                    malloc32(usb_batch->setup_size + usb_batch->buffer_size);
    143                 CHECK_NULL_DISPOSE_RET(ohci_batch->device_buffer,
    144                     "Failed to allocate device accessible buffer.\n");
     143                if (!ohci_batch->device_buffer) {
     144                        usb_log_error("Failed to allocate device buffer");
     145                        goto dispose;
     146                }
    145147                /* Copy setup data */
    146148                memcpy(ohci_batch->device_buffer, usb_batch->setup_buffer,
     
    159161
    160162        return ohci_batch;
    161 #undef CHECK_NULL_DISPOSE_RET
     163dispose:
     164        ohci_transfer_batch_dispose(ohci_batch);
     165        return NULL;
    162166}
    163167
Note: See TracChangeset for help on using the changeset viewer.