Commit ec3757de320f5cc847fb51bff8bc99a9d264389d

Authored by bellard
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,12 +164,12 @@ void help(void)
164 164
165 static void get_human_readable_size(char *buf, int buf_size, int64_t size) 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 int64_t base; 168 int64_t base;
169 int i; 169 int i;
170 170
171 if (size <= 999) { 171 if (size <= 999) {
172 - snprintf(buf, buf_size, "%lld", (long long) size); 172 + snprintf(buf, buf_size, "%" PRId64, size);
173 } else { 173 } else {
174 base = 1024; 174 base = 1024;
175 for(i = 0; i < NB_SUFFIXES; i++) { 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,8 +179,8 @@ static void get_human_readable_size(char *buf, int buf_size, int64_t size)
179 suffixes[i]); 179 suffixes[i]);
180 break; 180 break;
181 } else if (size < (1000 * base) || i == (NB_SUFFIXES - 1)) { 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 suffixes[i]); 184 suffixes[i]);
185 break; 185 break;
186 } 186 }
@@ -373,7 +373,7 @@ static int img_create(int argc, char **argv) @@ -373,7 +373,7 @@ static int img_create(int argc, char **argv)
373 printf(", backing_file=%s", 373 printf(", backing_file=%s",
374 base_filename); 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 ret = bdrv_create(drv, filename, size / 512, base_filename, encrypted); 377 ret = bdrv_create(drv, filename, size / 512, base_filename, encrypted);
378 if (ret < 0) { 378 if (ret < 0) {
379 if (ret == -ENOTSUP) { 379 if (ret == -ENOTSUP) {
@@ -563,7 +563,8 @@ static int img_convert(int argc, char **argv) @@ -563,7 +563,8 @@ static int img_convert(int argc, char **argv)
563 memset(buf + n * 512, 0, cluster_size - n * 512); 563 memset(buf + n * 512, 0, cluster_size - n * 512);
564 if (is_not_zero(buf, cluster_size)) { 564 if (is_not_zero(buf, cluster_size)) {
565 if (qcow_compress_cluster(out_bs, sector_num, buf) != 0) 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 sector_num += n; 569 sector_num += n;
569 } 570 }
@@ -680,10 +681,10 @@ static int img_info(int argc, char **argv) @@ -680,10 +681,10 @@ static int img_info(int argc, char **argv)
680 allocated_size); 681 allocated_size);
681 printf("image: %s\n" 682 printf("image: %s\n"
682 "file format: %s\n" 683 "file format: %s\n"
683 - "virtual size: %s (%lld bytes)\n" 684 + "virtual size: %s (%" PRId64 " bytes)\n"
684 "disk size: %s\n", 685 "disk size: %s\n",
685 filename, fmt_name, size_buf, 686 filename, fmt_name, size_buf,
686 - (long long) (total_sectors * 512), 687 + (total_sectors * 512),
687 dsize_buf); 688 dsize_buf);
688 if (bdrv_is_encrypted(bs)) 689 if (bdrv_is_encrypted(bs))
689 printf("encrypted: yes\n"); 690 printf("encrypted: yes\n");
@@ -58,6 +58,8 @@ static inline char *realpath(const char *path, char *resolved_path) @@ -58,6 +58,8 @@ static inline char *realpath(const char *path, char *resolved_path)
58 _fullpath(resolved_path, path, _MAX_PATH); 58 _fullpath(resolved_path, path, _MAX_PATH);
59 return resolved_path; 59 return resolved_path;
60 } 60 }
  61 +
  62 +#define PRId64 "I64d"
61 #endif 63 #endif
62 64
63 #ifdef QEMU_TOOL 65 #ifdef QEMU_TOOL