diff --git a/daemon/daemon.h b/daemon/daemon.h index c92e1108e..6f288c172 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -145,10 +145,11 @@ extern void main_loop (int sock) __attribute__((noreturn)); * NB: you don't need to prefix the string with the current command, * it is added automatically by the client-side RPC stubs. */ -extern void reply_with_error (const char *fs, ...) - __attribute__((format (printf,1,2))); +extern void reply_with_error_errno (int err, const char *fs, ...) + __attribute__((format (printf,2,3))); 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__) /* daemon functions that receive files (FileIn) should call diff --git a/daemon/proto.c b/daemon/proto.c index ac62a6be6..d3cf2810a 100644 --- a/daemon/proto.c +++ b/daemon/proto.c @@ -221,16 +221,16 @@ main_loop (int _sock) static void send_error (int errnum, const char *msg); void -reply_with_error (const char *fs, ...) +reply_with_error_errno (int err, const char *fs, ...) { - char err[GUESTFS_ERROR_LEN]; + char buf[GUESTFS_ERROR_LEN]; va_list args; va_start (args, fs); - vsnprintf (err, sizeof err, fs, args); + vsnprintf (buf, sizeof buf, fs, args); va_end (args); - send_error (0, err); + send_error (err, buf); } void