Commit 8ddbc04f067e6f8c63f1e0f60a7d10bf9036fd9a

Authored by aliguori
1 parent 11c2fd3e

qcow2: Fix warnings in check_refcount() (Kevin Wolf)

From: Kevin Wolf <kwolf@redhat.com>

This code is currently only compiled when DEBUG_ALLOC is defined, so you
usually don't see compiler warnings on it. This patch series wants to enable
the code, so fix the format string warnings first.

While we're at it, let's print error messages to stderr.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7213 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 13 additions and 10 deletions
block-qcow2.c
... ... @@ -2583,10 +2583,12 @@ static void inc_refcounts(BlockDriverState *bs,
2583 2583 cluster_offset += s->cluster_size) {
2584 2584 k = cluster_offset >> s->cluster_bits;
2585 2585 if (k < 0 || k >= refcount_table_size) {
2586   - printf("ERROR: invalid cluster offset=0x%llx\n", cluster_offset);
  2586 + fprintf(stderr, "ERROR: invalid cluster offset=0x%" PRIx64 "\n",
  2587 + cluster_offset);
2587 2588 } else {
2588 2589 if (++refcount_table[k] == 0) {
2589   - printf("ERROR: overflow cluster offset=0x%llx\n", cluster_offset);
  2590 + fprintf(stderr, "ERROR: overflow cluster offset=0x%" PRIx64
  2591 + "\n", cluster_offset);
2590 2592 }
2591 2593 }
2592 2594 }
... ... @@ -2623,8 +2625,8 @@ static int check_refcounts_l1(BlockDriverState *bs,
2623 2625 if (check_copied) {
2624 2626 refcount = get_refcount(bs, (l2_offset & ~QCOW_OFLAG_COPIED) >> s->cluster_bits);
2625 2627 if ((refcount == 1) != ((l2_offset & QCOW_OFLAG_COPIED) != 0)) {
2626   - printf("ERROR OFLAG_COPIED: l2_offset=%llx refcount=%d\n",
2627   - l2_offset, refcount);
  2628 + fprintf(stderr, "ERROR OFLAG_COPIED: l2_offset=%" PRIx64
  2629 + " refcount=%d\n", l2_offset, refcount);
2628 2630 }
2629 2631 }
2630 2632 l2_offset &= ~QCOW_OFLAG_COPIED;
... ... @@ -2635,8 +2637,9 @@ static int check_refcounts_l1(BlockDriverState *bs,
2635 2637 if (offset != 0) {
2636 2638 if (offset & QCOW_OFLAG_COMPRESSED) {
2637 2639 if (offset & QCOW_OFLAG_COPIED) {
2638   - printf("ERROR: cluster %lld: copied flag must never be set for compressed clusters\n",
2639   - offset >> s->cluster_bits);
  2640 + fprintf(stderr, "ERROR: cluster %" PRId64 ": "
  2641 + "copied flag must never be set for compressed "
  2642 + "clusters\n", offset >> s->cluster_bits);
2640 2643 offset &= ~QCOW_OFLAG_COPIED;
2641 2644 }
2642 2645 nb_csectors = ((offset >> s->csize_shift) &
... ... @@ -2649,8 +2652,8 @@ static int check_refcounts_l1(BlockDriverState *bs,
2649 2652 if (check_copied) {
2650 2653 refcount = get_refcount(bs, (offset & ~QCOW_OFLAG_COPIED) >> s->cluster_bits);
2651 2654 if ((refcount == 1) != ((offset & QCOW_OFLAG_COPIED) != 0)) {
2652   - printf("ERROR OFLAG_COPIED: offset=%llx refcount=%d\n",
2653   - offset, refcount);
  2655 + fprintf(stderr, "ERROR OFLAG_COPIED: offset=%"
  2656 + PRIx64 " refcount=%d\n", offset, refcount);
2654 2657 }
2655 2658 }
2656 2659 offset &= ~QCOW_OFLAG_COPIED;
... ... @@ -2670,7 +2673,7 @@ static int check_refcounts_l1(BlockDriverState *bs,
2670 2673 qemu_free(l2_table);
2671 2674 return 0;
2672 2675 fail:
2673   - printf("ERROR: I/O error in check_refcounts_l1\n");
  2676 + fprintf(stderr, "ERROR: I/O error in check_refcounts_l1\n");
2674 2677 qemu_free(l1_table);
2675 2678 qemu_free(l2_table);
2676 2679 return -EIO;
... ... @@ -2722,7 +2725,7 @@ static void check_refcounts(BlockDriverState *bs)
2722 2725 refcount1 = get_refcount(bs, i);
2723 2726 refcount2 = refcount_table[i];
2724 2727 if (refcount1 != refcount2)
2725   - printf("ERROR cluster %d refcount=%d reference=%d\n",
  2728 + fprintf(stderr, "ERROR cluster %d refcount=%d reference=%d\n",
2726 2729 i, refcount1, refcount2);
2727 2730 }
2728 2731  
... ...