submodule--helper, module_clone: catch fprintf failure
authorStefan Beller <sbeller@google.com>
Fri, 1 Apr 2016 00:17:29 +0000 (17:17 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Apr 2016 21:04:33 +0000 (14:04 -0700)
The return value of fprintf is unchecked, which may lead to
unreported errors. Use fprintf_or_die to report the error to the user.

Signed-off-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/submodule--helper.c
index b59c66f0116fbc3b7157db0fd13f2a067a672000..b3a60f56c345fce8dabc31826769ff879fbde931 100644 (file)
@@ -229,8 +229,8 @@ static int module_clone(int argc, const char **argv, const char *prefix)
        if (!submodule_dot_git)
                die_errno(_("cannot open file '%s'"), sb.buf);
 
-       fprintf(submodule_dot_git, "gitdir: %s\n",
-               relative_path(sm_gitdir, path, &rel_path));
+       fprintf_or_die(submodule_dot_git, "gitdir: %s\n",
+                      relative_path(sm_gitdir, path, &rel_path));
        if (fclose(submodule_dot_git))
                die(_("could not close file %s"), sb.buf);
        strbuf_reset(&sb);