diff --git a/cgit.h b/cgit.h index f01f6c9..6937c42 100644 --- a/cgit.h +++ b/cgit.h @@ -157,6 +157,7 @@ extern void cgit_querystring_cb(const char *name, const char *value); extern int chk_zero(int result, char *msg); extern int chk_positive(int result, char *msg); +extern int chk_non_negative(int result, char *msg); extern int hextoint(char c); extern char *trim_end(const char *str, char c); diff --git a/shared.c b/shared.c index 1a5b866..65fc8b2 100644 --- a/shared.c +++ b/shared.c @@ -86,6 +86,13 @@ int chk_positive(int result, char *msg) return result; } +int chk_non_negative(int result, char *msg) +{ + if (result < 0) + die("%s: %s",msg, strerror(errno)); + return result; +} + struct repoinfo *add_repo(const char *url) { struct repoinfo *ret;