Changes in / [00db345a:7ac73a4] in mainline


Ignore:
Location:
uspace
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/batch.c

    r00db345a r7ac73a4  
    4747static int batch_schedule(batch_t *instance);
    4848
    49 static void batch_control(batch_t *instance,
    50     usb_packet_id data_stage, usb_packet_id status_stage);
    51 static void batch_data(batch_t *instance, usb_packet_id pid);
     49static void batch_control(
     50    batch_t *instance, int data_stage, int status_stage);
    5251static void batch_call_in(batch_t *instance);
    5352static void batch_call_out(batch_t *instance);
     
    8483        }
    8584
    86         instance->tds = malloc32(sizeof(td_t) * instance->packets);
     85        instance->tds = malloc32(sizeof(transfer_descriptor_t) * instance->packets);
    8786        if (instance->tds == NULL) {
    8887                usb_log_error("Failed to allocate transfer descriptors.\n");
     
    9190                return NULL;
    9291        }
    93         bzero(instance->tds, sizeof(td_t) * instance->packets);
     92        bzero(instance->tds, sizeof(transfer_descriptor_t) * instance->packets);
    9493
    9594        const size_t transport_size = max_packet_size * instance->packets;
     
    152151        size_t i = 0;
    153152        for (;i < instance->packets; ++i) {
    154                 if (td_is_active(&instance->tds[i])) {
     153                if (transfer_descriptor_is_active(&instance->tds[i])) {
    155154                        return false;
    156155                }
    157 
    158                 instance->error = td_status(&instance->tds[i]);
     156                instance->error = transfer_descriptor_status(&instance->tds[i]);
    159157                if (instance->error != EOK) {
     158                        if (i > 0)
     159                                instance->transfered_size -= instance->setup_size;
    160160                        usb_log_debug("Batch(%p) found error TD(%d):%x.\n",
    161                             instance, i, instance->tds[i].status);
    162                         if (i > 0)
    163                                 goto substract_ret;
     161                          instance, i, instance->tds[i].status);
    164162                        return true;
    165163                }
    166 
    167                 instance->transfered_size += td_act_size(&instance->tds[i]);
    168                 if (td_is_short(&instance->tds[i]))
    169                         goto substract_ret;
    170         }
    171 substract_ret:
     164                instance->transfered_size +=
     165                    transfer_descriptor_actual_size(&instance->tds[i]);
     166        }
    172167        instance->transfered_size -= instance->setup_size;
    173168        return true;
     
    197192{
    198193        assert(instance);
    199         batch_data(instance, USB_PID_IN);
     194
     195        const bool low_speed = instance->speed == USB_SPEED_LOW;
     196        int toggle = 1;
     197        size_t i = 0;
     198        for (;i < instance->packets; ++i) {
     199                char *data =
     200                    instance->transport_buffer + (i  * instance->max_packet_size);
     201                transfer_descriptor_t *next = (i + 1) < instance->packets ?
     202                    &instance->tds[i + 1] : NULL;
     203                toggle = 1 - toggle;
     204
     205                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
     206                    instance->max_packet_size, toggle, false, low_speed,
     207                    instance->target, USB_PID_IN, data, next);
     208        }
     209
     210        instance->tds[i - 1].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
     211
    200212        instance->next_step = batch_call_in_and_dispose;
    201213        usb_log_debug("Batch(%p) INTERRUPT IN initialized.\n", instance);
     
    207219        assert(instance);
    208220        memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    209         batch_data(instance, USB_PID_OUT);
     221
     222        const bool low_speed = instance->speed == USB_SPEED_LOW;
     223        int toggle = 1;
     224        size_t i = 0;
     225        for (;i < instance->packets; ++i) {
     226                char *data =
     227                    instance->transport_buffer + (i  * instance->max_packet_size);
     228                transfer_descriptor_t *next = (i + 1) < instance->packets ?
     229                    &instance->tds[i + 1] : NULL;
     230                toggle = 1 - toggle;
     231
     232                transfer_descriptor_init(&instance->tds[i], DEFAULT_ERROR_COUNT,
     233                    instance->max_packet_size, toggle++, false, low_speed,
     234                    instance->target, USB_PID_OUT, data, next);
     235        }
     236
     237        instance->tds[i - 1].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
     238
    210239        instance->next_step = batch_call_out_and_dispose;
    211240        usb_log_debug("Batch(%p) INTERRUPT OUT initialized.\n", instance);
     
    213242}
    214243/*----------------------------------------------------------------------------*/
    215 void batch_bulk_in(batch_t *instance)
    216 {
    217         assert(instance);
    218         batch_data(instance, USB_PID_IN);
    219         instance->next_step = batch_call_in_and_dispose;
    220         usb_log_debug("Batch(%p) BULK IN initialized.\n", instance);
    221         batch_schedule(instance);
    222 }
    223 /*----------------------------------------------------------------------------*/
    224 void batch_bulk_out(batch_t *instance)
    225 {
    226         assert(instance);
    227         memcpy(instance->transport_buffer, instance->buffer, instance->buffer_size);
    228         batch_data(instance, USB_PID_OUT);
    229         instance->next_step = batch_call_out_and_dispose;
    230         usb_log_debug("Batch(%p) BULK OUT initialized.\n", instance);
    231         batch_schedule(instance);
    232 }
    233 /*----------------------------------------------------------------------------*/
    234 static void batch_data(batch_t *instance, usb_packet_id pid)
    235 {
    236         assert(instance);
    237         const bool low_speed = instance->speed == USB_SPEED_LOW;
    238         int toggle = 1;
    239 
    240         size_t packet = 0;
    241         size_t remain_size = instance->buffer_size;
    242         while (remain_size > 0) {
    243                 char *data =
    244                     instance->transport_buffer + instance->buffer_size
    245                     - remain_size;
    246 
    247                 toggle = 1 - toggle;
    248 
    249                 const size_t packet_size =
    250                     (instance->max_packet_size > remain_size) ?
    251                     remain_size : instance->max_packet_size;
    252 
    253                 td_init(&instance->tds[packet],
    254                     DEFAULT_ERROR_COUNT, packet_size, toggle, false, low_speed,
    255                     instance->target, pid, data,
    256                     &instance->tds[packet + 1]);
    257 
    258                 ++packet;
    259                 assert(packet <= instance->packets);
    260                 assert(packet_size <= remain_size);
    261                 remain_size -= packet_size;
    262         }
    263 
    264         instance->tds[packet - 1].status |= TD_STATUS_COMPLETE_INTERRUPT_FLAG;
    265         instance->tds[packet - 1].next = 0 | LINK_POINTER_TERMINATE_FLAG;
    266 }
    267 /*----------------------------------------------------------------------------*/
    268 static void batch_control(batch_t *instance,
    269    usb_packet_id data_stage, usb_packet_id status_stage)
     244static void batch_control(
     245    batch_t *instance, int data_stage, int status_stage)
    270246{
    271247        assert(instance);
     
    274250        int toggle = 0;
    275251        /* setup stage */
    276         td_init(instance->tds, DEFAULT_ERROR_COUNT,
     252        transfer_descriptor_init(instance->tds, DEFAULT_ERROR_COUNT,
    277253            instance->setup_size, toggle, false, low_speed, instance->target,
    278254            USB_PID_SETUP, instance->setup_buffer, &instance->tds[1]);
     
    292268                    remain_size : instance->max_packet_size;
    293269
    294                 td_init(&instance->tds[packet],
     270                transfer_descriptor_init(&instance->tds[packet],
    295271                    DEFAULT_ERROR_COUNT, packet_size, toggle, false, low_speed,
    296272                    instance->target, data_stage, data,
     
    305281        /* status stage */
    306282        assert(packet == instance->packets - 1);
    307         td_init(&instance->tds[packet], DEFAULT_ERROR_COUNT,
     283        transfer_descriptor_init(&instance->tds[packet], DEFAULT_ERROR_COUNT,
    308284            0, 1, false, low_speed, instance->target, status_stage, NULL, NULL);
    309285
  • uspace/drv/uhci-hcd/batch.h

    r00db345a r7ac73a4  
    6565        ddf_fun_t *fun;
    6666        queue_head_t *qh;
    67         td_t *tds;
     67        transfer_descriptor_t *tds;
    6868        void (*next_step)(struct batch*);
    6969} batch_t;
     
    8686void batch_interrupt_out(batch_t *instance);
    8787
    88 void batch_bulk_in(batch_t *instance);
     88/* DEPRECATED FUNCTIONS NEEDED BY THE OLD API */
     89void batch_control_setup_old(batch_t *instance);
    8990
    90 void batch_bulk_out(batch_t *instance);
     91void batch_control_write_data_old(batch_t *instance);
     92
     93void batch_control_read_data_old(batch_t *instance);
     94
     95void batch_control_write_status_old(batch_t *instance);
     96
     97void batch_control_read_status_old(batch_t *instance);
    9198#endif
    9299/**
  • uspace/drv/uhci-hcd/iface.c

    r00db345a r7ac73a4  
    140140}
    141141/*----------------------------------------------------------------------------*/
    142 static int bulk_out(ddf_fun_t *fun, usb_target_t target,
    143     size_t max_packet_size, void *data, size_t size,
    144     usbhc_iface_transfer_out_callback_t callback, void *arg)
    145 {
    146         assert(fun);
    147         uhci_t *hc = fun_to_uhci(fun);
    148         assert(hc);
    149         usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
    150 
    151         usb_log_debug("Bulk OUT %d:%d %zu(%zu).\n",
    152             target.address, target.endpoint, size, max_packet_size);
    153 
    154         batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,
    155             max_packet_size, speed, data, size, NULL, 0, NULL, callback, arg);
    156         if (!batch)
    157                 return ENOMEM;
    158         batch_bulk_out(batch);
    159         return EOK;
    160 }
    161 /*----------------------------------------------------------------------------*/
    162 static int bulk_in(ddf_fun_t *fun, usb_target_t target,
    163     size_t max_packet_size, void *data, size_t size,
    164     usbhc_iface_transfer_in_callback_t callback, void *arg)
    165 {
    166         assert(fun);
    167         uhci_t *hc = fun_to_uhci(fun);
    168         assert(hc);
    169         usb_speed_t speed = device_keeper_speed(&hc->device_manager, target.address);
    170         usb_log_debug("Bulk IN %d:%d %zu(%zu).\n",
    171             target.address, target.endpoint, size, max_packet_size);
    172 
    173         batch_t *batch = batch_get(fun, target, USB_TRANSFER_BULK,
    174             max_packet_size, speed, data, size, NULL, 0, callback, NULL, arg);
    175         if (!batch)
    176                 return ENOMEM;
    177         batch_bulk_in(batch);
    178         return EOK;
    179 }
    180 /*----------------------------------------------------------------------------*/
    181142static int control_write(ddf_fun_t *fun, usb_target_t target,
    182143    size_t max_packet_size,
     
    220181        return EOK;
    221182}
     183
     184
    222185/*----------------------------------------------------------------------------*/
    223186usbhc_iface_t uhci_iface = {
     
    231194        .interrupt_in = interrupt_in,
    232195
    233         .bulk_in = bulk_in,
    234         .bulk_out = bulk_out,
    235 
    236196        .control_read = control_read,
    237197        .control_write = control_write,
  • uspace/drv/uhci-hcd/uhci.c

    r00db345a r7ac73a4  
    336336                uhci_interrupt(instance, status);
    337337                pio_write_16(&instance->registers->usbsts, 0x1f);
    338                 async_usleep(UHCI_CLEANER_TIMEOUT);
     338                async_usleep(UHCI_CLEANER_TIMEOUT * 5);
    339339        }
    340340        return EOK;
  • uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.c

    r00db345a r7ac73a4  
    3838#include "utils/malloc32.h"
    3939
    40 void td_init(td_t *instance, int err_count, size_t size, bool toggle, bool iso,
    41     bool low_speed, usb_target_t target, usb_packet_id pid, void *buffer, td_t *next)
     40void transfer_descriptor_init(transfer_descriptor_t *instance,
     41    int error_count, size_t size, bool toggle, bool isochronous, bool low_speed,
     42    usb_target_t target, int pid, void *buffer, transfer_descriptor_t *next)
    4243{
    4344        assert(instance);
    44         assert(size < 1024);
    45         assert((pid == USB_PID_SETUP) || (pid == USB_PID_IN) || (pid == USB_PID_OUT));
    4645
    4746        instance->next = 0
     
    5049
    5150        instance->status = 0
    52             | ((err_count & TD_STATUS_ERROR_COUNT_MASK) << TD_STATUS_ERROR_COUNT_POS)
    53             | (low_speed ? TD_STATUS_LOW_SPEED_FLAG : 0)
    54             | (iso ? TD_STATUS_ISOCHRONOUS_FLAG : 0)
    55             | TD_STATUS_ERROR_ACTIVE;
     51          | ((error_count & TD_STATUS_ERROR_COUNT_MASK) << TD_STATUS_ERROR_COUNT_POS)
     52                | (low_speed ? TD_STATUS_LOW_SPEED_FLAG : 0)
     53          | TD_STATUS_ERROR_ACTIVE;
    5654
    57         if (pid == USB_PID_IN && !iso) {
    58                 instance->status |= TD_STATUS_SPD_FLAG;
    59         }
    60 
     55        assert(size < 1024);
    6156        instance->device = 0
    62             | (((size - 1) & TD_DEVICE_MAXLEN_MASK) << TD_DEVICE_MAXLEN_POS)
    63             | (toggle ? TD_DEVICE_DATA_TOGGLE_ONE_FLAG : 0)
    64             | ((target.address & TD_DEVICE_ADDRESS_MASK) << TD_DEVICE_ADDRESS_POS)
    65             | ((target.endpoint & TD_DEVICE_ENDPOINT_MASK) << TD_DEVICE_ENDPOINT_POS)
    66             | ((pid & TD_DEVICE_PID_MASK) << TD_DEVICE_PID_POS);
     57                | (((size - 1) & TD_DEVICE_MAXLEN_MASK) << TD_DEVICE_MAXLEN_POS)
     58                | (toggle ? TD_DEVICE_DATA_TOGGLE_ONE_FLAG : 0)
     59                | ((target.address & TD_DEVICE_ADDRESS_MASK) << TD_DEVICE_ADDRESS_POS)
     60                | ((target.endpoint & TD_DEVICE_ENDPOINT_MASK) << TD_DEVICE_ENDPOINT_POS)
     61                | ((pid & TD_DEVICE_PID_MASK) << TD_DEVICE_PID_POS);
    6762
    6863        instance->buffer_ptr = 0;
     
    7368
    7469        usb_log_debug2("Created TD: %X:%X:%X:%X(%p).\n",
    75             instance->next, instance->status, instance->device,
    76             instance->buffer_ptr, buffer);
     70                instance->next, instance->status, instance->device,
     71          instance->buffer_ptr, buffer);
    7772}
    7873/*----------------------------------------------------------------------------*/
    79 int td_status(td_t *instance)
     74int transfer_descriptor_status(transfer_descriptor_t *instance)
    8075{
    8176        assert(instance);
  • uspace/drv/uhci-hcd/uhci_struct/transfer_descriptor.h

    r00db345a r7ac73a4  
    8888         * we don't use it anyway
    8989         */
    90 } __attribute__((packed)) td_t;
     90} __attribute__((packed)) transfer_descriptor_t;
    9191
    9292
    93 void td_init(td_t *instance, int error_count, size_t size, bool toggle, bool iso,
    94     bool low_speed, usb_target_t target, usb_packet_id pid, void *buffer,
    95     td_t *next);
     93void transfer_descriptor_init(transfer_descriptor_t *instance,
     94    int error_count, size_t size, bool toggle, bool isochronous, bool low_speed,
     95    usb_target_t target, int pid, void *buffer, transfer_descriptor_t * next);
    9696
    97 int td_status(td_t *instance);
     97int transfer_descriptor_status(transfer_descriptor_t *instance);
    9898
    99 static inline size_t td_act_size(td_t *instance)
     99static inline size_t transfer_descriptor_actual_size(
     100    transfer_descriptor_t *instance)
    100101{
    101102        assert(instance);
    102103        return
    103             ((instance->status >> TD_STATUS_ACTLEN_POS) + 1)
    104             & TD_STATUS_ACTLEN_MASK;
     104            ((instance->status >> TD_STATUS_ACTLEN_POS) + 1) & TD_STATUS_ACTLEN_MASK;
    105105}
    106106
    107 static inline bool td_is_short(td_t *instance)
    108 {
    109         const size_t act_size = td_act_size(instance);
    110         const size_t max_size =
    111             ((instance->device >> TD_DEVICE_MAXLEN_POS) + 1)
    112             & TD_DEVICE_MAXLEN_MASK;
    113         return
    114             (instance->status | TD_STATUS_SPD_FLAG) && act_size < max_size;
    115 }
    116 
    117 static inline bool td_is_active(td_t *instance)
     107static inline bool transfer_descriptor_is_active(
     108    transfer_descriptor_t *instance)
    118109{
    119110        assert(instance);
  • uspace/drv/usbhub/usbhub.c

    r00db345a r7ac73a4  
    233233        dprintf(USB_LOG_LEVEL_DEBUG, "starting control transaction");
    234234        usb_endpoint_pipe_start_session(&result->endpoints.control);
    235         opResult = usb_request_set_configuration(&result->endpoints.control, 1);
    236         assert(opResult == EOK);
    237 
    238235        opResult = usb_request_get_descriptor(&result->endpoints.control,
    239236                        USB_REQUEST_TYPE_CLASS, USB_REQUEST_RECIPIENT_DEVICE,
     
    246243                dprintf(USB_LOG_LEVEL_ERROR, "failed when receiving hub descriptor, badcode = %d",opResult);
    247244                free(serialized_descriptor);
    248                 free(result);
    249                 return NULL;
     245                return result;
    250246        }
    251247        dprintf(USB_LOG_LEVEL_DEBUG2, "deserializing descriptor");
     
    253249        if(descriptor==NULL){
    254250                dprintf(USB_LOG_LEVEL_WARNING, "could not deserialize descriptor ");
    255                 free(result);
    256                 return NULL;
     251                result->port_count = 1;///\TODO this code is only for debug!!!
     252                return result;
    257253        }
    258254
     
    290286
    291287        usb_hub_info_t * hub_info = usb_create_hub_info(dev);
    292         if(!hub_info){
    293                 return EINTR;
    294         }
    295288
    296289        int opResult;
     
    301294        opResult = usb_hub_process_configuration_descriptors(hub_info);
    302295        if(opResult != EOK){
    303                 dprintf(USB_LOG_LEVEL_ERROR,"could not get configuration descriptors, %d",
     296                dprintf(USB_LOG_LEVEL_ERROR,"could not get condiguration descriptors, %d",
    304297                                opResult);
    305298                return opResult;
  • uspace/drv/usbmouse/main.c

    r00db345a r7ac73a4  
    7474int main(int argc, char *argv[])
    7575{
    76         usb_log_enable(USB_LOG_LEVEL_DEBUG2, NAME);
     76        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    7777
    7878        return ddf_driver_main(&mouse_driver);
  • uspace/drv/usbmouse/mouse.c

    r00db345a r7ac73a4  
    3737#include <usb/debug.h>
    3838#include <errno.h>
    39 #include <str_error.h>
    4039#include <ipc/mouse.h>
    4140
     
    6564
    6665                size_t actual_size;
    67                 int rc;
    6866
    69                 /*
    70                  * Error checking note:
    71                  * - failure when starting a session is considered
    72                  *   temporary (e.g. out of phones, next try might succeed)
    73                  * - failure of transfer considered fatal (probably the
    74                  *   device was unplugged)
    75                  * - session closing not checked (shall not fail anyway)
    76                  */
     67                /* FIXME: check for errors. */
     68                usb_endpoint_pipe_start_session(&mouse->poll_pipe);
    7769
    78                 rc = usb_endpoint_pipe_start_session(&mouse->poll_pipe);
    79                 if (rc != EOK) {
    80                         usb_log_warning("Failed to start session, will try again: %s.\n",
    81                             str_error(rc));
    82                         continue;
    83                 }
    84 
    85                 rc = usb_endpoint_pipe_read(&mouse->poll_pipe,
     70                usb_endpoint_pipe_read(&mouse->poll_pipe,
    8671                    buffer, buffer_size, &actual_size);
    8772
    8873                usb_endpoint_pipe_end_session(&mouse->poll_pipe);
    89 
    90                 if (rc != EOK) {
    91                         usb_log_error("Failed reading mouse input: %s.\n",
    92                             str_error(rc));
    93                         break;
    94                 }
    95 
    96                 usb_log_debug2("got buffer: %s.\n",
    97                     usb_debug_str_buffer(buffer, buffer_size, 0));
    9874
    9975                uint8_t butt = buffer[0];
     
    139115        }
    140116
    141         /*
    142          * Device was probably unplugged.
    143          * Hang-up the phone to the console.
    144          * FIXME: release allocated memory.
    145          */
    146         async_hangup(mouse->console_phone);
    147         mouse->console_phone = -1;
    148 
    149         usb_log_error("Mouse polling fibril terminated.\n");
    150 
    151117        return EOK;
    152118}
  • uspace/lib/usb/include/usb/debug.h

    r00db345a r7ac73a4  
    7979        usb_log_printf(USB_LOG_LEVEL_DEBUG2, format, ##__VA_ARGS__)
    8080
    81 const char *usb_debug_str_buffer(uint8_t *, size_t, size_t);
    8281
    8382
  • uspace/lib/usb/src/debug.c

    r00db345a r7ac73a4  
    252252}
    253253
    254 
    255 #define REMAINDER_STR_FMT " (%zu)..."
    256 /* string + terminator + number width (enough for 4GB)*/
    257 #define REMAINDER_STR_LEN (5 + 1 + 10)
    258 #define BUFFER_DUMP_GROUP_SIZE 4
    259 #define BUFFER_DUMP_LEN 240 /* Ought to be enough for everybody ;-). */
    260 static fibril_local char buffer_dump[BUFFER_DUMP_LEN];
    261 
    262 /** Dump buffer into string.
    263  *
    264  * The function dumps given buffer into hexadecimal format and stores it
    265  * in a static fibril local string.
    266  * That means that you do not have to deallocate the string (actually, you
    267  * can not do that) and you do not have to save it agains concurrent
    268  * calls to it.
    269  * The only limitation is that each call rewrites the buffer again.
    270  * Thus, it is necessary to copy the buffer elsewhere (that includes printing
    271  * to screen or writing to file).
    272  * Since this function is expected to be used for debugging prints only,
    273  * that is not a big limitation.
    274  *
    275  * @warning You cannot use this function twice in the same printf
    276  * (see detailed explanation).
    277  *
    278  * @param buffer Buffer to be printed (can be NULL).
    279  * @param size Size of the buffer in bytes (can be zero).
    280  * @param dumped_size How many bytes to actually dump (zero means all).
    281  * @return Dumped buffer as a static (but fibril local) string.
    282  */
    283 const char *usb_debug_str_buffer(uint8_t *buffer, size_t size,
    284     size_t dumped_size)
    285 {
    286         /*
    287          * Remove previous string (that might also reveal double usage of
    288          * this function).
    289          */
    290         bzero(buffer_dump, BUFFER_DUMP_LEN);
    291 
    292         if (buffer == NULL) {
    293                 return "(null)";
    294         }
    295         if (size == 0) {
    296                 return "(empty)";
    297         }
    298         if ((dumped_size == 0) || (dumped_size > size)) {
    299                 dumped_size = size;
    300         }
    301 
    302         /* How many bytes are available in the output buffer. */
    303         size_t buffer_remaining_size = BUFFER_DUMP_LEN - 1 - REMAINDER_STR_LEN;
    304         char *it = buffer_dump;
    305 
    306         size_t index = 0;
    307 
    308         while (index < size) {
    309                 /* Determine space before the number. */
    310                 const char *space_before;
    311                 if (index == 0) {
    312                         space_before = "";
    313                 } else if ((index % BUFFER_DUMP_GROUP_SIZE) == 0) {
    314                         space_before = "  ";
    315                 } else {
    316                         space_before = " ";
    317                 }
    318 
    319                 /*
    320                  * Add the byte as a hexadecimal number plus the space.
    321                  * We do it into temporary buffer to ensure that always
    322                  * the whole byte is printed.
    323                  */
    324                 int val = buffer[index];
    325                 char current_byte[16];
    326                 int printed = snprintf(current_byte, 16,
    327                     "%s%02x", space_before, val);
    328                 if (printed < 0) {
    329                         break;
    330                 }
    331 
    332                 if ((size_t) printed > buffer_remaining_size) {
    333                         break;
    334                 }
    335 
    336                 /* We can safely add 1, because space for end 0 is reserved. */
    337                 str_append(it, buffer_remaining_size + 1, current_byte);
    338 
    339                 buffer_remaining_size -= printed;
    340                 /* Point at the terminator 0. */
    341                 it += printed;
    342                 index++;
    343 
    344                 if (index >= dumped_size) {
    345                         break;
    346                 }
    347         }
    348 
    349         /* Add how many bytes were not printed. */
    350         if (index < size) {
    351                 snprintf(it, REMAINDER_STR_LEN,
    352                     REMAINDER_STR_FMT, size - index);
    353         }
    354 
    355         return buffer_dump;
    356 }
    357 
    358 
    359254/**
    360255 * @}
Note: See TracChangeset for help on using the changeset viewer.