Commit 63d8cd189e7eb9a410f04283cbe46d3d3f0a1924

Patrick Steinhardt 2019-06-16T11:17:17

apply: remove use of variadic error macro The macro `apply_err` is implemented as a variadic macro, which are not defined by C89. Convert it to a variadic function, instead.

diff --git a/src/apply.c b/src/apply.c
index 55b1a39..1ee9291 100644
--- a/src/apply.c
+++ b/src/apply.c
@@ -24,9 +24,6 @@
 #include "reader.h"
 #include "index.h"
 
-#define apply_err(...) \
-	( git_error_set(GIT_ERROR_PATCH, __VA_ARGS__), GIT_EAPPLYFAIL )
-
 typedef struct {
 	/* The lines that we allocate ourself are allocated out of the pool.
 	 * (Lines may have been allocated out of the diff.)
@@ -35,6 +32,18 @@ typedef struct {
 	git_vector lines;
 } patch_image;
 
+static int apply_err(const char *fmt, ...) GIT_FORMAT_PRINTF(1, 2);
+static int apply_err(const char *fmt, ...)
+{
+	va_list ap;
+
+	va_start(ap, fmt);
+	git_error_vset(GIT_ERROR_PATCH, fmt, ap);
+	va_end(ap);
+
+	return GIT_EAPPLYFAIL;
+}
+
 static void patch_line_init(
 	git_diff_line *out,
 	const char *in,