summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f21a47b)
raw | patch | inline | side by side (parent: f21a47b)
author | Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br> | |
Tue, 14 Aug 2007 19:45:58 +0000 (16:45 -0300) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 15 Aug 2007 05:20:26 +0000 (22:20 -0700) |
xmkstemp() performs error checking and prints a standard error message when
an error occur.
Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
an error occur.
Signed-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin-pack-objects.c | patch | blob | history | |
fast-import.c | patch | blob | history | |
index-pack.c | patch | blob | history | |
merge-recursive.c | patch | blob | history | |
pack-write.c | patch | blob | history | |
unpack-file.c | patch | blob | history |
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 5e9d1fd86ce5ee18dcb9ace9595b925f7630b6e8..51a850e1113f6d89cbd7730949a444b330231b1c 100644 (file)
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
static int open_object_dir_tmp(const char *path)
{
snprintf(tmpname, sizeof(tmpname), "%s/%s", get_object_directory(), path);
- return mkstemp(tmpname);
+ return xmkstemp(tmpname);
}
/* forward declaration for write_pack_file */
f = sha1fd(1, "<stdout>");
} else {
int fd = open_object_dir_tmp("tmp_pack_XXXXXX");
- if (fd < 0)
- die("unable to create %s: %s\n", tmpname, strerror(errno));
pack_tmp_name = xstrdup(tmpname);
f = sha1fd(fd, pack_tmp_name);
}
diff --git a/fast-import.c b/fast-import.c
index 99a19d89e8b50417fc8abc86d9253276bc8943a8..170cccdcebfd3c715c17d7d762556cd3878a5fd8 100644 (file)
--- a/fast-import.c
+++ b/fast-import.c
snprintf(tmpfile, sizeof(tmpfile),
"%s/tmp_pack_XXXXXX", get_object_directory());
- pack_fd = mkstemp(tmpfile);
- if (pack_fd < 0)
- die("Can't create %s: %s", tmpfile, strerror(errno));
+ pack_fd = xmkstemp(tmpfile);
p = xcalloc(1, sizeof(*p) + strlen(tmpfile) + 2);
strcpy(p->pack_name, tmpfile);
p->pack_fd = pack_fd;
snprintf(tmpfile, sizeof(tmpfile),
"%s/tmp_idx_XXXXXX", get_object_directory());
- idx_fd = mkstemp(tmpfile);
- if (idx_fd < 0)
- die("Can't create %s: %s", tmpfile, strerror(errno));
+ idx_fd = xmkstemp(tmpfile);
f = sha1fd(idx_fd, tmpfile);
sha1write(f, array, 256 * sizeof(int));
SHA1_Init(&ctx);
diff --git a/index-pack.c b/index-pack.c
index 8403c36b63c041fe0c81276391a0bbea906e833d..db58e050410197f6eda4b91705e20a8bfc87b088 100644 (file)
--- a/index-pack.c
+++ b/index-pack.c
static char tmpfile[PATH_MAX];
snprintf(tmpfile, sizeof(tmpfile),
"%s/tmp_pack_XXXXXX", get_object_directory());
- output_fd = mkstemp(tmpfile);
+ output_fd = xmkstemp(tmpfile);
pack_name = xstrdup(tmpfile);
} else
output_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600);
diff --git a/merge-recursive.c b/merge-recursive.c
index 5326d7c97a693e409de2cbb406e08dd9fac77577..16f6a0f98b5df8fbb9bb5263d0d32afca678cbec 100644 (file)
--- a/merge-recursive.c
+++ b/merge-recursive.c
int fd;
strcpy(path, ".merge_file_XXXXXX");
- fd = mkstemp(path);
- if (fd < 0)
- die("unable to create temp-file");
+ fd = xmkstemp(path);
if (write_in_full(fd, src->ptr, src->size) != src->size)
die("unable to write temp-file");
close(fd);
diff --git a/pack-write.c b/pack-write.c
index 1cf5f7c9f0956a457de03c64238d298a9d996984..e59b197e5ebb301107f9a18b7765e18097a1c8e3 100644 (file)
--- a/pack-write.c
+++ b/pack-write.c
static char tmpfile[PATH_MAX];
snprintf(tmpfile, sizeof(tmpfile),
"%s/tmp_idx_XXXXXX", get_object_directory());
- fd = mkstemp(tmpfile);
+ fd = xmkstemp(tmpfile);
index_name = xstrdup(tmpfile);
} else {
unlink(index_name);
diff --git a/unpack-file.c b/unpack-file.c
index 25c56b374ae01ba890ee243368077c1316d9f0ba..65c66eb0bf34efee6485db3dbf8af11788c394f4 100644 (file)
--- a/unpack-file.c
+++ b/unpack-file.c
die("unable to read blob object %s", sha1_to_hex(sha1));
strcpy(path, ".merge_file_XXXXXX");
- fd = mkstemp(path);
- if (fd < 0)
- die("unable to create temp-file");
+ fd = xmkstemp(path);
if (write_in_full(fd, buf, size) != size)
die("unable to write temp-file");
close(fd);