aboutsummaryrefslogtreecommitdiff
path: root/qga
diff options
context:
space:
mode:
authorLuiz Capitulino <lcapitulino@redhat.com>2012-11-27 11:02:01 -0200
committerMichael Roth <mdroth@linux.vnet.ibm.com>2013-01-08 16:38:11 -0600
commit071673b09021b60eab268653c6bcfba92eea7603 (patch)
treeabcd72cc451b4b0c1a659d0752e155096c6ab6ec /qga
parent617fbbc13219d26dd71d100d83d617ec8acf5e2d (diff)
qemu-ga: qmp_guest_fstrim(): get rid of sprintf() + error_set()
Convert them to error_setg_errno(). Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Michael Roth <mdroth@linux.vnet.ibm.com> Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
Diffstat (limited to 'qga')
-rw-r--r--qga/commands-posix.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 9ad2891d77..fa786e53e9 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;
}