From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43101) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUeIf-0007Zp-Ji for qemu-devel@nongnu.org; Fri, 11 Oct 2013 11:06:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VUeIZ-0005OX-Hv for qemu-devel@nongnu.org; Fri, 11 Oct 2013 11:06:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14059) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUeIZ-0005M4-9i for qemu-devel@nongnu.org; Fri, 11 Oct 2013 11:06:39 -0400 From: Kevin Wolf Date: Fri, 11 Oct 2013 17:05:14 +0200 Message-Id: <1381503951-27985-25-git-send-email-kwolf@redhat.com> In-Reply-To: <1381503951-27985-1-git-send-email-kwolf@redhat.com> References: <1381503951-27985-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 24/61] qcow2: Use better type for numerical snapshot ID List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: 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 Signed-off-by: Kevin Wolf --- 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 fe7e14c..884b06d 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.1.4