[Pkg-libvirt-commits] [libguestfs] 60/266: daemon: add and use a reply_with_unavailable_feature macro

Hilko Bengen bengen at moszumanska.debian.org
Fri Oct 3 14:41:42 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to annotated tag debian/1%1.27.35-1
in repository libguestfs.

commit f5c74637e36b6c8eb1281f93f7fe26f9016e405c
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.
---
 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 94537b7..fb74e91 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -245,6 +245,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 ca748d2..951729c 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