From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50560) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkFAe-0005W0-OX for qemu-devel@nongnu.org; Tue, 13 May 2014 12:03:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WkFAR-0008GX-BI for qemu-devel@nongnu.org; Tue, 13 May 2014 12:03:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44399) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WkFAR-0008G6-1z for qemu-devel@nongnu.org; Tue, 13 May 2014 12:02:59 -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 s4DG2v6f005144 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 13 May 2014 12:02:58 -0400 From: Markus Armbruster Date: Tue, 13 May 2014 18:02:45 +0200 Message-Id: <1399996972-23429-12-git-send-email-armbru@redhat.com> In-Reply-To: <1399996972-23429-1-git-send-email-armbru@redhat.com> References: <1399996972-23429-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH 11/18] block/vvfat: Propagate errors through init_directories() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com Completes the conversion of the open method to Error started in commit 015a103. Signed-off-by: Markus Armbruster --- block/vvfat.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index 3eccd68..c6a1211 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -831,7 +831,8 @@ static inline off_t cluster2sector(BDRVVVFATState* s, uint32_t cluster_num) } static int init_directories(BDRVVVFATState* s, - const char *dirname, int heads, int secs) + const char *dirname, int heads, int secs, + Error **errp) { bootsector_t* bootsector; mapping_t* mapping; @@ -892,8 +893,8 @@ static int init_directories(BDRVVVFATState* s, if (mapping->mode & MODE_DIRECTORY) { mapping->begin = cluster; if(read_directory(s, i)) { - fprintf(stderr, "Could not read directory %s\n", - mapping->path); + error_setg(errp, "Could not read directory %s", + mapping->path); return -1; } mapping = array_get(&(s->mapping), i); @@ -919,9 +920,10 @@ static int init_directories(BDRVVVFATState* s, cluster = mapping->end; if(cluster > s->cluster_count) { - fprintf(stderr,"Directory does not fit in FAT%d (capacity %.2f MB)\n", - s->fat_type, s->sector_count / 2000.0); - return -EINVAL; + error_setg(errp, + "Directory does not fit in FAT%d (capacity %.2f MB)", + s->fat_type, s->sector_count / 2000.0); + return -1; } /* fix fat for entry */ @@ -1169,7 +1171,7 @@ DLOG(if (stderr == NULL) { bs->total_sectors = cyls * heads * secs; - if (init_directories(s, dirname, heads, secs)) { + if (init_directories(s, dirname, heads, secs, errp)) { ret = -EIO; goto fail; } -- 1.8.1.4