Changeset 0435fe41 in mainline for uspace/lib/gpt/libgpt.c
- Timestamp:
- 2013-08-27T00:32:08Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 61ab4a9, 802898f
- Parents:
- 493b881
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/gpt/libgpt.c
r493b881 r0435fe41 48 48 #include <checksum.h> 49 49 #include <mem.h> 50 #include <sys/typefmt.h> 51 50 52 51 53 #include "libgpt.h" … … 55 57 static int extend_part_array(gpt_partitions_t *); 56 58 static int reduce_part_array(gpt_partitions_t *); 57 //static long long nearest_larger_int(double);58 59 static uint8_t get_byte(const char *); 59 60 static bool check_overlap(gpt_part_t *, gpt_part_t *); … … 313 314 fillries * ent_size); 314 315 315 if (uint32_t_le2host(label->gpt->header->pe_array_crc32) != crc)316 if (uint32_t_le2host(label->gpt->header->pe_array_crc32) != crc) 316 317 { 317 318 rc = EBADCHECKSUM; … … 369 370 370 371 /* Perform checks */ 371 gpt_part_foreach (label, p) {372 gpt_part_foreach (label, p) { 372 373 if (gpt_get_part_type(p) == GPT_PTE_UNUSED) 373 374 continue; … … 375 376 if (!check_encaps(p, n_blocks, gpt_space)) { 376 377 rc = ERANGE; 377 printf("encaps with: %llu, %llu, %llu\n", n_blocks, gpt_space, gpt_get_end_lba(p)); 378 printf("encaps with: %" PRIuOFF64 ", %" PRIu64 ", %" PRIu64 "\n", 379 n_blocks, gpt_space, gpt_get_end_lba(p)); 378 380 goto fail; 379 381 } 380 382 381 gpt_part_foreach (label, q) {383 gpt_part_foreach (label, q) { 382 384 if (p == q) 383 385 continue; … … 385 387 if (gpt_get_part_type(p) != GPT_PTE_UNUSED) { 386 388 if (check_overlap(p, q)) { 387 printf("overlap with: %llu, %llu\n", gpt_get_start_lba(p), gpt_get_start_lba(q)); 389 printf("overlap with: %" PRIu64 ", %" PRIu64 "\n", 390 gpt_get_start_lba(p), gpt_get_start_lba(q)); 388 391 rc = ERANGE; 389 392 goto fail; … … 709 712 void gpt_set_random_uuid(uint8_t * uuid) 710 713 { 711 srandom((unsigned int) uuid);714 srandom((unsigned int) (size_t) uuid); 712 715 713 716 unsigned int i; … … 786 789 size_t nsize = p->arr_size * 2; 787 790 gpt_entry_t * tmp = malloc(nsize * sizeof(gpt_entry_t)); 788 if (tmp == NULL) {791 if (tmp == NULL) { 789 792 errno = ENOMEM; 790 793 return -1; … … 801 804 static int reduce_part_array(gpt_partitions_t * p) 802 805 { 803 if (p->arr_size > GPT_MIN_PART_NUM) {806 if (p->arr_size > GPT_MIN_PART_NUM) { 804 807 unsigned int nsize = p->arr_size / 2; 805 808 nsize = nsize > GPT_MIN_PART_NUM ? nsize : GPT_MIN_PART_NUM; 806 809 gpt_entry_t * tmp = malloc(nsize * sizeof(gpt_entry_t)); 807 if (tmp == NULL)810 if (tmp == NULL) 808 811 return ENOMEM; 809 812 … … 816 819 return 0; 817 820 } 818 819 /*static long long nearest_larger_int(double a)820 {821 if ((long long) a == a) {822 return (long long) a;823 }824 825 return ((long long) a) + 1;826 }*/827 821 828 822 /* Parse a byte from a string in hexadecimal
Note:
See TracChangeset
for help on using the changeset viewer.