Appease Sun Studio by renaming "tmpfile"

On Solaris the system headers define the "tmpfile" name, which'll cause Git compiled with Sun Studio 12 Update 1 to whine about us redefining the name: "pack-write.c", line 76: warning: name redefined by pragma redefine_extname declared static: tmpfile (E_PRAGMA_REDEFINE_STATIC) "sha1_file.c", line 2455: warning: name redefined by pragma redefine_extname declared static: tmpfile (E_PRAGMA_REDEFINE_STATIC) "fast-import.c", line 858: warning: name redefined by pragma redefine_extname declared static: tmpfile (E_PRAGMA_REDEFINE_STATIC) "builtin/index-pack.c", line 175: warning: name redefined by pragma redefine_extname declared static: tmpfile (E_PRAGMA_REDEFINE_STATIC) Just renaming the "tmpfile" variable to "tmp_file" in the relevant places is the easiest way to fix this. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Dec 21, 2011 at 01:18 UTC ab1900a36ef7fcfe872ff9d0803f9442e356c2f0
4 files changed +16 -16
builtin/index-pack.c
+3 -3
@@ -172,10 +172,10 @@ static const char *open_pack_file(const char *pack_name)
172 if (from_stdin) {
173 input_fd = 0;
174 if (!pack_name) {
175 - static char tmpfile[PATH_MAX];
176 - output_fd = odb_mkstemp(tmpfile, sizeof(tmpfile),
175 + static char tmp_file[PATH_MAX];
176 + output_fd = odb_mkstemp(tmp_file, sizeof(tmp_file),
177 "pack/tmp_pack_XXXXXX");
178 - pack_name = xstrdup(tmpfile);
178 + pack_name = xstrdup(tmp_file);
179 } else
180 output_fd = open(pack_name, O_CREAT|O_EXCL|O_RDWR, 0600);
181 if (output_fd < 0)
fast-import.c
+4 -4
@@ -855,15 +855,15 @@ static struct tree_content *dup_tree_content(struct tree_content *s)
855
856 static void start_packfile(void)
857 {
858 - static char tmpfile[PATH_MAX];
858 + static char tmp_file[PATH_MAX];
859 struct packed_git *p;
860 struct pack_header hdr;
861 int pack_fd;
862
863 - pack_fd = odb_mkstemp(tmpfile, sizeof(tmpfile),
863 + pack_fd = odb_mkstemp(tmp_file, sizeof(tmp_file),
864 "pack/tmp_pack_XXXXXX");
865 - p = xcalloc(1, sizeof(*p) + strlen(tmpfile) + 2);
866 - strcpy(p->pack_name, tmpfile);
865 + p = xcalloc(1, sizeof(*p) + strlen(tmp_file) + 2);
866 + strcpy(p->pack_name, tmp_file);
867 p->pack_fd = pack_fd;
868 p->do_not_close = 1;
869 pack_file = sha1fd(pack_fd, p->pack_name);
pack-write.c
+3 -3
@@ -73,9 +73,9 @@ const char *write_idx_file(const char *index_name, struct pack_idx_entry **objec
73 f = sha1fd_check(index_name);
74 } else {
75 if (!index_name) {
76 - static char tmpfile[PATH_MAX];
77 - fd = odb_mkstemp(tmpfile, sizeof(tmpfile), "pack/tmp_idx_XXXXXX");
78 - index_name = xstrdup(tmpfile);
76 + static char tmp_file[PATH_MAX];
77 + fd = odb_mkstemp(tmp_file, sizeof(tmp_file), "pack/tmp_idx_XXXXXX");
78 + index_name = xstrdup(tmp_file);
79 } else {
80 unlink(index_name);
81 fd = open(index_name, O_CREAT|O_EXCL|O_WRONLY, 0600);
sha1_file.c
+6 -6
@@ -2452,15 +2452,15 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
2452 git_SHA_CTX c;
2453 unsigned char parano_sha1[20];
2454 char *filename;
2455 - static char tmpfile[PATH_MAX];
2455 + static char tmp_file[PATH_MAX];
2456
2457 filename = sha1_file_name(sha1);
2458 - fd = create_tmpfile(tmpfile, sizeof(tmpfile), filename);
2458 + fd = create_tmpfile(tmp_file, sizeof(tmp_file), filename);
2459 if (fd < 0) {
2460 if (errno == EACCES)
2461 return error("insufficient permission for adding an object to repository database %s\n", get_object_directory());
2462 else
2463 - return error("unable to create temporary sha1 filename %s: %s\n", tmpfile, strerror(errno));
2463 + return error("unable to create temporary sha1 filename %s: %s\n", tmp_file, strerror(errno));
2464 }
2465
2466 /* Set it up */
@@ -2505,12 +2505,12 @@ static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
2505 struct utimbuf utb;
2506 utb.actime = mtime;
2507 utb.modtime = mtime;
2508 - if (utime(tmpfile, &utb) < 0)
2508 + if (utime(tmp_file, &utb) < 0)
2509 warning("failed utime() on %s: %s",
2510 - tmpfile, strerror(errno));
2510 + tmp_file, strerror(errno));
2511 }
2512
2513 - return move_temp_to_file(tmpfile, filename);
2513 + return move_temp_to_file(tmp_file, filename);
2514 }
2515
2516 int write_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *returnsha1)