Author: Michael Krelin <hacker@klever.net>
added a chk_non_negative check
cgit.h | 1 + shared.c | 7 +++++++
diff --git a/cgit.h b/cgit.h index f01f6c9c9a459b6ccc996dcb57a01e2072ffca30..6937c42900eea20c5e9824974aa9eccbb68f814b 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 1a5b866e86630df4964961086edbb0ea1ec0d48e..65fc8b25d25a165a70ee49e2916cfd4cb69071ad 100644 --- a/shared.c +++ b/shared.c @@ -86,6 +86,13 @@ die("%s: %s", msg, strerror(errno)); 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;