Commit ec3757de320f5cc847fb51bff8bc99a9d264389d
1 parent
e8445331
use C99 64 bit printf format to ease win32 porting
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1974 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
2 changed files
with
11 additions
and
8 deletions
qemu-img.c
... | ... | @@ -164,12 +164,12 @@ void help(void) |
164 | 164 | |
165 | 165 | static void get_human_readable_size(char *buf, int buf_size, int64_t size) |
166 | 166 | { |
167 | - char suffixes[NB_SUFFIXES] = "KMGT"; | |
167 | + static const char suffixes[NB_SUFFIXES] = "KMGT"; | |
168 | 168 | int64_t base; |
169 | 169 | int i; |
170 | 170 | |
171 | 171 | if (size <= 999) { |
172 | - snprintf(buf, buf_size, "%lld", (long long) size); | |
172 | + snprintf(buf, buf_size, "%" PRId64, size); | |
173 | 173 | } else { |
174 | 174 | base = 1024; |
175 | 175 | for(i = 0; i < NB_SUFFIXES; i++) { |
... | ... | @@ -179,8 +179,8 @@ static void get_human_readable_size(char *buf, int buf_size, int64_t size) |
179 | 179 | suffixes[i]); |
180 | 180 | break; |
181 | 181 | } else if (size < (1000 * base) || i == (NB_SUFFIXES - 1)) { |
182 | - snprintf(buf, buf_size, "%lld%c", | |
183 | - (long long) ((size + (base >> 1)) / base), | |
182 | + snprintf(buf, buf_size, "%" PRId64 "%c", | |
183 | + ((size + (base >> 1)) / base), | |
184 | 184 | suffixes[i]); |
185 | 185 | break; |
186 | 186 | } |
... | ... | @@ -373,7 +373,7 @@ static int img_create(int argc, char **argv) |
373 | 373 | printf(", backing_file=%s", |
374 | 374 | base_filename); |
375 | 375 | } |
376 | - printf(", size=%lld kB\n", (long long) (size / 1024)); | |
376 | + printf(", size=%" PRId64 " kB\n", (int64_t) (size / 1024)); | |
377 | 377 | ret = bdrv_create(drv, filename, size / 512, base_filename, encrypted); |
378 | 378 | if (ret < 0) { |
379 | 379 | if (ret == -ENOTSUP) { |
... | ... | @@ -563,7 +563,8 @@ static int img_convert(int argc, char **argv) |
563 | 563 | memset(buf + n * 512, 0, cluster_size - n * 512); |
564 | 564 | if (is_not_zero(buf, cluster_size)) { |
565 | 565 | if (qcow_compress_cluster(out_bs, sector_num, buf) != 0) |
566 | - error("error while compressing sector %lld", sector_num); | |
566 | + error("error while compressing sector %" PRId64, | |
567 | + sector_num); | |
567 | 568 | } |
568 | 569 | sector_num += n; |
569 | 570 | } |
... | ... | @@ -680,10 +681,10 @@ static int img_info(int argc, char **argv) |
680 | 681 | allocated_size); |
681 | 682 | printf("image: %s\n" |
682 | 683 | "file format: %s\n" |
683 | - "virtual size: %s (%lld bytes)\n" | |
684 | + "virtual size: %s (%" PRId64 " bytes)\n" | |
684 | 685 | "disk size: %s\n", |
685 | 686 | filename, fmt_name, size_buf, |
686 | - (long long) (total_sectors * 512), | |
687 | + (total_sectors * 512), | |
687 | 688 | dsize_buf); |
688 | 689 | if (bdrv_is_encrypted(bs)) |
689 | 690 | printf("encrypted: yes\n"); | ... | ... |