]> granicus.if.org Git - cgit/commitdiff
added a chk_non_negative check
authorMichael Krelin <hacker@klever.net>
Fri, 20 Jul 2007 18:56:43 +0000 (20:56 +0200)
committerMichael Krelin <hacker@klever.net>
Fri, 20 Jul 2007 18:56:43 +0000 (20:56 +0200)
cgit.h
shared.c

diff --git a/cgit.h b/cgit.h
index f01f6c9c9a459b6ccc996dcb57a01e2072ffca30..6937c42900eea20c5e9824974aa9eccbb68f814b 100644 (file)
--- 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);
index 1a5b866e86630df4964961086edbb0ea1ec0d48e..65fc8b25d25a165a70ee49e2916cfd4cb69071ad 100644 (file)
--- 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;