qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 1/3] Fix %lld or %llx printf format use


From: Blue Swirl
Subject: [Qemu-devel] [PATCH 1/3] Fix %lld or %llx printf format use
Date: Sat, 15 May 2010 23:49:20 +0300

Signed-off-by: Blue Swirl <address@hidden>
---
 audio/audio_template.h  |    2 +-
 block/curl.c            |    9 ++++---
 block/parallels.c       |    7 ++++-
 block/qcow2.c           |    8 ++++--
 darwin-user/commpage.c  |    2 +-
 darwin-user/syscall.c   |    2 +-
 hw/vga.c                |    2 +-
 hw/vhost_net.c          |    2 +-
 ia64-dis.c              |    9 +++++--
 nbd.c                   |    4 +-
 qemu-img.c              |   10 ++++----
 qemu-io.c               |   57 ++++++++++++++++++++++++-----------------------
 target-cris/translate.c |    4 +-
 target-ppc/translate.c  |    7 +++--
 target-sparc/helper.c   |    2 +-
 15 files changed, 69 insertions(+), 58 deletions(-)

diff --git a/audio/audio_template.h b/audio/audio_template.h
index 6b19848..2f5224b 100644
--- a/audio/audio_template.h
+++ b/audio/audio_template.h
@@ -541,7 +541,7 @@ uint64_t glue (AUD_get_elapsed_usec_, TYPE) (SW
*sw, QEMUAudioTimeStamp *ts)

     cur_ts = sw->hw->ts_helper;
     old_ts = ts->old_ts;
-    /* dolog ("cur %lld old %lld\n", cur_ts, old_ts); */
+    /* dolog ("cur %" PRId64 " old %" PRId64 "\n", cur_ts, old_ts); */

     if (cur_ts >= old_ts) {
         delta = cur_ts - old_ts;
diff --git a/block/curl.c b/block/curl.c
index b944740..94b451c 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -118,7 +118,7 @@ static size_t curl_read_cb(void *ptr, size_t size,
size_t nmemb, void *opaque)
     size_t realsize = size * nmemb;
     int i;

-    DPRINTF("CURL: Just reading %lld bytes\n", (unsigned long long)realsize);
+    DPRINTF("CURL: Just reading %" PRId64 " bytes\n", (uint64_t)realsize);

     if (!s || !s->orig_buf)
         goto read_end;
@@ -368,7 +368,7 @@ static int curl_open(BlockDriverState *bs, const
char *filename, int flags)
         s->len = (size_t)d;
     else if(!s->len)
         goto out;
-    DPRINTF("CURL: Size = %lld\n", (long long)s->len);
+    DPRINTF("CURL: Size = %" PRId64 "\n", (int64_t)s->len);

     curl_clean_state(state);
     curl_easy_cleanup(state->curl);
@@ -450,8 +450,9 @@ static BlockDriverAIOCB
*curl_aio_readv(BlockDriverState *bs,
     state->orig_buf = qemu_malloc(state->buf_len);
     state->acb[0] = acb;

-    snprintf(state->range, 127, "%lld-%lld", (long long)start, (long long)end);
-    DPRINTF("CURL (AIO): Reading %d at %lld (%s)\n", (nb_sectors *
SECTOR_SIZE), start, state->range);
+    snprintf(state->range, 127, "%" PRId64 "-%" PRId64,
(int64_t)start, (int64_t)end);
+    DPRINTF("CURL (AIO): Reading %d at %" PRId64 " (%s)\n",
+            (nb_sectors * SECTOR_SIZE), start, state->range);
     curl_easy_setopt(state->curl, CURLOPT_RANGE, state->range);

     curl_multi_add_handle(s->multi, state->curl);
diff --git a/block/parallels.c b/block/parallels.c
index b217101..e0eb4dc 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -129,8 +129,11 @@ static inline int seek_to_sector(BlockDriverState
*bs, int64_t sector_num)

     position = (uint64_t)(s->catalog_bitmap[index] + offset) * 512;

-//    fprintf(stderr, "sector: %llx index=%x offset=%x pointer=%x
position=%x\n",
-//     sector_num, index, offset, s->catalog_bitmap[index], position);
+    /*
+    fprintf(stderr, "sector: %" PRIx64 " index=%x offset=%x pointer=%x"
+            "position=%x\n", sector_num, index, offset,
+            s->catalog_bitmap[index], position);
+    */

     if (lseek(s->fd, position, SEEK_SET) != position)
        return -1;
diff --git a/block/qcow2.c b/block/qcow2.c
index ebad4e1..e7d0676 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -93,8 +93,9 @@ static int qcow_read_extensions(BlockDriverState
*bs, uint64_t start_offset,
 #endif

         if (bdrv_pread(bs->file, offset, &ext, sizeof(ext)) != sizeof(ext)) {
-            fprintf(stderr, "qcow_handle_extension: ERROR: pread fail
from offset %llu\n",
-                    (unsigned long long)offset);
+            fprintf(stderr, "qcow_handle_extension: ERROR: "
+                    "pread fail from offset %" PRIu64 "\n",
+                    offset);
             return 1;
         }
         be32_to_cpus(&ext.magic);
@@ -1245,7 +1246,8 @@ static void dump_refcounts(BlockDriverState *bs)
         k++;
         while (k < nb_clusters && get_refcount(bs, k) == refcount)
             k++;
-        printf("%lld: refcount=%d nb=%lld\n", k, refcount, k - k1);
+        printf("%" PRId64 ": refcount=%d nb=%" PRId64 "\n", k, refcount,
+               k - k1);
     }
 }
 #endif
diff --git a/darwin-user/commpage.c b/darwin-user/commpage.c
index 2b41bc5..f6aa71e 100644
--- a/darwin-user/commpage.c
+++ b/darwin-user/commpage.c
@@ -237,7 +237,7 @@ void do_compare_and_swap64(void *cpu_env, int num)
     uint64_t *value = (uint64_t*)((CPUX86State*)cpu_env)->regs[R_ESI];
     old = (uint64_t)((uint64_t)((CPUX86State*)cpu_env)->regs[R_EDX])
<< 32 | (uint64_t)((CPUX86State*)cpu_env)->regs[R_EAX];

-    DPRINTF("commpage: compare_and_swap64(%llx,new,%p)\n", old, value);
+    DPRINTF("commpage: compare_and_swap64(%" PRIx64 ",new,%p)\n", old, value);
     swapped_val = tswap64(*value);

     if(old == swapped_val)
diff --git a/darwin-user/syscall.c b/darwin-user/syscall.c
index d774ad3..060acc8 100644
--- a/darwin-user/syscall.c
+++ b/darwin-user/syscall.c
@@ -858,7 +858,7 @@ long no_syscall(void *cpu_env, int num);

 long do_pread(uint32_t arg1, void * arg2, size_t arg3, off_t arg4)
 {
-    DPRINTF("0x%x, %p, 0x%lx, 0x%llx\n", arg1, arg2, arg3, arg4);
+    DPRINTF("0x%x, %p, 0x%lx, 0x%" PRIx64 "\n", arg1, arg2, arg3, arg4);
     long ret = pread(arg1, arg2, arg3, arg4);
     return ret;
 }
diff --git a/hw/vga.c b/hw/vga.c
index 87a1bb0..01de1e1 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -232,7 +232,7 @@ static void
vga_precise_update_retrace_info(VGACommonState *s)
         "clocking_mode = %d\n"
         "clock_sel = %d %d\n"
         "dots = %d\n"
-        "ticks/char = %lld\n"
+        "ticks/char = %" PRId64 "\n"
         "\n",
         (double) get_ticks_per_sec() / (r->ticks_per_char * r->total_chars),
         htotal_chars,
diff --git a/hw/vhost_net.c b/hw/vhost_net.c
index 2e292ee..26dae79 100644
--- a/hw/vhost_net.c
+++ b/hw/vhost_net.c
@@ -99,7 +99,7 @@ struct vhost_net *vhost_net_init(VLANClientState
*backend, int devfd)
         goto fail;
     }
     if (~net->dev.features & net->dev.backend_features) {
-        fprintf(stderr, "vhost lacks feature mask %llu for backend\n",
+        fprintf(stderr, "vhost lacks feature mask %" PRIu64 " for backend\n",
                 ~net->dev.features & net->dev.backend_features);
         vhost_dev_cleanup(&net->dev);
         goto fail;
diff --git a/ia64-dis.c b/ia64-dis.c
index da73a98..2886df3 100644
--- a/ia64-dis.c
+++ b/ia64-dis.c
@@ -10560,11 +10560,14 @@ print_insn_ia64 (bfd_vma memaddr, struct
disassemble_info *info)
            if (str)
              (*info->fprintf_func) (info->stream, "%s", str);
            else if (odesc->flags & IA64_OPND_FLAG_DECIMAL_SIGNED)
-             (*info->fprintf_func) (info->stream, "%lld", (long long) value);
+              (*info->fprintf_func) (info->stream, "%" PRId64,
+                                     (int64_t) value);
            else if (odesc->flags & IA64_OPND_FLAG_DECIMAL_UNSIGNED)
-             (*info->fprintf_func) (info->stream, "%llu", (long long) value);
+              (*info->fprintf_func) (info->stream, "%" PRIu64,
+                                     (uint64_t) value);
            else
-             (*info->fprintf_func) (info->stream, "0x%llx", (long long) value);
+              (*info->fprintf_func) (info->stream, "0x%" PRIx64,
+                                     (uint64_t) value);
            break;

          case IA64_OPND_CLASS_REL:
diff --git a/nbd.c b/nbd.c
index 337eeba..4d9fa58 100644
--- a/nbd.c
+++ b/nbd.c
@@ -353,8 +353,8 @@ int nbd_init(int fd, int csock, off_t size, size_t
blocksize)
                return -1;
        }

-       TRACE("Setting size to %llu block(s)",
-             (unsigned long long)(size / blocksize));
+        TRACE("Setting size to %" PRIu64 " block(s)",
+              (uint64_t)(size / blocksize));

        if (ioctl(fd, NBD_SET_SIZE_BLOCKS, size / blocksize) == -1) {
                int serrno = errno;
diff --git a/qemu-img.c b/qemu-img.c
index d3c30a7..cb007b7 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -701,9 +701,9 @@ static int img_convert(int argc, char **argv)
                     bs_offset += bs_sectors;
                     bdrv_get_geometry(bs[bs_i], &bs_sectors);
                     bs_num = 0;
-                    /* printf("changing part: sector_num=%lld, "
-                       "bs_i=%d, bs_offset=%lld, bs_sectors=%lld\n",
-                       sector_num, bs_i, bs_offset, bs_sectors); */
+                    /* printf("changing part: sector_num=%" PRId64 ", "
+                       "bs_i=%d, bs_offset=%" PRId64 ", bs_sectors=%" PRId64
+                       "\n", sector_num, bs_i, bs_offset, bs_sectors); */
                 }
                 assert (bs_num < bs_sectors);

@@ -749,8 +749,8 @@ static int img_convert(int argc, char **argv)
                 assert (bs_i < bs_n);
                 bs_offset += bs_sectors;
                 bdrv_get_geometry(bs[bs_i], &bs_sectors);
-                /* printf("changing part: sector_num=%lld, bs_i=%d, "
-                  "bs_offset=%lld, bs_sectors=%lld\n",
+                /* printf("changing part: sector_num=%" PRId64 ", bs_i=%d, "
+                  "bs_offset=%" PRId64 ", bs_sectors=%" PRId64 "\n",
                    sector_num, bs_i, bs_offset, bs_sectors); */
             }

diff --git a/qemu-io.c b/qemu-io.c
index 8517b90..030dedd 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -84,7 +84,7 @@ dump_buffer(const void *buffer, int64_t offset, int len)
        for (i = 0, p = buffer; i < len; i += 16) {
                const uint8_t *s = p;

-               printf("%08llx:  ", (unsigned long long)offset + i);
+                printf("%08" PRIx64 ":  ", offset + i);
                for (j = 0; j < 16 && i + j < len; j++, p++)
                        printf("%02x ", *p);
                printf(" ");
@@ -108,8 +108,8 @@ print_report(const char *op, struct timeval *t,
int64_t offset,
        if (!Cflag) {
                cvtstr((double)total, s1, sizeof(s1));
                cvtstr(tdiv((double)total, *t), s2, sizeof(s2));
-               printf("%s %d/%d bytes at offset %lld\n",
-                       op, total, count, (long long)offset);
+                printf("%s %d/%d bytes at offset %" PRId64 "\n",
+                       op, total, count, offset);
                printf("%s, %d ops; %s (%s/sec and %.4f ops/sec)\n",
                        s1, cnt, ts, s2, tdiv((double)cnt, *t));
        } else {/* bytes,ops,time,bytes/sec,ops/sec */
@@ -150,8 +150,9 @@ create_iovec(QEMUIOVector *qiov, char **argv, int
nr_iov, int pattern)
                }

                if (len & 0x1ff) {
-                       printf("length argument %lld is not sector aligned\n",
-                               len);
+                        printf("length argument %" PRId64
+                               " is not sector aligned\n",
+                               (uint64_t)len);
                        goto fail;
                }

@@ -398,8 +399,8 @@ read_f(int argc, char **argv)

        if (!pflag)
                if (offset & 0x1ff) {
-                       printf("offset %lld is not sector aligned\n",
-                               (long long)offset);
+                        printf("offset %" PRId64 " is not sector aligned\n",
+                               offset);
                        return 0;

                if (count & 0x1ff) {
@@ -429,9 +430,9 @@ read_f(int argc, char **argv)
                void* cmp_buf = malloc(pattern_count);
                memset(cmp_buf, pattern, pattern_count);
                if (memcmp(buf + pattern_offset, cmp_buf, pattern_count)) {
-                       printf("Pattern verification failed at offset %lld, "
-                               "%d bytes\n",
-                               (long long) offset + pattern_offset, 
pattern_count);
+                       printf("Pattern verification failed at offset %"
+                               PRId64 ", %d bytes\n",
+                               offset + pattern_offset, pattern_count);
                }
                free(cmp_buf);
        }
@@ -533,8 +534,8 @@ readv_f(int argc, char **argv)
        optind++;

        if (offset & 0x1ff) {
-               printf("offset %lld is not sector aligned\n",
-                       (long long)offset);
+                printf("offset %" PRId64 " is not sector aligned\n",
+                       offset);
                return 0;
        }

@@ -554,9 +555,9 @@ readv_f(int argc, char **argv)
                void* cmp_buf = malloc(qiov.size);
                memset(cmp_buf, pattern, qiov.size);
                if (memcmp(buf, cmp_buf, qiov.size)) {
-                       printf("Pattern verification failed at offset %lld, "
-                               "%zd bytes\n",
-                               (long long) offset, qiov.size);
+                       printf("Pattern verification failed at offset %"
+                               PRId64 ", %zd bytes\n",
+                               offset, qiov.size);
                }
                free(cmp_buf);
        }
@@ -669,8 +670,8 @@ write_f(int argc, char **argv)

        if (!pflag) {
                if (offset & 0x1ff) {
-                       printf("offset %lld is not sector aligned\n",
-                               (long long)offset);
+                        printf("offset %" PRId64 " is not sector aligned\n",
+                               offset);
                        return 0;
                }

@@ -783,8 +784,8 @@ writev_f(int argc, char **argv)
        optind++;

        if (offset & 0x1ff) {
-               printf("offset %lld is not sector aligned\n",
-                       (long long)offset);
+                printf("offset %" PRId64 " is not sector aligned\n",
+                       offset);
                return 0;
        }

@@ -868,9 +869,9 @@ aio_read_done(void *opaque, int ret)

                memset(cmp_buf, ctx->pattern, ctx->qiov.size);
                if (memcmp(ctx->buf, cmp_buf, ctx->qiov.size)) {
-                       printf("Pattern verification failed at offset %lld, "
-                               "%zd bytes\n",
-                               (long long) ctx->offset, ctx->qiov.size);
+                       printf("Pattern verification failed at offset %"
+                               PRId64 ", %zd bytes\n",
+                               ctx->offset, ctx->qiov.size);
                }
                free(cmp_buf);
        }
@@ -969,8 +970,8 @@ aio_read_f(int argc, char **argv)
        optind++;

        if (ctx->offset & 0x1ff) {
-               printf("offset %lld is not sector aligned\n",
-                       (long long)ctx->offset);
+               printf("offset %" PRId64 " is not sector aligned\n",
+                       ctx->offset);
                free(ctx);
                return 0;
        }
@@ -1064,8 +1065,8 @@ aio_write_f(int argc, char **argv)
        optind++;

        if (ctx->offset & 0x1ff) {
-               printf("offset %lld is not sector aligned\n",
-                       (long long)ctx->offset);
+               printf("offset %" PRId64 " is not sector aligned\n",
+                       ctx->offset);
                free(ctx);
                return 0;
        }
@@ -1214,8 +1215,8 @@ alloc_f(int argc, char **argv)

        offset = cvtnum(argv[1]);
        if (offset & 0x1ff) {
-               printf("offset %lld is not sector aligned\n",
-                       (long long)offset);
+                printf("offset %" PRId64 " is not sector aligned\n",
+                       offset);
                return 0;
        }

diff --git a/target-cris/translate.c b/target-cris/translate.c
index a7014fa..6c1d9e0 100644
--- a/target-cris/translate.c
+++ b/target-cris/translate.c
@@ -3226,14 +3226,14 @@ gen_intermediate_code_internal(CPUState *env,
TranslationBlock *tb,

        if (qemu_loglevel_mask(CPU_LOG_TB_IN_ASM)) {
                qemu_log(
-                       "srch=%d pc=%x %x flg=%llx bt=%x ds=%u ccs=%x\n"
+                        "srch=%d pc=%x %x flg=%" PRIx64 " bt=%x ds=%u ccs=%x\n"
                        "pid=%x usp=%x\n"
                        "%x.%x.%x.%x\n"
                        "%x.%x.%x.%x\n"
                        "%x.%x.%x.%x\n"
                        "%x.%x.%x.%x\n",
                        search_pc, dc->pc, dc->ppc,
-                       (unsigned long long)tb->flags,
+                        (uint64_t)tb->flags,
                        env->btarget, (unsigned)tb->flags & 7,
                        env->pregs[PR_CCS],
                        env->pregs[PR_PID], env->pregs[PR_USP],
diff --git a/target-ppc/translate.c b/target-ppc/translate.c
index 86cca51..66e1c0d 100644
--- a/target-ppc/translate.c
+++ b/target-ppc/translate.c
@@ -8918,7 +8918,7 @@ void cpu_dump_statistics (CPUState *env, FILE*f,
                         if (handler->count == 0)
                             continue;
                         cpu_fprintf(f, "%02x %02x %02x (%02x %04d) %16s: "
-                                    "%016llx %lld\n",
+                                    "%016" PRIx64 " %" PRId64 "\n",
                                     op1, op2, op3, op1, (op3 << 5) | op2,
                                     handler->oname,
                                     handler->count, handler->count);
@@ -8927,7 +8927,7 @@ void cpu_dump_statistics (CPUState *env, FILE*f,
                     if (handler->count == 0)
                         continue;
                     cpu_fprintf(f, "%02x %02x    (%02x %04d) %16s: "
-                                "%016llx %lld\n",
+                                "%016" PRIx64 " %" PRId64 "\n",
                                 op1, op2, op1, op2, handler->oname,
                                 handler->count, handler->count);
                 }
@@ -8935,7 +8935,8 @@ void cpu_dump_statistics (CPUState *env, FILE*f,
         } else {
             if (handler->count == 0)
                 continue;
-            cpu_fprintf(f, "%02x       (%02x     ) %16s: %016llx %lld\n",
+            cpu_fprintf(f, "%02x       (%02x     ) %16s: %016" PRIx64
+                        " %" PRId64 "\n",
                         op1, op1, handler->oname,
                         handler->count, handler->count);
         }
diff --git a/target-sparc/helper.c b/target-sparc/helper.c
index 582de10..6ba80f7 100644
--- a/target-sparc/helper.c
+++ b/target-sparc/helper.c
@@ -1342,7 +1342,7 @@ static int cpu_sparc_find_by_name(sparc_def_t
*cpu_def, const char *cpu_model)
                 }
                 cpu_def->iu_version = iu_version;
 #ifdef DEBUG_FEATURES
-                fprintf(stderr, "iu_version %llx\n", iu_version);
+                fprintf(stderr, "iu_version %" PRIx64 "\n", iu_version);
 #endif
             } else if (!strcmp(featurestr, "fpu_version")) {
                 char *err;
-- 
1.6.2.4



reply via email to

[Prev in Thread] Current Thread [Next in Thread]