Changeset 9445aad in mainline for uspace/lib
- Timestamp:
- 2011-03-03T23:25:34Z (15 years ago)
- 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. - Location:
- uspace/lib
- Files:
-
- 4 edited
-
c/generic/loader.c (modified) (1 diff)
-
c/generic/vfs/vfs.c (modified) (3 diffs)
-
usb/include/usb/request.h (modified) (1 diff)
-
usb/src/request.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/loader.c
rbdc8ab1 r9445aad 160 160 int rc = async_data_write_start(ldr->phone_id, (void *) pa, pa_len); 161 161 if (rc != EOK) { 162 free(pa); 162 163 async_wait_for(req, NULL); 163 164 return rc; -
uspace/lib/c/generic/vfs/vfs.c
rbdc8ab1 r9445aad 69 69 char *ncwd_path; 70 70 char *ncwd_path_nc; 71 size_t total_size; 71 72 72 73 fibril_mutex_lock(&cwd_mutex); … … 77 78 return NULL; 78 79 } 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); 80 82 if (!ncwd_path_nc) { 81 83 fibril_mutex_unlock(&cwd_mutex); 82 84 return NULL; 83 85 } 84 str_cpy(ncwd_path_nc, cwd_size + 1 + size + 1, cwd_path);86 str_cpy(ncwd_path_nc, total_size, cwd_path); 85 87 ncwd_path_nc[cwd_size] = '/'; 86 88 ncwd_path_nc[cwd_size + 1] = '\0'; 87 89 } else { 88 ncwd_path_nc = malloc(size + 1); 90 total_size = size + 1; 91 ncwd_path_nc = malloc(total_size); 89 92 if (!ncwd_path_nc) { 90 93 fibril_mutex_unlock(&cwd_mutex); … … 93 96 ncwd_path_nc[0] = '\0'; 94 97 } 95 str_append(ncwd_path_nc, cwd_size + 1 + size + 1, path);98 str_append(ncwd_path_nc, total_size, path); 96 99 ncwd_path = canonify(ncwd_path_nc, retlen); 97 100 if (!ncwd_path) { -
uspace/lib/usb/include/usb/request.h
rbdc8ab1 r9445aad 106 106 int usb_request_get_full_configuration_descriptor(usb_endpoint_pipe_t *, int, 107 107 void *, size_t, size_t *); 108 int usb_request_get_full_configuration_descriptor_alloc(usb_endpoint_pipe_t *, 109 int, void **, size_t *); 108 110 int usb_request_set_configuration(usb_endpoint_pipe_t *, uint8_t); 109 111 -
uspace/lib/usb/src/request.c
rbdc8ab1 r9445aad 412 412 } 413 413 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 */ 426 int 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 414 479 /** Set configuration of USB device. 415 480 * … … 504 569 * 505 570 * @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). 507 573 * @param[in] lang String language (in native endianess). 508 574 * @param[out] string_ptr Where to store allocated string in native encoding. … … 515 581 return EBADMEM; 516 582 } 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)) { 519 588 return ERANGE; 520 589 }
Note:
See TracChangeset
for help on using the changeset viewer.
