Skip to contentSkip to conversation

qcow2: Use better type for numerical snapshot ID

PATCH Applied Max Reitz 2 participants 2 messages Oct 9, 2013 Block layer

lore
Share & tools
lore

Max Reitz

author
#0 lore raw

PATCH 1/1 qcow2: Use better type for numerical snapshot ID

When trying to find a new snapshot ID, the existing ones are converted to integers using strtoul. This function returns an unsigned long, therefore its result should be saved in an unsigned long as well.

---
 block/qcow2-snapshot.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
block/qcow2-snapshot.c +3 -2
index 812dab2..5b437ce 100644
@@ -292,7 +292,8 @@ static void find_new_snapshot_id(BlockDriverState *bs,
 {
     BDRVQcowState *s = bs->opaque;
     QCowSnapshot *sn;
-    int i, id, id_max = 0;
+    int i;
+    unsigned long id, id_max = 0;
 
     for(i = 0; i < s->nb_snapshots; i++) {
         sn = s->snapshots + i;
@@ -300,7 +301,7 @@ static void find_new_snapshot_id(BlockDriverState *bs,
         if (id > id_max)
             id_max = id;
     }
-    snprintf(id_str, id_str_size, "%d", id_max + 1);
+    snprintf(id_str, id_str_size, "%lu", id_max + 1);
 }
 
 static int find_snapshot_by_id_and_name(BlockDriverState *bs,
Signature · 1 line
1.8.3.1
Applied
#1 lore raw

Am 09.10.2013 um 14:42 hat Max Reitz geschrieben:

Quoted 5 lines

When trying to find a new snapshot ID, the existing ones are converted to integers using strtoul. This function returns an unsigned long, therefore its result should be saved in an unsigned long as well.

Thanks, applied to the block branch.

Kevin