From patchwork Tue Nov 27 13:02:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 202227 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 884B52C008E for ; Wed, 28 Nov 2012 00:51:16 +1100 (EST) Received: from localhost ([::1]:50874 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdKoj-0001VG-Dg for incoming@patchwork.ozlabs.org; Tue, 27 Nov 2012 08:03:13 -0500 Received: from eggs.gnu.org ([208.118.235.92]:53170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdKnw-0007ob-U3 for qemu-devel@nongnu.org; Tue, 27 Nov 2012 08:02:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TdKnr-0005ar-6M for qemu-devel@nongnu.org; Tue, 27 Nov 2012 08:02:24 -0500 Received: from mx1.redhat.com ([209.132.183.28]:21968) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdKnq-0005am-Uo for qemu-devel@nongnu.org; Tue, 27 Nov 2012 08:02:19 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qARD2GxN017330 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 27 Nov 2012 08:02:16 -0500 Received: from localhost (ovpn-113-91.phx2.redhat.com [10.3.113.91]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qARD2Fnc006157; Tue, 27 Nov 2012 08:02:16 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2012 11:02:00 -0200 Message-Id: <1354021324-31561-7-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1354021324-31561-1-git-send-email-lcapitulino@redhat.com> References: <1354021324-31561-1-git-send-email-lcapitulino@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: mdroth@linux.vnet.ibm.com Subject: [Qemu-devel] [PATCH 06/10] qemu-ga: qmp_guest_fsfreeze_*(): get rid of sprintf() + error_set() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Convert them to error_setg_errno(). Signed-off-by: Luiz Capitulino Reviewed-by: Michael Roth --- qga/commands-posix.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 59bb32d..9325433 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -433,7 +433,6 @@ int64_t qmp_guest_fsfreeze_freeze(Error **err) struct FsMount *mount; Error *local_err = NULL; int fd; - char err_msg[512]; slog("guest-fsfreeze called"); @@ -450,9 +449,7 @@ int64_t qmp_guest_fsfreeze_freeze(Error **err) QTAILQ_FOREACH(mount, &mounts, next) { fd = qemu_open(mount->dirname, O_RDONLY); if (fd == -1) { - sprintf(err_msg, "failed to open %s, %s", mount->dirname, - strerror(errno)); - error_set(err, QERR_QGA_COMMAND_FAILED, err_msg); + error_setg_errno(err, errno, "failed to open %s", mount->dirname); goto error; } @@ -468,9 +465,8 @@ int64_t qmp_guest_fsfreeze_freeze(Error **err) ret = ioctl(fd, FIFREEZE); if (ret == -1) { if (errno != EOPNOTSUPP) { - sprintf(err_msg, "failed to freeze %s, %s", - mount->dirname, strerror(errno)); - error_set(err, QERR_QGA_COMMAND_FAILED, err_msg); + error_setg_errno(err, errno, "failed to freeze %s", + mount->dirname); close(fd); goto error; }