commit - 9f42ff692bc2cb443e1aa112484d293022ce3a30
commit + 793c30b5d7b2959c83174499b64578dde045f9ee
blob - fd76c1551b254d17ac5f497c18317b74d445b335
blob + be07889760fc4487623d8280255a27183820436b
--- got/got.c
+++ got/got.c
#include "got_commit_graph.h"
#include "got_blame.h"
#include "got_privsep.h"
+#include "got_opentemp.h"
#ifndef nitems
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
{
struct got_pathlist_entry *pe;
const struct got_error *err = NULL;
- char *tmppath = NULL;
char *tmpfile = NULL;
char *cmdline_log = (char *)arg;
char buf[1024];
return got_error_prefix_errno("malloc");
strlcpy(*logmsg, cmdline_log, len);
return NULL;
- }
-
- tmppath = getenv("TMPDIR");
- if (tmppath == NULL || strlen(tmppath) == 0)
- tmppath = "/tmp";
-
- if (asprintf(&tmpfile, "%s/got-XXXXXXXXXX", tmppath) == -1) {
- err = got_error_prefix_errno("asprintf");
- return err;
}
- fd = mkstemp(tmpfile);
- if (fd < 0) {
- err = got_error_prefix_errno("mktemp");
- free(tmpfile);
+ err = got_opentemp_named_fd(&tmpfile, &fd, "got-XXXXXXXXXX");
+ if (err)
return err;
- }
dprintf(fd, "\n"
"# changes to be committed:\n");