From patchwork Tue Nov 27 13:02:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Capitulino X-Patchwork-Id: 202210 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 538912C008E for ; Wed, 28 Nov 2012 00:03:03 +1100 (EST) Received: from localhost ([::1]:48256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdKoX-00007J-DJ for incoming@patchwork.ozlabs.org; Tue, 27 Nov 2012 08:03:01 -0500 Received: from eggs.gnu.org ([208.118.235.92]:53195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdKo1-0007si-3F for qemu-devel@nongnu.org; Tue, 27 Nov 2012 08:02:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TdKnu-0005bf-MQ for qemu-devel@nongnu.org; Tue, 27 Nov 2012 08:02:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:23333) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TdKnu-0005bY-DK for qemu-devel@nongnu.org; Tue, 27 Nov 2012 08:02:22 -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 qARD2I7f017157 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 27 Nov 2012 08:02:18 -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 qARD2HOk006167; Tue, 27 Nov 2012 08:02:17 -0500 From: Luiz Capitulino To: qemu-devel@nongnu.org Date: Tue, 27 Nov 2012 11:02:01 -0200 Message-Id: <1354021324-31561-8-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 07/10] qemu-ga: qmp_guest_fstrim(): 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 9325433..72ef8ba 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -565,7 +565,6 @@ void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err) struct FsMount *mount; int fd; Error *local_err = NULL; - char err_msg[512]; struct fstrim_range r = { .start = 0, .len = -1, @@ -584,9 +583,7 @@ void qmp_guest_fstrim(bool has_minimum, int64_t minimum, 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; } @@ -599,9 +596,8 @@ void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err) ret = ioctl(fd, FITRIM, &r); if (ret == -1) { if (errno != ENOTTY && errno != EOPNOTSUPP) { - sprintf(err_msg, "failed to trim %s, %s", - mount->dirname, strerror(errno)); - error_set(err, QERR_QGA_COMMAND_FAILED, err_msg); + error_setg_errno(err, errno, "failed to trim %s", + mount->dirname); close(fd); goto error; }