[Pkg-libvirt-commits] [libguestfs] 119/156: daemon: add and use a reply_with_unavailable_feature macro
Hilko Bengen
bengen at moszumanska.debian.org
Sat Aug 30 08:26:12 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch master
in repository libguestfs.
commit 3f9a3bd685bc4e3518530753686303255ee0edd0
Author: Pino Toscano <ptoscano at redhat.com>
Date: Thu Aug 7 10:45:04 2014 +0200
daemon: add and use a reply_with_unavailable_feature macro
Handy macro to reply the right way for an unavailable feature.
While generally used so far in generated code, it can shorten that a
bit, and avoid copy&paste when wanting to do manual feature checking.
(cherry picked from commit f5c74637e36b6c8eb1281f93f7fe26f9016e405c)
---
daemon/daemon.h | 6 ++++++
generator/daemon.ml | 6 +-----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 6535658..8f7e2c6 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -244,6 +244,12 @@ extern void reply_with_perror_errno (int err, const char *fs, ...)
__attribute__((format (printf,2,3)));
#define reply_with_error(...) reply_with_error_errno(0, __VA_ARGS__)
#define reply_with_perror(...) reply_with_perror_errno(errno, __VA_ARGS__)
+#define reply_with_unavailable_feature(feature) \
+ reply_with_error_errno (ENOTSUP, \
+ "feature '%s' is not available in this\n" \
+ "build of libguestfs. Read 'AVAILABILITY' in the guestfs(3) man page for\n" \
+ "how to check for the availability of features.", \
+ feature)
/* daemon functions that receive files (FileIn) should call
* receive_file for each FileIn parameter.
diff --git a/generator/daemon.ml b/generator/daemon.ml
index 548982b..0b56d7a 100644
--- a/generator/daemon.ml
+++ b/generator/daemon.ml
@@ -280,11 +280,7 @@ cleanup_free_mountable (mountable_t *mountable)
pr " if (! optgroup_%s_available ()) {\n" group;
if is_filein then
pr " cancel_receive ();\n";
- pr " reply_with_error_errno (ENOTSUP,\n";
- pr " \"feature '%%s' is not available in this\\n\"\n";
- pr " \"build of libguestfs. Read 'AVAILABILITY' in the guestfs(3) man page for\\n\"\n";
- pr " \"how to check for the availability of features.\",\n";
- pr " \"%s\");\n" group;
+ pr " reply_with_unavailable_feature (\"%s\");\n" group;
pr " goto done_no_free;\n";
pr " }\n";
pr "\n"
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git
More information about the Pkg-libvirt-commits
mailing list