vcs-svn: Check for errors from open()
authorJonathan Nieder <jrnieder@gmail.com>
Sat, 20 Nov 2010 00:46:06 +0000 (18:46 -0600)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 Nov 2010 22:51:42 +0000 (14:51 -0800)
test-svn-fe segfaults when passed a bogus path.  Simplify debugging by
exiting with a meaningful error message instead.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/svn-fe/svn-fe.c
test-svn-fe.c
vcs-svn/svndump.c
vcs-svn/svndump.h

index a2677b03e0ff8347d13a5d56f4fa2e1aba18824a..35db24f5eae600a973391915ceb61c4635941aec 100644 (file)
@@ -8,7 +8,8 @@
 
 int main(int argc, char **argv)
 {
-       svndump_init(NULL);
+       if (svndump_init(NULL))
+               return 1;
        svndump_read((argc > 1) ? argv[1] : NULL);
        svndump_deinit();
        svndump_reset();
index 77cf78abcfd18532b1b75e5ad5efa21b27f1a28c..b42ba789b176160285844e49cb834d60170d9a54 100644 (file)
@@ -9,7 +9,8 @@ int main(int argc, char *argv[])
 {
        if (argc != 2)
                usage("test-svn-fe <file>");
-       svndump_init(argv[1]);
+       if (svndump_init(argv[1]))
+               return 1;
        svndump_read(NULL);
        svndump_deinit();
        svndump_reset();
index 6b64c1b8573c00fd09f6387bbda3714d1336356c..db11851225caa677f187c7142e4fb55f745994fa 100644 (file)
@@ -290,14 +290,16 @@ void svndump_read(const char *url)
                handle_revision();
 }
 
-void svndump_init(const char *filename)
+int svndump_init(const char *filename)
 {
-       buffer_init(filename);
+       if (buffer_init(filename))
+               return error("cannot open %s: %s", filename, strerror(errno));
        repo_init();
        reset_dump_ctx(~0);
        reset_rev_ctx(0);
        reset_node_ctx(NULL);
        init_keys();
+       return 0;
 }
 
 void svndump_deinit(void)
index 93c412f14a4ca48b9de18325c09d69f051d97647..df9ceb0e8d473b65fc22ac142d3856dc4f9980e0 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef SVNDUMP_H_
 #define SVNDUMP_H_
 
-void svndump_init(const char *filename);
+int svndump_init(const char *filename);
 void svndump_read(const char *url);
 void svndump_deinit(void);
 void svndump_reset(void);