Received: from eggs.gnu.org ([2001:4830:134:3::10]:58432) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTt6S-0001Ia-DY for qemu-devel@nongnu.org; Wed, 09 Oct 2013 08:43:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTt6I-0000Es-E2 for qemu-devel@nongnu.org; Wed, 09 Oct 2013 08:43:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:7898) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTt6I-0000Eg-6N for qemu-devel@nongnu.org; Wed, 09 Oct 2013 08:42:50 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r99Cgnei023617 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 9 Oct 2013 08:42:49 -0400 From: Max Reitz Date: Wed, 9 Oct 2013 14:42:47 +0200 Message-Id: <1381322567-18766-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH] qcow2: Use better type for numerical snapshot ID List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz 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: Max Reitz --- block/qcow2-snapshot.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 812dab2..5b437ce 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -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, -- 1.8.3.1