commit - 0823ffc2f6c509dbcedfb15d0d1011a253b45ef9
commit + 1601cb9fb1c61348022d15d2f34797672e2c3cc3
blob - 3a7013aa09b5952fd99ebb4cbf7e06235e769d42
blob + 0ddfc1d7596b2d3089ba662148743015a36ab107
--- got/got.c
+++ got/got.c
{
char *initial_content = NULL;
const struct got_error *err = NULL;
+ int initial_content_len;
int fd;
- if (asprintf(&initial_content,
+ initial_content_len = asprintf(&initial_content,
"\n# %s to be imported to branch %s\n", path_dir,
- branch_name) == -1)
+ branch_name);
+ if (initial_content_len == -1)
return got_error_from_errno("asprintf");
err = got_opentemp_named_fd(logmsg_path, &fd,
if (err)
goto done;
- dprintf(fd, initial_content);
+ write(fd, initial_content, initial_content_len);
close(fd);
err = edit_logmsg(logmsg, editor, *logmsg_path, initial_content);
const struct got_error *err = NULL;
char *template = NULL, *initial_content = NULL;
char *editor = NULL;
+ int initial_content_len;
int fd = -1;
if (asprintf(&template, GOT_TMPDIR_STR "/got-tagmsg") == -1) {
goto done;
}
- if (asprintf(&initial_content, "\n# tagging commit %s as %s\n",
- commit_id_str, tag_name) == -1) {
+ initial_content_len = asprintf(&initial_content,
+ "\n# tagging commit %s as %s\n",
+ commit_id_str, tag_name);
+ if (initial_content_len == -1) {
err = got_error_from_errno("asprintf");
goto done;
}
if (err)
goto done;
- dprintf(fd, initial_content);
+ write(fd, initial_content, initial_content_len);
close(fd);
err = get_editor(&editor);
const struct got_error *err = NULL;
char *template = NULL;
struct collect_commit_logmsg_arg *a = arg;
+ int initial_content_len;
int fd;
size_t len;
if (asprintf(&template, "%s/logmsg", a->worktree_path) == -1)
return got_error_from_errno("asprintf");
- if (asprintf(&initial_content,
+ initial_content_len = asprintf(&initial_content,
"\n# changes to be committed on branch %s:\n",
- a->branch_name) == -1)
+ a->branch_name);
+ if (initial_content_len == -1)
return got_error_from_errno("asprintf");
err = got_opentemp_named_fd(&a->logmsg_path, &fd, template);
if (err)
goto done;
- dprintf(fd, initial_content);
+ write(fd, initial_content, initial_content_len);
TAILQ_FOREACH(pe, commitable_paths, entry) {
struct got_commitable *ct = pe->data;
char *logmsg = NULL, *new_msg = NULL, *editor = NULL;
const struct got_error *err = NULL;
struct got_commit_object *commit = NULL;
+ int logmsg_len;
int fd;
struct got_histedit_list_entry *folded = NULL;
err = got_object_commit_get_logmsg(&orig_logmsg, commit);
if (err)
goto done;
- if (asprintf(&new_msg,
+ logmsg_len = asprintf(&new_msg,
"%s\n# original log message of commit %s: %s",
- logmsg ? logmsg : "", id_str, orig_logmsg) == -1) {
+ logmsg ? logmsg : "", id_str, orig_logmsg);
+ if (logmsg_len == -1) {
err = got_error_from_errno("asprintf");
goto done;
}
if (err)
goto done;
- dprintf(fd, logmsg);
+ write(fd, logmsg, logmsg_len);
close(fd);
err = get_editor(&editor);