提交 00c49b21 编写于 作者: M Max Reitz 提交者: Kevin Wolf

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.
Signed-off-by: NMax Reitz <mreitz@redhat.com>
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
上级 84757f7e
...@@ -292,7 +292,8 @@ static void find_new_snapshot_id(BlockDriverState *bs, ...@@ -292,7 +292,8 @@ static void find_new_snapshot_id(BlockDriverState *bs,
{ {
BDRVQcowState *s = bs->opaque; BDRVQcowState *s = bs->opaque;
QCowSnapshot *sn; QCowSnapshot *sn;
int i, id, id_max = 0; int i;
unsigned long id, id_max = 0;
for(i = 0; i < s->nb_snapshots; i++) { for(i = 0; i < s->nb_snapshots; i++) {
sn = s->snapshots + i; sn = s->snapshots + i;
...@@ -300,7 +301,7 @@ static void find_new_snapshot_id(BlockDriverState *bs, ...@@ -300,7 +301,7 @@ static void find_new_snapshot_id(BlockDriverState *bs,
if (id > id_max) if (id > id_max)
id_max = id; 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, static int find_snapshot_by_id_and_name(BlockDriverState *bs,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册