Fix false positive -Wuninitialized warnings GCC produces several -Wuninitialized warnings. Most of them can be fixed if we make visible for gcc that git__throw() and git__rethrow() always return first argument. Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
diff --git a/src/common.h b/src/common.h
index e1e7f00..5986a65 100644
--- a/src/common.h
+++ b/src/common.h
@@ -46,8 +46,13 @@ typedef SSIZE_T ssize_t;
#include "thread-utils.h"
#include "bswap.h"
-extern int git__throw(int error, const char *, ...) GIT_FORMAT_PRINTF(2, 3);
-extern int git__rethrow(int error, const char *, ...) GIT_FORMAT_PRINTF(2, 3);
+extern void git___throw(const char *, ...) GIT_FORMAT_PRINTF(1, 2);
+#define git__throw(error, ...) \
+ (git___throw(__VA_ARGS__), error)
+
+extern void git___rethrow(const char *, ...) GIT_FORMAT_PRINTF(1, 2);
+#define git__rethrow(error, ...) \
+ (git___rethrow(__VA_ARGS__), error)
#include "util.h"
diff --git a/src/errors.c b/src/errors.c
index e9022c3..5031245 100644
--- a/src/errors.c
+++ b/src/errors.c
@@ -77,7 +77,7 @@ const char *git_strerror(int num)
return "Unknown error";
}
-int git__rethrow(int error, const char *msg, ...)
+void git___rethrow(const char *msg, ...)
{
char new_error[1024];
char *old_error = NULL;
@@ -91,19 +91,15 @@ int git__rethrow(int error, const char *msg, ...)
old_error = strdup(g_last_error);
snprintf(g_last_error, sizeof(g_last_error), "%s \n - %s", new_error, old_error);
free(old_error);
-
- return error;
}
-int git__throw(int error, const char *msg, ...)
+void git___throw(const char *msg, ...)
{
va_list va;
va_start(va, msg);
vsnprintf(g_last_error, sizeof(g_last_error), msg, va);
va_end(va);
-
- return error;
}
const char *git_lasterror(void)