From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60555) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9bkq-0003sX-H5 for qemu-devel@nongnu.org; Thu, 17 Dec 2015 11:50:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9bkn-0007Wp-PT for qemu-devel@nongnu.org; Thu, 17 Dec 2015 11:50:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54851) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9bkn-0007WY-LZ for qemu-devel@nongnu.org; Thu, 17 Dec 2015 11:50:09 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 489B98A14F for ; Thu, 17 Dec 2015 16:50:09 +0000 (UTC) Received: from blackfin.pond.sub.org ([10.3.113.12]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBHGo7XB027071 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 17 Dec 2015 11:50:08 -0500 From: Markus Armbruster Date: Thu, 17 Dec 2015 17:49:48 +0100 Message-Id: <1450371004-26866-8-git-send-email-armbru@redhat.com> In-Reply-To: <1450371004-26866-1-git-send-email-armbru@redhat.com> References: <1450371004-26866-1-git-send-email-armbru@redhat.com> Subject: [Qemu-devel] [PATCH v2 07/23] qemu-nbd: Clean up "Failed to load snapshot" error message List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org bdrv_snapshot_load_tmp() sets an error and returns -errno on failure. We report both even though the error message is self-contained. Drop the redundant strerror(). While there: setting errno right before exit() is pointless, so drop that, too. Signed-off-by: Markus Armbruster --- qemu-nbd.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/qemu-nbd.c b/qemu-nbd.c index ac7ceef..b8ee2d0 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -156,8 +156,7 @@ static int find_partition(BlockBackend *blk, int partition, int ret; if ((ret = blk_read(blk, 0, data, 1)) < 0) { - errno = -ret; - error_report("error while reading: %s", strerror(errno)); + error_report("error while reading: %s", strerror(-ret)); exit(EXIT_FAILURE); } @@ -178,8 +177,7 @@ static int find_partition(BlockBackend *blk, int partition, int j; if ((ret = blk_read(blk, mbr[i].start_sector_abs, data1, 1)) < 0) { - errno = -ret; - error_report("error while reading: %s", strerror(errno)); + error_report("error while reading: %s", strerror(-ret)); exit(EXIT_FAILURE); } @@ -719,9 +717,8 @@ int main(int argc, char **argv) &local_err); } if (ret < 0) { - errno = -ret; - error_report("Failed to load snapshot: %s: %s", - error_get_pretty(local_err), strerror(errno)); + error_report("Failed to load snapshot: %s", + error_get_pretty(local_err)); exit(EXIT_FAILURE); } @@ -736,9 +733,8 @@ int main(int argc, char **argv) if (partition != -1) { ret = find_partition(blk, partition, &dev_offset, &fd_size); if (ret < 0) { - errno = -ret; error_report("Could not find partition %d: %s", partition, - strerror(errno)); + strerror(-ret)); exit(EXIT_FAILURE); } } -- 2.4.3