Changeset 9445aad in mainline for uspace/lib


Ignore:
Timestamp:
2011-03-03T23:25:34Z (15 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3c775adb, 9a422574
Parents:
bdc8ab1 (diff), 8f74140c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Development branch changes

Location:
uspace/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/loader.c

    rbdc8ab1 r9445aad  
    160160        int rc = async_data_write_start(ldr->phone_id, (void *) pa, pa_len);
    161161        if (rc != EOK) {
     162                free(pa);
    162163                async_wait_for(req, NULL);
    163164                return rc;
  • uspace/lib/c/generic/vfs/vfs.c

    rbdc8ab1 r9445aad  
    6969        char *ncwd_path;
    7070        char *ncwd_path_nc;
     71        size_t total_size;
    7172
    7273        fibril_mutex_lock(&cwd_mutex);
     
    7778                        return NULL;
    7879                }
    79                 ncwd_path_nc = malloc(cwd_size + 1 + size + 1);
     80                total_size = cwd_size + 1 + size + 1;
     81                ncwd_path_nc = malloc(total_size);
    8082                if (!ncwd_path_nc) {
    8183                        fibril_mutex_unlock(&cwd_mutex);
    8284                        return NULL;
    8385                }
    84                 str_cpy(ncwd_path_nc, cwd_size + 1 + size + 1, cwd_path);
     86                str_cpy(ncwd_path_nc, total_size, cwd_path);
    8587                ncwd_path_nc[cwd_size] = '/';
    8688                ncwd_path_nc[cwd_size + 1] = '\0';
    8789        } else {
    88                 ncwd_path_nc = malloc(size + 1);
     90                total_size = size + 1;
     91                ncwd_path_nc = malloc(total_size);
    8992                if (!ncwd_path_nc) {
    9093                        fibril_mutex_unlock(&cwd_mutex);
     
    9396                ncwd_path_nc[0] = '\0';
    9497        }
    95         str_append(ncwd_path_nc, cwd_size + 1 + size + 1, path);
     98        str_append(ncwd_path_nc, total_size, path);
    9699        ncwd_path = canonify(ncwd_path_nc, retlen);
    97100        if (!ncwd_path) {
  • uspace/lib/usb/include/usb/request.h

    rbdc8ab1 r9445aad  
    106106int usb_request_get_full_configuration_descriptor(usb_endpoint_pipe_t *, int,
    107107    void *, size_t, size_t *);
     108int usb_request_get_full_configuration_descriptor_alloc(usb_endpoint_pipe_t *,
     109    int, void **, size_t *);
    108110int usb_request_set_configuration(usb_endpoint_pipe_t *, uint8_t);
    109111
  • uspace/lib/usb/src/request.c

    rbdc8ab1 r9445aad  
    412412}
    413413
     414/** Retrieve full configuration descriptor, allocate space for it.
     415 *
     416 * The function takes care that full configuration descriptor is returned
     417 * (i.e. the function will fail when less data then descriptor.totalLength
     418 * is returned).
     419 *
     420 * @param[in] pipe Control endpoint pipe (session must be already started).
     421 * @param[in] index Configuration index.
     422 * @param[out] descriptor_ptr Where to store pointer to allocated buffer.
     423 * @param[out] descriptor_size Where to store the size of the descriptor.
     424 * @return Error code.
     425 */
     426int usb_request_get_full_configuration_descriptor_alloc(
     427    usb_endpoint_pipe_t *pipe, int index,
     428    void **descriptor_ptr, size_t *descriptor_size)
     429{
     430        int rc;
     431
     432        if (descriptor_ptr == NULL) {
     433                return EBADMEM;
     434        }
     435
     436        usb_standard_configuration_descriptor_t bare_config;
     437        rc = usb_request_get_bare_configuration_descriptor(pipe, index,
     438            &bare_config);
     439        if (rc != EOK) {
     440                return rc;
     441        }
     442
     443        if (bare_config.descriptor_type != USB_DESCTYPE_CONFIGURATION) {
     444                return ENOENT;
     445        }
     446        if (bare_config.total_length < sizeof(bare_config)) {
     447                return ELIMIT;
     448        }
     449
     450        void *buffer = malloc(bare_config.total_length);
     451        if (buffer == NULL) {
     452                return ENOMEM;
     453        }
     454
     455        size_t transferred = 0;
     456        rc = usb_request_get_full_configuration_descriptor(pipe, index,
     457            buffer, bare_config.total_length, &transferred);
     458        if (rc != EOK) {
     459                free(buffer);
     460                return rc;
     461        }
     462
     463        if (transferred != bare_config.total_length) {
     464                free(buffer);
     465                return ELIMIT;
     466        }
     467
     468        /* Everything looks okay, copy the pointers. */
     469
     470        *descriptor_ptr = buffer;
     471
     472        if (descriptor_size != NULL) {
     473                *descriptor_size = bare_config.total_length;
     474        }
     475
     476        return EOK;
     477}
     478
    414479/** Set configuration of USB device.
    415480 *
     
    504569 *
    505570 * @param[in] pipe Control endpoint pipe (session must be already started).
    506  * @param[in] index String index (in native endianess).
     571 * @param[in] index String index (in native endianess),
     572 *      first index has number 1 (index from descriptors can be used directly).
    507573 * @param[in] lang String language (in native endianess).
    508574 * @param[out] string_ptr Where to store allocated string in native encoding.
     
    515581                return EBADMEM;
    516582        }
    517         /* Index is actually one byte value. */
    518         if (index > 0xFF) {
     583        /*
     584         * Index is actually one byte value and zero index is used
     585         * to retrieve list of supported languages.
     586         */
     587        if ((index < 1) || (index > 0xFF)) {
    519588                return ERANGE;
    520589        }
Note: See TracChangeset for help on using the changeset viewer.