diff options
| author | Patrick Steinhardt <ps@pks.im> | 2019-06-16 11:03:08 +0200 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2019-08-01 11:55:48 +0200 |
| commit | c8e63812c5f2402bab4f74f68d46843d7d94123c (patch) | |
| tree | ed304f9ea8c557e053bf95de7dab5d9d6b15d836 /src/errors.c | |
| parent | e8f6341105c7221e1358a5f6fda23e57c17eadc5 (diff) | |
| download | libgit2-c8e63812c5f2402bab4f74f68d46843d7d94123c.tar.gz | |
errors: introduce `git_error_vset` function
Right now, we only provide a `git_error_set` that has a variadic
function signature. It's impossible to drive this function in a
C89-compliant way from other functions that have a variadic
signature, though, like for example `git_parse_error`.
Implement a new `git_error_vset` function that gets a `va_list`
as parameter, fixing the above problem.
Diffstat (limited to 'src/errors.c')
| -rw-r--r-- | src/errors.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/errors.c b/src/errors.c index 8ef491916..18d6c2dc8 100644 --- a/src/errors.c +++ b/src/errors.c @@ -49,9 +49,17 @@ void git_error_set_oom(void) GIT_GLOBAL->last_error = &g_git_oom_error; } -void git_error_set(int error_class, const char *string, ...) +void git_error_set(int error_class, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + git_error_vset(error_class, fmt, ap); + va_end(ap); +} + +void git_error_vset(int error_class, const char *fmt, va_list ap) { - va_list arglist; #ifdef GIT_WIN32 DWORD win32_error_code = (error_class == GIT_ERROR_OS) ? GetLastError() : 0; #endif @@ -59,11 +67,8 @@ void git_error_set(int error_class, const char *string, ...) git_buf *buf = &GIT_GLOBAL->error_buf; git_buf_clear(buf); - if (string) { - va_start(arglist, string); - git_buf_vprintf(buf, string, arglist); - va_end(arglist); - + if (fmt) { + git_buf_vprintf(buf, fmt, ap); if (error_class == GIT_ERROR_OS) git_buf_PUTS(buf, ": "); } |
