diff options
author | Dustin Sallings <dustin@spy.net> | 2009-07-14 23:02:14 -0700 |
---|---|---|
committer | Trond Norbye <Trond.Norbye@sun.com> | 2009-08-19 21:28:34 +0200 |
commit | 891082f349304fb802c3df7491e337b47771eab1 (patch) | |
tree | d67385101a9157a5aaa355b86b1111d60e350bfd /util.c | |
parent | 7db0d07c754d1a54116aa2b424b35b429073b15e (diff) | |
download | memcached-891082f349304fb802c3df7491e337b47771eab1.tar.gz |
vperror implementation
This allows us to provide much more useful error messages for
syscalls.
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 17 |
1 files changed, 16 insertions, 1 deletions
@@ -1,9 +1,10 @@ -#include <stdlib.h> +#include <stdio.h> #include <assert.h> #include <ctype.h> #include <errno.h> #include <string.h> #include <stdlib.h> +#include <stdarg.h> #include "memcached.h" @@ -88,3 +89,17 @@ bool safe_strtol(const char *str, int32_t *out) { } return false; } + +void vperror(const char *fmt, ...) { + int old_errno = errno; + char buf[80]; + va_list ap; + + va_start(ap, fmt); + vsnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + + errno = old_errno; + + perror(buf); +} |