diff mbox

vmdk: Fix %d and %lld to PRI* in format strings

Message ID 1397705677-29173-1-git-send-email-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng April 17, 2014, 3:34 a.m. UTC
Signed-off-by: Fam Zheng <famz@redhat.com>
---
 block/vmdk.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Kevin Wolf April 17, 2014, 8:28 a.m. UTC | #1
Am 17.04.2014 um 05:34 hat Fam Zheng geschrieben:
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  block/vmdk.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)

Thanks, applied to the block branch.

> @@ -1720,7 +1721,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
>          "\n"
>          "ddb.virtualHWVersion = \"%d\"\n"
>          "ddb.geometry.cylinders = \"%" PRId64 "\"\n"
> -        "ddb.geometry.heads = \"%d\"\n"
> +        "ddb.geometry.heads = \"%" PRIu32 "\"\n"
>          "ddb.geometry.sectors = \"63\"\n"
>          "ddb.adapterType = \"%s\"\n";

The same template also has:

        "parentCID=%x\n"

This should be changed to PRIx32 in a follow-up patch.

Kevin
Fam Zheng April 17, 2014, 9:35 a.m. UTC | #2
On Thu, 04/17 10:28, Kevin Wolf wrote:
> Am 17.04.2014 um 05:34 hat Fam Zheng geschrieben:
> > Signed-off-by: Fam Zheng <famz@redhat.com>
> > ---
> >  block/vmdk.c | 13 +++++++------
> >  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> Thanks, applied to the block branch.
> 
> > @@ -1720,7 +1721,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
> >          "\n"
> >          "ddb.virtualHWVersion = \"%d\"\n"
> >          "ddb.geometry.cylinders = \"%" PRId64 "\"\n"
> > -        "ddb.geometry.heads = \"%d\"\n"
> > +        "ddb.geometry.heads = \"%" PRIu32 "\"\n"
> >          "ddb.geometry.sectors = \"63\"\n"
> >          "ddb.adapterType = \"%s\"\n";
> 
> The same template also has:
> 
>         "parentCID=%x\n"
> 
> This should be changed to PRIx32 in a follow-up patch.
> 

Thanks for noticing this, I missed it because I only looked for "%.*d"...

Will send a follow-up patch.

Fam
diff mbox

Patch

diff --git a/block/vmdk.c b/block/vmdk.c
index b69988d..938a183 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -640,7 +640,7 @@  static int vmdk_open_vmdk4(BlockDriverState *bs,
 
     if (le32_to_cpu(header.version) > 3) {
         char buf[64];
-        snprintf(buf, sizeof(buf), "VMDK version %d",
+        snprintf(buf, sizeof(buf), "VMDK version %" PRId32,
                  le32_to_cpu(header.version));
         error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
                   bs->device_name, "vmdk", buf);
@@ -671,8 +671,9 @@  static int vmdk_open_vmdk4(BlockDriverState *bs,
     }
     if (bdrv_getlength(file) <
             le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE) {
-        error_setg(errp, "File truncated, expecting at least %lld bytes",
-                   le64_to_cpu(header.grain_offset) * BDRV_SECTOR_SIZE);
+        error_setg(errp, "File truncated, expecting at least %" PRId64 " bytes",
+                   (int64_t)(le64_to_cpu(header.grain_offset)
+                             * BDRV_SECTOR_SIZE));
         return -EINVAL;
     }
 
@@ -1720,7 +1721,7 @@  static int vmdk_create(const char *filename, QEMUOptionParameter *options,
         "\n"
         "ddb.virtualHWVersion = \"%d\"\n"
         "ddb.geometry.cylinders = \"%" PRId64 "\"\n"
-        "ddb.geometry.heads = \"%d\"\n"
+        "ddb.geometry.heads = \"%" PRIu32 "\"\n"
         "ddb.geometry.sectors = \"63\"\n"
         "ddb.adapterType = \"%s\"\n";
 
@@ -1780,9 +1781,9 @@  static int vmdk_create(const char *filename, QEMUOptionParameter *options,
              strcmp(fmt, "twoGbMaxExtentFlat"));
     compress = !strcmp(fmt, "streamOptimized");
     if (flat) {
-        desc_extent_line = "RW %lld FLAT \"%s\" 0\n";
+        desc_extent_line = "RW %" PRId64 " FLAT \"%s\" 0\n";
     } else {
-        desc_extent_line = "RW %lld SPARSE \"%s\"\n";
+        desc_extent_line = "RW %" PRId64 " SPARSE \"%s\"\n";
     }
     if (flat && backing_file) {
         error_setg(errp, "Flat image can't have backing file");