[PATCHv2 5/5] submodule--helper, module_clone: catch fprintf failure
- From
Stefan Beller <sbeller@google.com>
- Date
- Mar 31, 2016, 21:04 UTC
- Message-ID
- <1459458280-17619-6-git-send-email-sbeller@google.com>
- In-Reply-To
- <1459458280-17619-1-git-send-email-sbeller@google.com>
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> --- builtin/submodule--helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c index 56c3033..89cbbda 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -240,8 +240,8 @@ static int module_clone(int argc, const char **argv, const char *prefix) submodule_dot_git = fopen(sb.buf, "w"); 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);
-- 2.5.0.264.g39f00fe